babylon.module.d.ts 4.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Creates a rotation matrix
  3262. * @param yaw defines the yaw angle in radians (Y axis)
  3263. * @param pitch defines the pitch angle in radians (X axis)
  3264. * @param roll defines the roll angle in radians (X axis)
  3265. * @returns the new rotation matrix
  3266. */
  3267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3268. /**
  3269. * Creates a rotation matrix and stores it in a given matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3276. /**
  3277. * Creates a scaling matrix
  3278. * @param x defines the scale factor on X axis
  3279. * @param y defines the scale factor on Y axis
  3280. * @param z defines the scale factor on Z axis
  3281. * @returns the new matrix
  3282. */
  3283. static Scaling(x: number, y: number, z: number): Matrix;
  3284. /**
  3285. * Creates a scaling matrix and stores it in a given matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @param result defines the target matrix
  3290. */
  3291. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3292. /**
  3293. * Creates a translation matrix
  3294. * @param x defines the translation on X axis
  3295. * @param y defines the translation on Y axis
  3296. * @param z defines the translationon Z axis
  3297. * @returns the new matrix
  3298. */
  3299. static Translation(x: number, y: number, z: number): Matrix;
  3300. /**
  3301. * Creates a translation matrix and stores it in a given matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @param result defines the target matrix
  3306. */
  3307. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3308. /**
  3309. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3310. * @param startValue defines the start value
  3311. * @param endValue defines the end value
  3312. * @param gradient defines the gradient factor
  3313. * @returns the new matrix
  3314. */
  3315. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3316. /**
  3317. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @param result defines the Matrix object where to store data
  3322. */
  3323. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3324. /**
  3325. * Builds a new matrix whose values are computed by:
  3326. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3327. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3328. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3329. * @param startValue defines the first matrix
  3330. * @param endValue defines the second matrix
  3331. * @param gradient defines the gradient between the two matrices
  3332. * @returns the new matrix
  3333. */
  3334. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3335. /**
  3336. * Update a matrix to values which are computed by:
  3337. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3338. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3339. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3340. * @param startValue defines the first matrix
  3341. * @param endValue defines the second matrix
  3342. * @param gradient defines the gradient between the two matrices
  3343. * @param result defines the target matrix
  3344. */
  3345. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3346. /**
  3347. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3348. * This function works in left handed mode
  3349. * @param eye defines the final position of the entity
  3350. * @param target defines where the entity should look at
  3351. * @param up defines the up vector for the entity
  3352. * @returns the new matrix
  3353. */
  3354. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3355. /**
  3356. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3357. * This function works in left handed mode
  3358. * @param eye defines the final position of the entity
  3359. * @param target defines where the entity should look at
  3360. * @param up defines the up vector for the entity
  3361. * @param result defines the target matrix
  3362. */
  3363. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3364. /**
  3365. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3366. * This function works in right handed mode
  3367. * @param eye defines the final position of the entity
  3368. * @param target defines where the entity should look at
  3369. * @param up defines the up vector for the entity
  3370. * @returns the new matrix
  3371. */
  3372. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3373. /**
  3374. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3375. * This function works in right handed mode
  3376. * @param eye defines the final position of the entity
  3377. * @param target defines where the entity should look at
  3378. * @param up defines the up vector for the entity
  3379. * @param result defines the target matrix
  3380. */
  3381. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3382. /**
  3383. * Create a left-handed orthographic projection matrix
  3384. * @param width defines the viewport width
  3385. * @param height defines the viewport height
  3386. * @param znear defines the near clip plane
  3387. * @param zfar defines the far clip plane
  3388. * @returns a new matrix as a left-handed orthographic projection matrix
  3389. */
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. /**
  3392. * Store a left-handed orthographic projection to a given matrix
  3393. * @param width defines the viewport width
  3394. * @param height defines the viewport height
  3395. * @param znear defines the near clip plane
  3396. * @param zfar defines the far clip plane
  3397. * @param result defines the target matrix
  3398. */
  3399. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3400. /**
  3401. * Create a left-handed orthographic projection matrix
  3402. * @param left defines the viewport left coordinate
  3403. * @param right defines the viewport right coordinate
  3404. * @param bottom defines the viewport bottom coordinate
  3405. * @param top defines the viewport top coordinate
  3406. * @param znear defines the near clip plane
  3407. * @param zfar defines the far clip plane
  3408. * @returns a new matrix as a left-handed orthographic projection matrix
  3409. */
  3410. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3411. /**
  3412. * Stores a left-handed orthographic projection into a given matrix
  3413. * @param left defines the viewport left coordinate
  3414. * @param right defines the viewport right coordinate
  3415. * @param bottom defines the viewport bottom coordinate
  3416. * @param top defines the viewport top coordinate
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. */
  3421. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3422. /**
  3423. * Creates a right-handed orthographic projection matrix
  3424. * @param left defines the viewport left coordinate
  3425. * @param right defines the viewport right coordinate
  3426. * @param bottom defines the viewport bottom coordinate
  3427. * @param top defines the viewport top coordinate
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @returns a new matrix as a right-handed orthographic projection matrix
  3431. */
  3432. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3433. /**
  3434. * Stores a right-handed orthographic projection into a given matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. */
  3443. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3444. /**
  3445. * Creates a left-handed perspective projection matrix
  3446. * @param width defines the viewport width
  3447. * @param height defines the viewport height
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @returns a new matrix as a left-handed perspective projection matrix
  3451. */
  3452. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3453. /**
  3454. * Creates a left-handed perspective projection matrix
  3455. * @param fov defines the horizontal field of view
  3456. * @param aspect defines the aspect ratio
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @returns a new matrix as a left-handed perspective projection matrix
  3460. */
  3461. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3462. /**
  3463. * Stores a left-handed perspective projection into a given matrix
  3464. * @param fov defines the horizontal field of view
  3465. * @param aspect defines the aspect ratio
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @param result defines the target matrix
  3469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3470. */
  3471. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3472. /**
  3473. * Creates a right-handed perspective projection matrix
  3474. * @param fov defines the horizontal field of view
  3475. * @param aspect defines the aspect ratio
  3476. * @param znear defines the near clip plane
  3477. * @param zfar defines the far clip plane
  3478. * @returns a new matrix as a right-handed perspective projection matrix
  3479. */
  3480. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3481. /**
  3482. * Stores a right-handed perspective projection into a given matrix
  3483. * @param fov defines the horizontal field of view
  3484. * @param aspect defines the aspect ratio
  3485. * @param znear defines the near clip plane
  3486. * @param zfar defines the far clip plane
  3487. * @param result defines the target matrix
  3488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3489. */
  3490. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3491. /**
  3492. * Stores a perspective projection for WebVR info a given matrix
  3493. * @param fov defines the field of view
  3494. * @param znear defines the near clip plane
  3495. * @param zfar defines the far clip plane
  3496. * @param result defines the target matrix
  3497. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3498. */
  3499. static PerspectiveFovWebVRToRef(fov: {
  3500. upDegrees: number;
  3501. downDegrees: number;
  3502. leftDegrees: number;
  3503. rightDegrees: number;
  3504. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3505. /**
  3506. * Computes a complete transformation matrix
  3507. * @param viewport defines the viewport to use
  3508. * @param world defines the world matrix
  3509. * @param view defines the view matrix
  3510. * @param projection defines the projection matrix
  3511. * @param zmin defines the near clip plane
  3512. * @param zmax defines the far clip plane
  3513. * @returns the transformation matrix
  3514. */
  3515. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3516. /**
  3517. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3518. * @param matrix defines the matrix to use
  3519. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3520. */
  3521. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3522. /**
  3523. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3524. * @param matrix defines the matrix to use
  3525. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3526. */
  3527. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3528. /**
  3529. * Compute the transpose of a given matrix
  3530. * @param matrix defines the matrix to transpose
  3531. * @returns the new matrix
  3532. */
  3533. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3534. /**
  3535. * Compute the transpose of a matrix and store it in a target matrix
  3536. * @param matrix defines the matrix to transpose
  3537. * @param result defines the target matrix
  3538. */
  3539. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3540. /**
  3541. * Computes a reflection matrix from a plane
  3542. * @param plane defines the reflection plane
  3543. * @returns a new matrix
  3544. */
  3545. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3546. /**
  3547. * Computes a reflection matrix from a plane
  3548. * @param plane defines the reflection plane
  3549. * @param result defines the target matrix
  3550. */
  3551. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3552. /**
  3553. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3554. * @param xaxis defines the value of the 1st axis
  3555. * @param yaxis defines the value of the 2nd axis
  3556. * @param zaxis defines the value of the 3rd axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3560. /**
  3561. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3562. * @param quat defines the quaternion to use
  3563. * @param result defines the target matrix
  3564. */
  3565. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3566. }
  3567. /**
  3568. * Represens a plane by the equation ax + by + cz + d = 0
  3569. */
  3570. export class Plane {
  3571. /**
  3572. * Normal of the plane (a,b,c)
  3573. */
  3574. normal: Vector3;
  3575. /**
  3576. * d component of the plane
  3577. */
  3578. d: number;
  3579. /**
  3580. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3581. * @param a a component of the plane
  3582. * @param b b component of the plane
  3583. * @param c c component of the plane
  3584. * @param d d component of the plane
  3585. */
  3586. constructor(a: number, b: number, c: number, d: number);
  3587. /**
  3588. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3589. */
  3590. asArray(): number[];
  3591. /**
  3592. * @returns a new plane copied from the current Plane.
  3593. */
  3594. clone(): Plane;
  3595. /**
  3596. * @returns the string "Plane".
  3597. */
  3598. getClassName(): string;
  3599. /**
  3600. * @returns the Plane hash code.
  3601. */
  3602. getHashCode(): number;
  3603. /**
  3604. * Normalize the current Plane in place.
  3605. * @returns the updated Plane.
  3606. */
  3607. normalize(): Plane;
  3608. /**
  3609. * Applies a transformation the plane and returns the result
  3610. * @param transformation the transformation matrix to be applied to the plane
  3611. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3612. */
  3613. transform(transformation: DeepImmutable<Matrix>): Plane;
  3614. /**
  3615. * Calcualtte the dot product between the point and the plane normal
  3616. * @param point point to calculate the dot product with
  3617. * @returns the dot product (float) of the point coordinates and the plane normal.
  3618. */
  3619. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3620. /**
  3621. * Updates the current Plane from the plane defined by the three given points.
  3622. * @param point1 one of the points used to contruct the plane
  3623. * @param point2 one of the points used to contruct the plane
  3624. * @param point3 one of the points used to contruct the plane
  3625. * @returns the updated Plane.
  3626. */
  3627. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3628. /**
  3629. * Checks if the plane is facing a given direction
  3630. * @param direction the direction to check if the plane is facing
  3631. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3632. * @returns True is the vector "direction" is the same side than the plane normal.
  3633. */
  3634. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3635. /**
  3636. * Calculates the distance to a point
  3637. * @param point point to calculate distance to
  3638. * @returns the signed distance (float) from the given point to the Plane.
  3639. */
  3640. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3641. /**
  3642. * Creates a plane from an array
  3643. * @param array the array to create a plane from
  3644. * @returns a new Plane from the given array.
  3645. */
  3646. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3647. /**
  3648. * Creates a plane from three points
  3649. * @param point1 point used to create the plane
  3650. * @param point2 point used to create the plane
  3651. * @param point3 point used to create the plane
  3652. * @returns a new Plane defined by the three given points.
  3653. */
  3654. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3655. /**
  3656. * Creates a plane from an origin point and a normal
  3657. * @param origin origin of the plane to be constructed
  3658. * @param normal normal of the plane to be constructed
  3659. * @returns a new Plane the normal vector to this plane at the given origin point.
  3660. * Note : the vector "normal" is updated because normalized.
  3661. */
  3662. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Calculates the distance from a plane and a point
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @param point point to calculate distance to
  3668. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3669. */
  3670. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3671. }
  3672. /**
  3673. * Class used to represent a viewport on screen
  3674. */
  3675. export class Viewport {
  3676. /** viewport left coordinate */
  3677. x: number;
  3678. /** viewport top coordinate */
  3679. y: number;
  3680. /**viewport width */
  3681. width: number;
  3682. /** viewport height */
  3683. height: number;
  3684. /**
  3685. * Creates a Viewport object located at (x, y) and sized (width, height)
  3686. * @param x defines viewport left coordinate
  3687. * @param y defines viewport top coordinate
  3688. * @param width defines the viewport width
  3689. * @param height defines the viewport height
  3690. */
  3691. constructor(
  3692. /** viewport left coordinate */
  3693. x: number,
  3694. /** viewport top coordinate */
  3695. y: number,
  3696. /**viewport width */
  3697. width: number,
  3698. /** viewport height */
  3699. height: number);
  3700. /**
  3701. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3702. * @param renderWidth defines the rendering width
  3703. * @param renderHeight defines the rendering height
  3704. * @returns a new Viewport
  3705. */
  3706. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3707. /**
  3708. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3709. * @param renderWidth defines the rendering width
  3710. * @param renderHeight defines the rendering height
  3711. * @param ref defines the target viewport
  3712. * @returns the current viewport
  3713. */
  3714. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3715. /**
  3716. * Returns a new Viewport copied from the current one
  3717. * @returns a new Viewport
  3718. */
  3719. clone(): Viewport;
  3720. }
  3721. /**
  3722. * Reprasents a camera frustum
  3723. */
  3724. export class Frustum {
  3725. /**
  3726. * Gets the planes representing the frustum
  3727. * @param transform matrix to be applied to the returned planes
  3728. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3729. */
  3730. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3731. /**
  3732. * Gets the near frustum plane transformed by the transform matrix
  3733. * @param transform transformation matrix to be applied to the resulting frustum plane
  3734. * @param frustumPlane the resuling frustum plane
  3735. */
  3736. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3737. /**
  3738. * Gets the far frustum plane transformed by the transform matrix
  3739. * @param transform transformation matrix to be applied to the resulting frustum plane
  3740. * @param frustumPlane the resuling frustum plane
  3741. */
  3742. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3743. /**
  3744. * Gets the left frustum plane transformed by the transform matrix
  3745. * @param transform transformation matrix to be applied to the resulting frustum plane
  3746. * @param frustumPlane the resuling frustum plane
  3747. */
  3748. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3749. /**
  3750. * Gets the right frustum plane transformed by the transform matrix
  3751. * @param transform transformation matrix to be applied to the resulting frustum plane
  3752. * @param frustumPlane the resuling frustum plane
  3753. */
  3754. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3755. /**
  3756. * Gets the top frustum plane transformed by the transform matrix
  3757. * @param transform transformation matrix to be applied to the resulting frustum plane
  3758. * @param frustumPlane the resuling frustum plane
  3759. */
  3760. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3761. /**
  3762. * Gets the bottom frustum plane transformed by the transform matrix
  3763. * @param transform transformation matrix to be applied to the resulting frustum plane
  3764. * @param frustumPlane the resuling frustum plane
  3765. */
  3766. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3767. /**
  3768. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3769. * @param transform transformation matrix to be applied to the resulting frustum planes
  3770. * @param frustumPlanes the resuling frustum planes
  3771. */
  3772. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3773. }
  3774. /** Defines supported spaces */
  3775. export enum Space {
  3776. /** Local (object) space */
  3777. LOCAL = 0,
  3778. /** World space */
  3779. WORLD = 1,
  3780. /** Bone space */
  3781. BONE = 2
  3782. }
  3783. /** Defines the 3 main axes */
  3784. export class Axis {
  3785. /** X axis */
  3786. static X: Vector3;
  3787. /** Y axis */
  3788. static Y: Vector3;
  3789. /** Z axis */
  3790. static Z: Vector3;
  3791. }
  3792. /** Class used to represent a Bezier curve */
  3793. export class BezierCurve {
  3794. /**
  3795. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3796. * @param t defines the time
  3797. * @param x1 defines the left coordinate on X axis
  3798. * @param y1 defines the left coordinate on Y axis
  3799. * @param x2 defines the right coordinate on X axis
  3800. * @param y2 defines the right coordinate on Y axis
  3801. * @returns the interpolated value
  3802. */
  3803. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3804. }
  3805. /**
  3806. * Defines potential orientation for back face culling
  3807. */
  3808. export enum Orientation {
  3809. /**
  3810. * Clockwise
  3811. */
  3812. CW = 0,
  3813. /** Counter clockwise */
  3814. CCW = 1
  3815. }
  3816. /**
  3817. * Defines angle representation
  3818. */
  3819. export class Angle {
  3820. private _radians;
  3821. /**
  3822. * Creates an Angle object of "radians" radians (float).
  3823. * @param radians the angle in radians
  3824. */
  3825. constructor(radians: number);
  3826. /**
  3827. * Get value in degrees
  3828. * @returns the Angle value in degrees (float)
  3829. */
  3830. degrees(): number;
  3831. /**
  3832. * Get value in radians
  3833. * @returns the Angle value in radians (float)
  3834. */
  3835. radians(): number;
  3836. /**
  3837. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3838. * @param a defines first vector
  3839. * @param b defines second vector
  3840. * @returns a new Angle
  3841. */
  3842. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3843. /**
  3844. * Gets a new Angle object from the given float in radians
  3845. * @param radians defines the angle value in radians
  3846. * @returns a new Angle
  3847. */
  3848. static FromRadians(radians: number): Angle;
  3849. /**
  3850. * Gets a new Angle object from the given float in degrees
  3851. * @param degrees defines the angle value in degrees
  3852. * @returns a new Angle
  3853. */
  3854. static FromDegrees(degrees: number): Angle;
  3855. }
  3856. /**
  3857. * This represents an arc in a 2d space.
  3858. */
  3859. export class Arc2 {
  3860. /** Defines the start point of the arc */
  3861. startPoint: Vector2;
  3862. /** Defines the mid point of the arc */
  3863. midPoint: Vector2;
  3864. /** Defines the end point of the arc */
  3865. endPoint: Vector2;
  3866. /**
  3867. * Defines the center point of the arc.
  3868. */
  3869. centerPoint: Vector2;
  3870. /**
  3871. * Defines the radius of the arc.
  3872. */
  3873. radius: number;
  3874. /**
  3875. * Defines the angle of the arc (from mid point to end point).
  3876. */
  3877. angle: Angle;
  3878. /**
  3879. * Defines the start angle of the arc (from start point to middle point).
  3880. */
  3881. startAngle: Angle;
  3882. /**
  3883. * Defines the orientation of the arc (clock wise/counter clock wise).
  3884. */
  3885. orientation: Orientation;
  3886. /**
  3887. * Creates an Arc object from the three given points : start, middle and end.
  3888. * @param startPoint Defines the start point of the arc
  3889. * @param midPoint Defines the midlle point of the arc
  3890. * @param endPoint Defines the end point of the arc
  3891. */
  3892. constructor(
  3893. /** Defines the start point of the arc */
  3894. startPoint: Vector2,
  3895. /** Defines the mid point of the arc */
  3896. midPoint: Vector2,
  3897. /** Defines the end point of the arc */
  3898. endPoint: Vector2);
  3899. }
  3900. /**
  3901. * Represents a 2D path made up of multiple 2D points
  3902. */
  3903. export class Path2 {
  3904. private _points;
  3905. private _length;
  3906. /**
  3907. * If the path start and end point are the same
  3908. */
  3909. closed: boolean;
  3910. /**
  3911. * Creates a Path2 object from the starting 2D coordinates x and y.
  3912. * @param x the starting points x value
  3913. * @param y the starting points y value
  3914. */
  3915. constructor(x: number, y: number);
  3916. /**
  3917. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3918. * @param x the added points x value
  3919. * @param y the added points y value
  3920. * @returns the updated Path2.
  3921. */
  3922. addLineTo(x: number, y: number): Path2;
  3923. /**
  3924. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3925. * @param midX middle point x value
  3926. * @param midY middle point y value
  3927. * @param endX end point x value
  3928. * @param endY end point y value
  3929. * @param numberOfSegments (default: 36)
  3930. * @returns the updated Path2.
  3931. */
  3932. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3933. /**
  3934. * Closes the Path2.
  3935. * @returns the Path2.
  3936. */
  3937. close(): Path2;
  3938. /**
  3939. * Gets the sum of the distance between each sequential point in the path
  3940. * @returns the Path2 total length (float).
  3941. */
  3942. length(): number;
  3943. /**
  3944. * Gets the points which construct the path
  3945. * @returns the Path2 internal array of points.
  3946. */
  3947. getPoints(): Vector2[];
  3948. /**
  3949. * Retreives the point at the distance aways from the starting point
  3950. * @param normalizedLengthPosition the length along the path to retreive the point from
  3951. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3952. */
  3953. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3954. /**
  3955. * Creates a new path starting from an x and y position
  3956. * @param x starting x value
  3957. * @param y starting y value
  3958. * @returns a new Path2 starting at the coordinates (x, y).
  3959. */
  3960. static StartingAt(x: number, y: number): Path2;
  3961. }
  3962. /**
  3963. * Represents a 3D path made up of multiple 3D points
  3964. */
  3965. export class Path3D {
  3966. /**
  3967. * an array of Vector3, the curve axis of the Path3D
  3968. */
  3969. path: Vector3[];
  3970. private _curve;
  3971. private _distances;
  3972. private _tangents;
  3973. private _normals;
  3974. private _binormals;
  3975. private _raw;
  3976. /**
  3977. * new Path3D(path, normal, raw)
  3978. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3979. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3980. * @param path an array of Vector3, the curve axis of the Path3D
  3981. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3982. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3983. */
  3984. constructor(
  3985. /**
  3986. * an array of Vector3, the curve axis of the Path3D
  3987. */
  3988. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3989. /**
  3990. * Returns the Path3D array of successive Vector3 designing its curve.
  3991. * @returns the Path3D array of successive Vector3 designing its curve.
  3992. */
  3993. getCurve(): Vector3[];
  3994. /**
  3995. * Returns an array populated with tangent vectors on each Path3D curve point.
  3996. * @returns an array populated with tangent vectors on each Path3D curve point.
  3997. */
  3998. getTangents(): Vector3[];
  3999. /**
  4000. * Returns an array populated with normal vectors on each Path3D curve point.
  4001. * @returns an array populated with normal vectors on each Path3D curve point.
  4002. */
  4003. getNormals(): Vector3[];
  4004. /**
  4005. * Returns an array populated with binormal vectors on each Path3D curve point.
  4006. * @returns an array populated with binormal vectors on each Path3D curve point.
  4007. */
  4008. getBinormals(): Vector3[];
  4009. /**
  4010. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4012. */
  4013. getDistances(): number[];
  4014. /**
  4015. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4016. * @param path path which all values are copied into the curves points
  4017. * @param firstNormal which should be projected onto the curve
  4018. * @returns the same object updated.
  4019. */
  4020. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4021. private _compute;
  4022. private _getFirstNonNullVector;
  4023. private _getLastNonNullVector;
  4024. private _normalVector;
  4025. }
  4026. /**
  4027. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4028. * A Curve3 is designed from a series of successive Vector3.
  4029. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4030. */
  4031. export class Curve3 {
  4032. private _points;
  4033. private _length;
  4034. /**
  4035. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4036. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4037. * @param v1 (Vector3) the control point
  4038. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4039. * @param nbPoints (integer) the wanted number of points in the curve
  4040. * @returns the created Curve3
  4041. */
  4042. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4043. /**
  4044. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4045. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4046. * @param v1 (Vector3) the first control point
  4047. * @param v2 (Vector3) the second control point
  4048. * @param v3 (Vector3) the end point of the Cubic Bezier
  4049. * @param nbPoints (integer) the wanted number of points in the curve
  4050. * @returns the created Curve3
  4051. */
  4052. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4053. /**
  4054. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4055. * @param p1 (Vector3) the origin point of the Hermite Spline
  4056. * @param t1 (Vector3) the tangent vector at the origin point
  4057. * @param p2 (Vector3) the end point of the Hermite Spline
  4058. * @param t2 (Vector3) the tangent vector at the end point
  4059. * @param nbPoints (integer) the wanted number of points in the curve
  4060. * @returns the created Curve3
  4061. */
  4062. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4063. /**
  4064. * Returns a Curve3 object along a CatmullRom Spline curve :
  4065. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4066. * @param nbPoints (integer) the wanted number of points between each curve control points
  4067. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4068. * @returns the created Curve3
  4069. */
  4070. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4071. /**
  4072. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4073. * A Curve3 is designed from a series of successive Vector3.
  4074. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4075. * @param points points which make up the curve
  4076. */
  4077. constructor(points: Vector3[]);
  4078. /**
  4079. * @returns the Curve3 stored array of successive Vector3
  4080. */
  4081. getPoints(): Vector3[];
  4082. /**
  4083. * @returns the computed length (float) of the curve.
  4084. */
  4085. length(): number;
  4086. /**
  4087. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4088. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4089. * curveA and curveB keep unchanged.
  4090. * @param curve the curve to continue from this curve
  4091. * @returns the newly constructed curve
  4092. */
  4093. continue(curve: DeepImmutable<Curve3>): Curve3;
  4094. private _computeLength;
  4095. }
  4096. /**
  4097. * Contains position and normal vectors for a vertex
  4098. */
  4099. export class PositionNormalVertex {
  4100. /** the position of the vertex (defaut: 0,0,0) */
  4101. position: Vector3;
  4102. /** the normal of the vertex (defaut: 0,1,0) */
  4103. normal: Vector3;
  4104. /**
  4105. * Creates a PositionNormalVertex
  4106. * @param position the position of the vertex (defaut: 0,0,0)
  4107. * @param normal the normal of the vertex (defaut: 0,1,0)
  4108. */
  4109. constructor(
  4110. /** the position of the vertex (defaut: 0,0,0) */
  4111. position?: Vector3,
  4112. /** the normal of the vertex (defaut: 0,1,0) */
  4113. normal?: Vector3);
  4114. /**
  4115. * Clones the PositionNormalVertex
  4116. * @returns the cloned PositionNormalVertex
  4117. */
  4118. clone(): PositionNormalVertex;
  4119. }
  4120. /**
  4121. * Contains position, normal and uv vectors for a vertex
  4122. */
  4123. export class PositionNormalTextureVertex {
  4124. /** the position of the vertex (defaut: 0,0,0) */
  4125. position: Vector3;
  4126. /** the normal of the vertex (defaut: 0,1,0) */
  4127. normal: Vector3;
  4128. /** the uv of the vertex (default: 0,0) */
  4129. uv: Vector2;
  4130. /**
  4131. * Creates a PositionNormalTextureVertex
  4132. * @param position the position of the vertex (defaut: 0,0,0)
  4133. * @param normal the normal of the vertex (defaut: 0,1,0)
  4134. * @param uv the uv of the vertex (default: 0,0)
  4135. */
  4136. constructor(
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position?: Vector3,
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal?: Vector3,
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv?: Vector2);
  4143. /**
  4144. * Clones the PositionNormalTextureVertex
  4145. * @returns the cloned PositionNormalTextureVertex
  4146. */
  4147. clone(): PositionNormalTextureVertex;
  4148. }
  4149. /**
  4150. * @hidden
  4151. */
  4152. export class Tmp {
  4153. static Color3: Color3[];
  4154. static Color4: Color4[];
  4155. static Vector2: Vector2[];
  4156. static Vector3: Vector3[];
  4157. static Vector4: Vector4[];
  4158. static Quaternion: Quaternion[];
  4159. static Matrix: Matrix[];
  4160. }
  4161. }
  4162. declare module "babylonjs/Offline/IOfflineProvider" {
  4163. /**
  4164. * Class used to enable access to offline support
  4165. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4166. */
  4167. export interface IOfflineProvider {
  4168. /**
  4169. * Gets a boolean indicating if scene must be saved in the database
  4170. */
  4171. enableSceneOffline: boolean;
  4172. /**
  4173. * Gets a boolean indicating if textures must be saved in the database
  4174. */
  4175. enableTexturesOffline: boolean;
  4176. /**
  4177. * Open the offline support and make it available
  4178. * @param successCallback defines the callback to call on success
  4179. * @param errorCallback defines the callback to call on error
  4180. */
  4181. open(successCallback: () => void, errorCallback: () => void): void;
  4182. /**
  4183. * Loads an image from the offline support
  4184. * @param url defines the url to load from
  4185. * @param image defines the target DOM image
  4186. */
  4187. loadImage(url: string, image: HTMLImageElement): void;
  4188. /**
  4189. * Loads a file from offline support
  4190. * @param url defines the URL to load from
  4191. * @param sceneLoaded defines a callback to call on success
  4192. * @param progressCallBack defines a callback to call when progress changed
  4193. * @param errorCallback defines a callback to call on error
  4194. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4195. */
  4196. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4197. }
  4198. }
  4199. declare module "babylonjs/Misc/observable" {
  4200. import { Nullable } from "babylonjs/types";
  4201. /**
  4202. * A class serves as a medium between the observable and its observers
  4203. */
  4204. export class EventState {
  4205. /**
  4206. * Create a new EventState
  4207. * @param mask defines the mask associated with this state
  4208. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4209. * @param target defines the original target of the state
  4210. * @param currentTarget defines the current target of the state
  4211. */
  4212. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4213. /**
  4214. * Initialize the current event state
  4215. * @param mask defines the mask associated with this state
  4216. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4217. * @param target defines the original target of the state
  4218. * @param currentTarget defines the current target of the state
  4219. * @returns the current event state
  4220. */
  4221. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4222. /**
  4223. * An Observer can set this property to true to prevent subsequent observers of being notified
  4224. */
  4225. skipNextObservers: boolean;
  4226. /**
  4227. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4228. */
  4229. mask: number;
  4230. /**
  4231. * The object that originally notified the event
  4232. */
  4233. target?: any;
  4234. /**
  4235. * The current object in the bubbling phase
  4236. */
  4237. currentTarget?: any;
  4238. /**
  4239. * This will be populated with the return value of the last function that was executed.
  4240. * If it is the first function in the callback chain it will be the event data.
  4241. */
  4242. lastReturnValue?: any;
  4243. }
  4244. /**
  4245. * Represent an Observer registered to a given Observable object.
  4246. */
  4247. export class Observer<T> {
  4248. /**
  4249. * Defines the callback to call when the observer is notified
  4250. */
  4251. callback: (eventData: T, eventState: EventState) => void;
  4252. /**
  4253. * Defines the mask of the observer (used to filter notifications)
  4254. */
  4255. mask: number;
  4256. /**
  4257. * Defines the current scope used to restore the JS context
  4258. */
  4259. scope: any;
  4260. /** @hidden */
  4261. _willBeUnregistered: boolean;
  4262. /**
  4263. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4264. */
  4265. unregisterOnNextCall: boolean;
  4266. /**
  4267. * Creates a new observer
  4268. * @param callback defines the callback to call when the observer is notified
  4269. * @param mask defines the mask of the observer (used to filter notifications)
  4270. * @param scope defines the current scope used to restore the JS context
  4271. */
  4272. constructor(
  4273. /**
  4274. * Defines the callback to call when the observer is notified
  4275. */
  4276. callback: (eventData: T, eventState: EventState) => void,
  4277. /**
  4278. * Defines the mask of the observer (used to filter notifications)
  4279. */
  4280. mask: number,
  4281. /**
  4282. * Defines the current scope used to restore the JS context
  4283. */
  4284. scope?: any);
  4285. }
  4286. /**
  4287. * Represent a list of observers registered to multiple Observables object.
  4288. */
  4289. export class MultiObserver<T> {
  4290. private _observers;
  4291. private _observables;
  4292. /**
  4293. * Release associated resources
  4294. */
  4295. dispose(): void;
  4296. /**
  4297. * Raise a callback when one of the observable will notify
  4298. * @param observables defines a list of observables to watch
  4299. * @param callback defines the callback to call on notification
  4300. * @param mask defines the mask used to filter notifications
  4301. * @param scope defines the current scope used to restore the JS context
  4302. * @returns the new MultiObserver
  4303. */
  4304. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4305. }
  4306. /**
  4307. * The Observable class is a simple implementation of the Observable pattern.
  4308. *
  4309. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4310. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4311. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4312. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4313. */
  4314. export class Observable<T> {
  4315. private _observers;
  4316. private _eventState;
  4317. private _onObserverAdded;
  4318. /**
  4319. * Creates a new observable
  4320. * @param onObserverAdded defines a callback to call when a new observer is added
  4321. */
  4322. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4323. /**
  4324. * Create a new Observer with the specified callback
  4325. * @param callback the callback that will be executed for that Observer
  4326. * @param mask the mask used to filter observers
  4327. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4328. * @param scope optional scope for the callback to be called from
  4329. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4330. * @returns the new observer created for the callback
  4331. */
  4332. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4333. /**
  4334. * Create a new Observer with the specified callback and unregisters after the next notification
  4335. * @param callback the callback that will be executed for that Observer
  4336. * @returns the new observer created for the callback
  4337. */
  4338. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4339. /**
  4340. * Remove an Observer from the Observable object
  4341. * @param observer the instance of the Observer to remove
  4342. * @returns false if it doesn't belong to this Observable
  4343. */
  4344. remove(observer: Nullable<Observer<T>>): boolean;
  4345. /**
  4346. * Remove a callback from the Observable object
  4347. * @param callback the callback to remove
  4348. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4349. * @returns false if it doesn't belong to this Observable
  4350. */
  4351. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4352. private _deferUnregister;
  4353. private _remove;
  4354. /**
  4355. * Notify all Observers by calling their respective callback with the given data
  4356. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4357. * @param eventData defines the data to send to all observers
  4358. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4359. * @param target defines the original target of the state
  4360. * @param currentTarget defines the current target of the state
  4361. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4362. */
  4363. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4364. /**
  4365. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4366. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4367. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4368. * and it is crucial that all callbacks will be executed.
  4369. * The order of the callbacks is kept, callbacks are not executed parallel.
  4370. *
  4371. * @param eventData The data to be sent to each callback
  4372. * @param mask is used to filter observers defaults to -1
  4373. * @param target defines the callback target (see EventState)
  4374. * @param currentTarget defines he current object in the bubbling phase
  4375. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4376. */
  4377. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4378. /**
  4379. * Notify a specific observer
  4380. * @param observer defines the observer to notify
  4381. * @param eventData defines the data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. */
  4384. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4385. /**
  4386. * Gets a boolean indicating if the observable has at least one observer
  4387. * @returns true is the Observable has at least one Observer registered
  4388. */
  4389. hasObservers(): boolean;
  4390. /**
  4391. * Clear the list of observers
  4392. */
  4393. clear(): void;
  4394. /**
  4395. * Clone the current observable
  4396. * @returns a new observable
  4397. */
  4398. clone(): Observable<T>;
  4399. /**
  4400. * Does this observable handles observer registered with a given mask
  4401. * @param mask defines the mask to be tested
  4402. * @return whether or not one observer registered with the given mask is handeled
  4403. **/
  4404. hasSpecificMask(mask?: number): boolean;
  4405. }
  4406. }
  4407. declare module "babylonjs/Misc/filesInputStore" {
  4408. /**
  4409. * Class used to help managing file picking and drag'n'drop
  4410. * File Storage
  4411. */
  4412. export class FilesInputStore {
  4413. /**
  4414. * List of files ready to be loaded
  4415. */
  4416. static FilesToLoad: {
  4417. [key: string]: File;
  4418. };
  4419. }
  4420. }
  4421. declare module "babylonjs/Engines/constants" {
  4422. /** Defines the cross module used constants to avoid circular dependncies */
  4423. export class Constants {
  4424. /** Defines that alpha blending is disabled */
  4425. static readonly ALPHA_DISABLE: number;
  4426. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4427. static readonly ALPHA_ADD: number;
  4428. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4429. static readonly ALPHA_COMBINE: number;
  4430. /** Defines that alpha blending to DEST - SRC * DEST */
  4431. static readonly ALPHA_SUBTRACT: number;
  4432. /** Defines that alpha blending to SRC * DEST */
  4433. static readonly ALPHA_MULTIPLY: number;
  4434. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4435. static readonly ALPHA_MAXIMIZED: number;
  4436. /** Defines that alpha blending to SRC + DEST */
  4437. static readonly ALPHA_ONEONE: number;
  4438. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_PREMULTIPLIED: number;
  4440. /**
  4441. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4442. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4443. */
  4444. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4445. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4446. static readonly ALPHA_INTERPOLATE: number;
  4447. /**
  4448. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4449. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4450. */
  4451. static readonly ALPHA_SCREENMODE: number;
  4452. /** Defines that the ressource is not delayed*/
  4453. static readonly DELAYLOADSTATE_NONE: number;
  4454. /** Defines that the ressource was successfully delay loaded */
  4455. static readonly DELAYLOADSTATE_LOADED: number;
  4456. /** Defines that the ressource is currently delay loading */
  4457. static readonly DELAYLOADSTATE_LOADING: number;
  4458. /** Defines that the ressource is delayed and has not started loading */
  4459. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4461. static readonly NEVER: number;
  4462. /** 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 */
  4463. static readonly ALWAYS: number;
  4464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4465. static readonly LESS: number;
  4466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4467. static readonly EQUAL: number;
  4468. /** 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 */
  4469. static readonly LEQUAL: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4471. static readonly GREATER: number;
  4472. /** 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 */
  4473. static readonly GEQUAL: number;
  4474. /** 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 */
  4475. static readonly NOTEQUAL: number;
  4476. /** Passed to stencilOperation to specify that stencil value must be kept */
  4477. static readonly KEEP: number;
  4478. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4479. static readonly REPLACE: number;
  4480. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4481. static readonly INCR: number;
  4482. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4483. static readonly DECR: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4485. static readonly INVERT: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4487. static readonly INCR_WRAP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4489. static readonly DECR_WRAP: number;
  4490. /** Texture is not repeating outside of 0..1 UVs */
  4491. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4492. /** Texture is repeating outside of 0..1 UVs */
  4493. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4494. /** Texture is repeating and mirrored */
  4495. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4496. /** ALPHA */
  4497. static readonly TEXTUREFORMAT_ALPHA: number;
  4498. /** LUMINANCE */
  4499. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4500. /** LUMINANCE_ALPHA */
  4501. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4502. /** RGB */
  4503. static readonly TEXTUREFORMAT_RGB: number;
  4504. /** RGBA */
  4505. static readonly TEXTUREFORMAT_RGBA: number;
  4506. /** RED */
  4507. static readonly TEXTUREFORMAT_RED: number;
  4508. /** RED (2nd reference) */
  4509. static readonly TEXTUREFORMAT_R: number;
  4510. /** RG */
  4511. static readonly TEXTUREFORMAT_RG: number;
  4512. /** RED_INTEGER */
  4513. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4514. /** RED_INTEGER (2nd reference) */
  4515. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4516. /** RG_INTEGER */
  4517. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4518. /** RGB_INTEGER */
  4519. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4520. /** RGBA_INTEGER */
  4521. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4522. /** UNSIGNED_BYTE */
  4523. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4524. /** UNSIGNED_BYTE (2nd reference) */
  4525. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4526. /** FLOAT */
  4527. static readonly TEXTURETYPE_FLOAT: number;
  4528. /** HALF_FLOAT */
  4529. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4530. /** BYTE */
  4531. static readonly TEXTURETYPE_BYTE: number;
  4532. /** SHORT */
  4533. static readonly TEXTURETYPE_SHORT: number;
  4534. /** UNSIGNED_SHORT */
  4535. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4536. /** INT */
  4537. static readonly TEXTURETYPE_INT: number;
  4538. /** UNSIGNED_INT */
  4539. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4540. /** UNSIGNED_SHORT_4_4_4_4 */
  4541. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4542. /** UNSIGNED_SHORT_5_5_5_1 */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4544. /** UNSIGNED_SHORT_5_6_5 */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4546. /** UNSIGNED_INT_2_10_10_10_REV */
  4547. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4548. /** UNSIGNED_INT_24_8 */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4550. /** UNSIGNED_INT_10F_11F_11F_REV */
  4551. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4552. /** UNSIGNED_INT_5_9_9_9_REV */
  4553. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4554. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4555. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4556. /** nearest is mag = nearest and min = nearest and mip = linear */
  4557. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4558. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4559. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4560. /** Trilinear is mag = linear and min = linear and mip = linear */
  4561. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4562. /** nearest is mag = nearest and min = nearest and mip = linear */
  4563. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4565. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4566. /** Trilinear is mag = linear and min = linear and mip = linear */
  4567. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4568. /** mag = nearest and min = nearest and mip = nearest */
  4569. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4570. /** mag = nearest and min = linear and mip = nearest */
  4571. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4572. /** mag = nearest and min = linear and mip = linear */
  4573. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4574. /** mag = nearest and min = linear and mip = none */
  4575. static readonly TEXTURE_NEAREST_LINEAR: number;
  4576. /** mag = nearest and min = nearest and mip = none */
  4577. static readonly TEXTURE_NEAREST_NEAREST: number;
  4578. /** mag = linear and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4580. /** mag = linear and min = nearest and mip = linear */
  4581. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4582. /** mag = linear and min = linear and mip = none */
  4583. static readonly TEXTURE_LINEAR_LINEAR: number;
  4584. /** mag = linear and min = nearest and mip = none */
  4585. static readonly TEXTURE_LINEAR_NEAREST: number;
  4586. /** Explicit coordinates mode */
  4587. static readonly TEXTURE_EXPLICIT_MODE: number;
  4588. /** Spherical coordinates mode */
  4589. static readonly TEXTURE_SPHERICAL_MODE: number;
  4590. /** Planar coordinates mode */
  4591. static readonly TEXTURE_PLANAR_MODE: number;
  4592. /** Cubic coordinates mode */
  4593. static readonly TEXTURE_CUBIC_MODE: number;
  4594. /** Projection coordinates mode */
  4595. static readonly TEXTURE_PROJECTION_MODE: number;
  4596. /** Skybox coordinates mode */
  4597. static readonly TEXTURE_SKYBOX_MODE: number;
  4598. /** Inverse Cubic coordinates mode */
  4599. static readonly TEXTURE_INVCUBIC_MODE: number;
  4600. /** Equirectangular coordinates mode */
  4601. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4602. /** Equirectangular Fixed coordinates mode */
  4603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4604. /** Equirectangular Fixed Mirrored coordinates mode */
  4605. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4606. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4607. static readonly SCALEMODE_FLOOR: number;
  4608. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4609. static readonly SCALEMODE_NEAREST: number;
  4610. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4611. static readonly SCALEMODE_CEILING: number;
  4612. /**
  4613. * The dirty texture flag value
  4614. */
  4615. static readonly MATERIAL_TextureDirtyFlag: number;
  4616. /**
  4617. * The dirty light flag value
  4618. */
  4619. static readonly MATERIAL_LightDirtyFlag: number;
  4620. /**
  4621. * The dirty fresnel flag value
  4622. */
  4623. static readonly MATERIAL_FresnelDirtyFlag: number;
  4624. /**
  4625. * The dirty attribute flag value
  4626. */
  4627. static readonly MATERIAL_AttributesDirtyFlag: number;
  4628. /**
  4629. * The dirty misc flag value
  4630. */
  4631. static readonly MATERIAL_MiscDirtyFlag: number;
  4632. /**
  4633. * The all dirty flag value
  4634. */
  4635. static readonly MATERIAL_AllDirtyFlag: number;
  4636. /**
  4637. * Returns the triangle fill mode
  4638. */
  4639. static readonly MATERIAL_TriangleFillMode: number;
  4640. /**
  4641. * Returns the wireframe mode
  4642. */
  4643. static readonly MATERIAL_WireFrameFillMode: number;
  4644. /**
  4645. * Returns the point fill mode
  4646. */
  4647. static readonly MATERIAL_PointFillMode: number;
  4648. /**
  4649. * Returns the point list draw mode
  4650. */
  4651. static readonly MATERIAL_PointListDrawMode: number;
  4652. /**
  4653. * Returns the line list draw mode
  4654. */
  4655. static readonly MATERIAL_LineListDrawMode: number;
  4656. /**
  4657. * Returns the line loop draw mode
  4658. */
  4659. static readonly MATERIAL_LineLoopDrawMode: number;
  4660. /**
  4661. * Returns the line strip draw mode
  4662. */
  4663. static readonly MATERIAL_LineStripDrawMode: number;
  4664. /**
  4665. * Returns the triangle strip draw mode
  4666. */
  4667. static readonly MATERIAL_TriangleStripDrawMode: number;
  4668. /**
  4669. * Returns the triangle fan draw mode
  4670. */
  4671. static readonly MATERIAL_TriangleFanDrawMode: number;
  4672. /**
  4673. * Stores the clock-wise side orientation
  4674. */
  4675. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4676. /**
  4677. * Stores the counter clock-wise side orientation
  4678. */
  4679. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4680. /**
  4681. * Nothing
  4682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4683. */
  4684. static readonly ACTION_NothingTrigger: number;
  4685. /**
  4686. * On pick
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_OnPickTrigger: number;
  4690. /**
  4691. * On left pick
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_OnLeftPickTrigger: number;
  4695. /**
  4696. * On right pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnRightPickTrigger: number;
  4700. /**
  4701. * On center pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnCenterPickTrigger: number;
  4705. /**
  4706. * On pick down
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnPickDownTrigger: number;
  4710. /**
  4711. * On double pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnDoublePickTrigger: number;
  4715. /**
  4716. * On pick up
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickUpTrigger: number;
  4720. /**
  4721. * On pick out.
  4722. * This trigger will only be raised if you also declared a OnPickDown
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnPickOutTrigger: number;
  4726. /**
  4727. * On long press
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnLongPressTrigger: number;
  4731. /**
  4732. * On pointer over
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPointerOverTrigger: number;
  4736. /**
  4737. * On pointer out
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPointerOutTrigger: number;
  4741. /**
  4742. * On every frame
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnEveryFrameTrigger: number;
  4746. /**
  4747. * On intersection enter
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4751. /**
  4752. * On intersection exit
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnIntersectionExitTrigger: number;
  4756. /**
  4757. * On key down
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnKeyDownTrigger: number;
  4761. /**
  4762. * On key up
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnKeyUpTrigger: number;
  4766. /**
  4767. * Billboard mode will only apply to Y axis
  4768. */
  4769. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4770. /**
  4771. * Billboard mode will apply to all axes
  4772. */
  4773. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4774. /**
  4775. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4776. */
  4777. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4778. /**
  4779. * Gets or sets base Assets URL
  4780. */
  4781. static readonly PARTICLES_BaseAssetsUrl: string;
  4782. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4783. * Test order :
  4784. * Is the bounding sphere outside the frustum ?
  4785. * If not, are the bounding box vertices outside the frustum ?
  4786. * It not, then the cullable object is in the frustum.
  4787. */
  4788. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4789. /** Culling strategy : Bounding Sphere Only.
  4790. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4791. * It's also less accurate than the standard because some not visible objects can still be selected.
  4792. * Test : is the bounding sphere outside the frustum ?
  4793. * If not, then the cullable object is in the frustum.
  4794. */
  4795. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4796. /** Culling strategy : Optimistic Inclusion.
  4797. * This in an inclusion test first, then the standard exclusion test.
  4798. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4799. * 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.
  4800. * Anyway, it's as accurate as the standard strategy.
  4801. * Test :
  4802. * Is the cullable object bounding sphere center in the frustum ?
  4803. * If not, apply the default culling strategy.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4806. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4807. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4808. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4809. * 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.
  4810. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4816. /**
  4817. * No logging while loading
  4818. */
  4819. static readonly SCENELOADER_NO_LOGGING: number;
  4820. /**
  4821. * Minimal logging while loading
  4822. */
  4823. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4824. /**
  4825. * Summary logging while loading
  4826. */
  4827. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4828. /**
  4829. * Detailled logging while loading
  4830. */
  4831. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4832. }
  4833. }
  4834. declare module "babylonjs/Misc/domManagement" {
  4835. /**
  4836. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4837. * Babylon.js
  4838. */
  4839. export class DomManagement {
  4840. /**
  4841. * Checks if the window object exists
  4842. * @returns true if the window object exists
  4843. */
  4844. static IsWindowObjectExist(): boolean;
  4845. /**
  4846. * Extracts text content from a DOM element hierarchy
  4847. * @param element defines the root element
  4848. * @returns a string
  4849. */
  4850. static GetDOMTextContent(element: HTMLElement): string;
  4851. }
  4852. }
  4853. declare module "babylonjs/Misc/logger" {
  4854. /**
  4855. * Logger used througouht the application to allow configuration of
  4856. * the log level required for the messages.
  4857. */
  4858. export class Logger {
  4859. /**
  4860. * No log
  4861. */
  4862. static readonly NoneLogLevel: number;
  4863. /**
  4864. * Only message logs
  4865. */
  4866. static readonly MessageLogLevel: number;
  4867. /**
  4868. * Only warning logs
  4869. */
  4870. static readonly WarningLogLevel: number;
  4871. /**
  4872. * Only error logs
  4873. */
  4874. static readonly ErrorLogLevel: number;
  4875. /**
  4876. * All logs
  4877. */
  4878. static readonly AllLogLevel: number;
  4879. private static _LogCache;
  4880. /**
  4881. * Gets a value indicating the number of loading errors
  4882. * @ignorenaming
  4883. */
  4884. static errorsCount: number;
  4885. /**
  4886. * Callback called when a new log is added
  4887. */
  4888. static OnNewCacheEntry: (entry: string) => void;
  4889. private static _AddLogEntry;
  4890. private static _FormatMessage;
  4891. private static _LogDisabled;
  4892. private static _LogEnabled;
  4893. private static _WarnDisabled;
  4894. private static _WarnEnabled;
  4895. private static _ErrorDisabled;
  4896. private static _ErrorEnabled;
  4897. /**
  4898. * Log a message to the console
  4899. */
  4900. static Log: (message: string) => void;
  4901. /**
  4902. * Write a warning message to the console
  4903. */
  4904. static Warn: (message: string) => void;
  4905. /**
  4906. * Write an error message to the console
  4907. */
  4908. static Error: (message: string) => void;
  4909. /**
  4910. * Gets current log cache (list of logs)
  4911. */
  4912. static readonly LogCache: string;
  4913. /**
  4914. * Clears the log cache
  4915. */
  4916. static ClearLogCache(): void;
  4917. /**
  4918. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4919. */
  4920. static LogLevels: number;
  4921. }
  4922. }
  4923. declare module "babylonjs/Misc/typeStore" {
  4924. /** @hidden */
  4925. export class _TypeStore {
  4926. /** @hidden */
  4927. static RegisteredTypes: {
  4928. [key: string]: Object;
  4929. };
  4930. /** @hidden */
  4931. static GetClass(fqdn: string): any;
  4932. }
  4933. }
  4934. declare module "babylonjs/Misc/deepCopier" {
  4935. /**
  4936. * Class containing a set of static utilities functions for deep copy.
  4937. */
  4938. export class DeepCopier {
  4939. /**
  4940. * Tries to copy an object by duplicating every property
  4941. * @param source defines the source object
  4942. * @param destination defines the target object
  4943. * @param doNotCopyList defines a list of properties to avoid
  4944. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4945. */
  4946. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4947. }
  4948. }
  4949. declare module "babylonjs/Misc/precisionDate" {
  4950. /**
  4951. * Class containing a set of static utilities functions for precision date
  4952. */
  4953. export class PrecisionDate {
  4954. /**
  4955. * Gets either window.performance.now() if supported or Date.now() else
  4956. */
  4957. static readonly Now: number;
  4958. }
  4959. }
  4960. declare module "babylonjs/Misc/devTools" {
  4961. /** @hidden */
  4962. export class _DevTools {
  4963. static WarnImport(name: string): string;
  4964. }
  4965. }
  4966. declare module "babylonjs/Misc/andOrNotEvaluator" {
  4967. /**
  4968. * Class used to evalaute queries containing `and` and `or` operators
  4969. */
  4970. export class AndOrNotEvaluator {
  4971. /**
  4972. * Evaluate a query
  4973. * @param query defines the query to evaluate
  4974. * @param evaluateCallback defines the callback used to filter result
  4975. * @returns true if the query matches
  4976. */
  4977. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4978. private static _HandleParenthesisContent;
  4979. private static _SimplifyNegation;
  4980. }
  4981. }
  4982. declare module "babylonjs/Misc/tags" {
  4983. /**
  4984. * Class used to store custom tags
  4985. */
  4986. export class Tags {
  4987. /**
  4988. * Adds support for tags on the given object
  4989. * @param obj defines the object to use
  4990. */
  4991. static EnableFor(obj: any): void;
  4992. /**
  4993. * Removes tags support
  4994. * @param obj defines the object to use
  4995. */
  4996. static DisableFor(obj: any): void;
  4997. /**
  4998. * Gets a boolean indicating if the given object has tags
  4999. * @param obj defines the object to use
  5000. * @returns a boolean
  5001. */
  5002. static HasTags(obj: any): boolean;
  5003. /**
  5004. * Gets the tags available on a given object
  5005. * @param obj defines the object to use
  5006. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5007. * @returns the tags
  5008. */
  5009. static GetTags(obj: any, asString?: boolean): any;
  5010. /**
  5011. * Adds tags to an object
  5012. * @param obj defines the object to use
  5013. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5014. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5015. */
  5016. static AddTagsTo(obj: any, tagsString: string): void;
  5017. /**
  5018. * @hidden
  5019. */
  5020. static _AddTagTo(obj: any, tag: string): void;
  5021. /**
  5022. * Removes specific tags from a specific object
  5023. * @param obj defines the object to use
  5024. * @param tagsString defines the tags to remove
  5025. */
  5026. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5027. /**
  5028. * @hidden
  5029. */
  5030. static _RemoveTagFrom(obj: any, tag: string): void;
  5031. /**
  5032. * Defines if tags hosted on an object match a given query
  5033. * @param obj defines the object to use
  5034. * @param tagsQuery defines the tag query
  5035. * @returns a boolean
  5036. */
  5037. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5038. }
  5039. }
  5040. declare module "babylonjs/Materials/materialDefines" {
  5041. /**
  5042. * Manages the defines for the Material
  5043. */
  5044. export class MaterialDefines {
  5045. private _keys;
  5046. private _isDirty;
  5047. /** @hidden */
  5048. _renderId: number;
  5049. /** @hidden */
  5050. _areLightsDirty: boolean;
  5051. /** @hidden */
  5052. _areAttributesDirty: boolean;
  5053. /** @hidden */
  5054. _areTexturesDirty: boolean;
  5055. /** @hidden */
  5056. _areFresnelDirty: boolean;
  5057. /** @hidden */
  5058. _areMiscDirty: boolean;
  5059. /** @hidden */
  5060. _areImageProcessingDirty: boolean;
  5061. /** @hidden */
  5062. _normals: boolean;
  5063. /** @hidden */
  5064. _uvs: boolean;
  5065. /** @hidden */
  5066. _needNormals: boolean;
  5067. /** @hidden */
  5068. _needUVs: boolean;
  5069. /**
  5070. * Specifies if the material needs to be re-calculated
  5071. */
  5072. readonly isDirty: boolean;
  5073. /**
  5074. * Marks the material to indicate that it has been re-calculated
  5075. */
  5076. markAsProcessed(): void;
  5077. /**
  5078. * Marks the material to indicate that it needs to be re-calculated
  5079. */
  5080. markAsUnprocessed(): void;
  5081. /**
  5082. * Marks the material to indicate all of its defines need to be re-calculated
  5083. */
  5084. markAllAsDirty(): void;
  5085. /**
  5086. * Marks the material to indicate that image processing needs to be re-calculated
  5087. */
  5088. markAsImageProcessingDirty(): void;
  5089. /**
  5090. * Marks the material to indicate the lights need to be re-calculated
  5091. */
  5092. markAsLightDirty(): void;
  5093. /**
  5094. * Marks the attribute state as changed
  5095. */
  5096. markAsAttributesDirty(): void;
  5097. /**
  5098. * Marks the texture state as changed
  5099. */
  5100. markAsTexturesDirty(): void;
  5101. /**
  5102. * Marks the fresnel state as changed
  5103. */
  5104. markAsFresnelDirty(): void;
  5105. /**
  5106. * Marks the misc state as changed
  5107. */
  5108. markAsMiscDirty(): void;
  5109. /**
  5110. * Rebuilds the material defines
  5111. */
  5112. rebuild(): void;
  5113. /**
  5114. * Specifies if two material defines are equal
  5115. * @param other - A material define instance to compare to
  5116. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5117. */
  5118. isEqual(other: MaterialDefines): boolean;
  5119. /**
  5120. * Clones this instance's defines to another instance
  5121. * @param other - material defines to clone values to
  5122. */
  5123. cloneTo(other: MaterialDefines): void;
  5124. /**
  5125. * Resets the material define values
  5126. */
  5127. reset(): void;
  5128. /**
  5129. * Converts the material define values to a string
  5130. * @returns - String of material define information
  5131. */
  5132. toString(): string;
  5133. }
  5134. }
  5135. declare module "babylonjs/Misc/performanceMonitor" {
  5136. /**
  5137. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5138. */
  5139. export class PerformanceMonitor {
  5140. private _enabled;
  5141. private _rollingFrameTime;
  5142. private _lastFrameTimeMs;
  5143. /**
  5144. * constructor
  5145. * @param frameSampleSize The number of samples required to saturate the sliding window
  5146. */
  5147. constructor(frameSampleSize?: number);
  5148. /**
  5149. * Samples current frame
  5150. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5151. */
  5152. sampleFrame(timeMs?: number): void;
  5153. /**
  5154. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5155. */
  5156. readonly averageFrameTime: number;
  5157. /**
  5158. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5159. */
  5160. readonly averageFrameTimeVariance: number;
  5161. /**
  5162. * Returns the frame time of the most recent frame
  5163. */
  5164. readonly instantaneousFrameTime: number;
  5165. /**
  5166. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5167. */
  5168. readonly averageFPS: number;
  5169. /**
  5170. * Returns the average framerate in frames per second using the most recent frame time
  5171. */
  5172. readonly instantaneousFPS: number;
  5173. /**
  5174. * Returns true if enough samples have been taken to completely fill the sliding window
  5175. */
  5176. readonly isSaturated: boolean;
  5177. /**
  5178. * Enables contributions to the sliding window sample set
  5179. */
  5180. enable(): void;
  5181. /**
  5182. * Disables contributions to the sliding window sample set
  5183. * Samples will not be interpolated over the disabled period
  5184. */
  5185. disable(): void;
  5186. /**
  5187. * Returns true if sampling is enabled
  5188. */
  5189. readonly isEnabled: boolean;
  5190. /**
  5191. * Resets performance monitor
  5192. */
  5193. reset(): void;
  5194. }
  5195. /**
  5196. * RollingAverage
  5197. *
  5198. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5199. */
  5200. export class RollingAverage {
  5201. /**
  5202. * Current average
  5203. */
  5204. average: number;
  5205. /**
  5206. * Current variance
  5207. */
  5208. variance: number;
  5209. protected _samples: Array<number>;
  5210. protected _sampleCount: number;
  5211. protected _pos: number;
  5212. protected _m2: number;
  5213. /**
  5214. * constructor
  5215. * @param length The number of samples required to saturate the sliding window
  5216. */
  5217. constructor(length: number);
  5218. /**
  5219. * Adds a sample to the sample set
  5220. * @param v The sample value
  5221. */
  5222. add(v: number): void;
  5223. /**
  5224. * Returns previously added values or null if outside of history or outside the sliding window domain
  5225. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5226. * @return Value previously recorded with add() or null if outside of range
  5227. */
  5228. history(i: number): number;
  5229. /**
  5230. * Returns true if enough samples have been taken to completely fill the sliding window
  5231. * @return true if sample-set saturated
  5232. */
  5233. isSaturated(): boolean;
  5234. /**
  5235. * Resets the rolling average (equivalent to 0 samples taken so far)
  5236. */
  5237. reset(): void;
  5238. /**
  5239. * Wraps a value around the sample range boundaries
  5240. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5241. * @return Wrapped position in sample range
  5242. */
  5243. protected _wrapPosition(i: number): number;
  5244. }
  5245. }
  5246. declare module "babylonjs/Misc/stringDictionary" {
  5247. import { Nullable } from "babylonjs/types";
  5248. /**
  5249. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5250. * The underlying implementation relies on an associative array to ensure the best performances.
  5251. * The value can be anything including 'null' but except 'undefined'
  5252. */
  5253. export class StringDictionary<T> {
  5254. /**
  5255. * This will clear this dictionary and copy the content from the 'source' one.
  5256. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5257. * @param source the dictionary to take the content from and copy to this dictionary
  5258. */
  5259. copyFrom(source: StringDictionary<T>): void;
  5260. /**
  5261. * Get a value based from its key
  5262. * @param key the given key to get the matching value from
  5263. * @return the value if found, otherwise undefined is returned
  5264. */
  5265. get(key: string): T | undefined;
  5266. /**
  5267. * Get a value from its key or add it if it doesn't exist.
  5268. * This method will ensure you that a given key/data will be present in the dictionary.
  5269. * @param key the given key to get the matching value from
  5270. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5271. * The factory will only be invoked if there's no data for the given key.
  5272. * @return the value corresponding to the key.
  5273. */
  5274. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5275. /**
  5276. * Get a value from its key if present in the dictionary otherwise add it
  5277. * @param key the key to get the value from
  5278. * @param val if there's no such key/value pair in the dictionary add it with this value
  5279. * @return the value corresponding to the key
  5280. */
  5281. getOrAdd(key: string, val: T): T;
  5282. /**
  5283. * Check if there's a given key in the dictionary
  5284. * @param key the key to check for
  5285. * @return true if the key is present, false otherwise
  5286. */
  5287. contains(key: string): boolean;
  5288. /**
  5289. * Add a new key and its corresponding value
  5290. * @param key the key to add
  5291. * @param value the value corresponding to the key
  5292. * @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
  5293. */
  5294. add(key: string, value: T): boolean;
  5295. /**
  5296. * Update a specific value associated to a key
  5297. * @param key defines the key to use
  5298. * @param value defines the value to store
  5299. * @returns true if the value was updated (or false if the key was not found)
  5300. */
  5301. set(key: string, value: T): boolean;
  5302. /**
  5303. * Get the element of the given key and remove it from the dictionary
  5304. * @param key defines the key to search
  5305. * @returns the value associated with the key or null if not found
  5306. */
  5307. getAndRemove(key: string): Nullable<T>;
  5308. /**
  5309. * Remove a key/value from the dictionary.
  5310. * @param key the key to remove
  5311. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5312. */
  5313. remove(key: string): boolean;
  5314. /**
  5315. * Clear the whole content of the dictionary
  5316. */
  5317. clear(): void;
  5318. /**
  5319. * Gets the current count
  5320. */
  5321. readonly count: number;
  5322. /**
  5323. * Execute a callback on each key/val of the dictionary.
  5324. * Note that you can remove any element in this dictionary in the callback implementation
  5325. * @param callback the callback to execute on a given key/value pair
  5326. */
  5327. forEach(callback: (key: string, val: T) => void): void;
  5328. /**
  5329. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5330. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5331. * Note that you can remove any element in this dictionary in the callback implementation
  5332. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5333. * @returns the first item
  5334. */
  5335. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5336. private _count;
  5337. private _data;
  5338. }
  5339. }
  5340. declare module "babylonjs/Misc/promise" {
  5341. /**
  5342. * Helper class that provides a small promise polyfill
  5343. */
  5344. export class PromisePolyfill {
  5345. /**
  5346. * Static function used to check if the polyfill is required
  5347. * If this is the case then the function will inject the polyfill to window.Promise
  5348. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5349. */
  5350. static Apply(force?: boolean): void;
  5351. }
  5352. }
  5353. declare module "babylonjs/Meshes/buffer" {
  5354. import { Nullable, DataArray } from "babylonjs/types";
  5355. /**
  5356. * Class used to store data that will be store in GPU memory
  5357. */
  5358. export class Buffer {
  5359. private _engine;
  5360. private _buffer;
  5361. /** @hidden */
  5362. _data: Nullable<DataArray>;
  5363. private _updatable;
  5364. private _instanced;
  5365. /**
  5366. * Gets the byte stride.
  5367. */
  5368. readonly byteStride: number;
  5369. /**
  5370. * Constructor
  5371. * @param engine the engine
  5372. * @param data the data to use for this buffer
  5373. * @param updatable whether the data is updatable
  5374. * @param stride the stride (optional)
  5375. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5376. * @param instanced whether the buffer is instanced (optional)
  5377. * @param useBytes set to true if the stride in in bytes (optional)
  5378. */
  5379. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5380. /**
  5381. * Create a new VertexBuffer based on the current buffer
  5382. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5383. * @param offset defines offset in the buffer (0 by default)
  5384. * @param size defines the size in floats of attributes (position is 3 for instance)
  5385. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5386. * @param instanced defines if the vertex buffer contains indexed data
  5387. * @param useBytes defines if the offset and stride are in bytes
  5388. * @returns the new vertex buffer
  5389. */
  5390. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5391. /**
  5392. * Gets a boolean indicating if the Buffer is updatable?
  5393. * @returns true if the buffer is updatable
  5394. */
  5395. isUpdatable(): boolean;
  5396. /**
  5397. * Gets current buffer's data
  5398. * @returns a DataArray or null
  5399. */
  5400. getData(): Nullable<DataArray>;
  5401. /**
  5402. * Gets underlying native buffer
  5403. * @returns underlying native buffer
  5404. */
  5405. getBuffer(): Nullable<WebGLBuffer>;
  5406. /**
  5407. * Gets the stride in float32 units (i.e. byte stride / 4).
  5408. * May not be an integer if the byte stride is not divisible by 4.
  5409. * DEPRECATED. Use byteStride instead.
  5410. * @returns the stride in float32 units
  5411. */
  5412. getStrideSize(): number;
  5413. /**
  5414. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5415. * @param data defines the data to store
  5416. */
  5417. create(data?: Nullable<DataArray>): void;
  5418. /** @hidden */
  5419. _rebuild(): void;
  5420. /**
  5421. * Update current buffer data
  5422. * @param data defines the data to store
  5423. */
  5424. update(data: DataArray): void;
  5425. /**
  5426. * Updates the data directly.
  5427. * @param data the new data
  5428. * @param offset the new offset
  5429. * @param vertexCount the vertex count (optional)
  5430. * @param useBytes set to true if the offset is in bytes
  5431. */
  5432. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5433. /**
  5434. * Release all resources
  5435. */
  5436. dispose(): void;
  5437. }
  5438. /**
  5439. * Specialized buffer used to store vertex data
  5440. */
  5441. export class VertexBuffer {
  5442. /** @hidden */
  5443. _buffer: Buffer;
  5444. private _kind;
  5445. private _size;
  5446. private _ownsBuffer;
  5447. private _instanced;
  5448. private _instanceDivisor;
  5449. /**
  5450. * The byte type.
  5451. */
  5452. static readonly BYTE: number;
  5453. /**
  5454. * The unsigned byte type.
  5455. */
  5456. static readonly UNSIGNED_BYTE: number;
  5457. /**
  5458. * The short type.
  5459. */
  5460. static readonly SHORT: number;
  5461. /**
  5462. * The unsigned short type.
  5463. */
  5464. static readonly UNSIGNED_SHORT: number;
  5465. /**
  5466. * The integer type.
  5467. */
  5468. static readonly INT: number;
  5469. /**
  5470. * The unsigned integer type.
  5471. */
  5472. static readonly UNSIGNED_INT: number;
  5473. /**
  5474. * The float type.
  5475. */
  5476. static readonly FLOAT: number;
  5477. /**
  5478. * Gets or sets the instance divisor when in instanced mode
  5479. */
  5480. instanceDivisor: number;
  5481. /**
  5482. * Gets the byte stride.
  5483. */
  5484. readonly byteStride: number;
  5485. /**
  5486. * Gets the byte offset.
  5487. */
  5488. readonly byteOffset: number;
  5489. /**
  5490. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5491. */
  5492. readonly normalized: boolean;
  5493. /**
  5494. * Gets the data type of each component in the array.
  5495. */
  5496. readonly type: number;
  5497. /**
  5498. * Constructor
  5499. * @param engine the engine
  5500. * @param data the data to use for this vertex buffer
  5501. * @param kind the vertex buffer kind
  5502. * @param updatable whether the data is updatable
  5503. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5504. * @param stride the stride (optional)
  5505. * @param instanced whether the buffer is instanced (optional)
  5506. * @param offset the offset of the data (optional)
  5507. * @param size the number of components (optional)
  5508. * @param type the type of the component (optional)
  5509. * @param normalized whether the data contains normalized data (optional)
  5510. * @param useBytes set to true if stride and offset are in bytes (optional)
  5511. */
  5512. 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);
  5513. /** @hidden */
  5514. _rebuild(): void;
  5515. /**
  5516. * Returns the kind of the VertexBuffer (string)
  5517. * @returns a string
  5518. */
  5519. getKind(): string;
  5520. /**
  5521. * Gets a boolean indicating if the VertexBuffer is updatable?
  5522. * @returns true if the buffer is updatable
  5523. */
  5524. isUpdatable(): boolean;
  5525. /**
  5526. * Gets current buffer's data
  5527. * @returns a DataArray or null
  5528. */
  5529. getData(): Nullable<DataArray>;
  5530. /**
  5531. * Gets underlying native buffer
  5532. * @returns underlying native buffer
  5533. */
  5534. getBuffer(): Nullable<WebGLBuffer>;
  5535. /**
  5536. * Gets the stride in float32 units (i.e. byte stride / 4).
  5537. * May not be an integer if the byte stride is not divisible by 4.
  5538. * DEPRECATED. Use byteStride instead.
  5539. * @returns the stride in float32 units
  5540. */
  5541. getStrideSize(): number;
  5542. /**
  5543. * Returns the offset as a multiple of the type byte length.
  5544. * DEPRECATED. Use byteOffset instead.
  5545. * @returns the offset in bytes
  5546. */
  5547. getOffset(): number;
  5548. /**
  5549. * Returns the number of components per vertex attribute (integer)
  5550. * @returns the size in float
  5551. */
  5552. getSize(): number;
  5553. /**
  5554. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5555. * @returns true if this buffer is instanced
  5556. */
  5557. getIsInstanced(): boolean;
  5558. /**
  5559. * Returns the instancing divisor, zero for non-instanced (integer).
  5560. * @returns a number
  5561. */
  5562. getInstanceDivisor(): number;
  5563. /**
  5564. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5565. * @param data defines the data to store
  5566. */
  5567. create(data?: DataArray): void;
  5568. /**
  5569. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5570. * This function will create a new buffer if the current one is not updatable
  5571. * @param data defines the data to store
  5572. */
  5573. update(data: DataArray): void;
  5574. /**
  5575. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5576. * Returns the directly updated WebGLBuffer.
  5577. * @param data the new data
  5578. * @param offset the new offset
  5579. * @param useBytes set to true if the offset is in bytes
  5580. */
  5581. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5582. /**
  5583. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5584. */
  5585. dispose(): void;
  5586. /**
  5587. * Enumerates each value of this vertex buffer as numbers.
  5588. * @param count the number of values to enumerate
  5589. * @param callback the callback function called for each value
  5590. */
  5591. forEach(count: number, callback: (value: number, index: number) => void): void;
  5592. /**
  5593. * Positions
  5594. */
  5595. static readonly PositionKind: string;
  5596. /**
  5597. * Normals
  5598. */
  5599. static readonly NormalKind: string;
  5600. /**
  5601. * Tangents
  5602. */
  5603. static readonly TangentKind: string;
  5604. /**
  5605. * Texture coordinates
  5606. */
  5607. static readonly UVKind: string;
  5608. /**
  5609. * Texture coordinates 2
  5610. */
  5611. static readonly UV2Kind: string;
  5612. /**
  5613. * Texture coordinates 3
  5614. */
  5615. static readonly UV3Kind: string;
  5616. /**
  5617. * Texture coordinates 4
  5618. */
  5619. static readonly UV4Kind: string;
  5620. /**
  5621. * Texture coordinates 5
  5622. */
  5623. static readonly UV5Kind: string;
  5624. /**
  5625. * Texture coordinates 6
  5626. */
  5627. static readonly UV6Kind: string;
  5628. /**
  5629. * Colors
  5630. */
  5631. static readonly ColorKind: string;
  5632. /**
  5633. * Matrix indices (for bones)
  5634. */
  5635. static readonly MatricesIndicesKind: string;
  5636. /**
  5637. * Matrix weights (for bones)
  5638. */
  5639. static readonly MatricesWeightsKind: string;
  5640. /**
  5641. * Additional matrix indices (for bones)
  5642. */
  5643. static readonly MatricesIndicesExtraKind: string;
  5644. /**
  5645. * Additional matrix weights (for bones)
  5646. */
  5647. static readonly MatricesWeightsExtraKind: string;
  5648. /**
  5649. * Deduces the stride given a kind.
  5650. * @param kind The kind string to deduce
  5651. * @returns The deduced stride
  5652. */
  5653. static DeduceStride(kind: string): number;
  5654. /**
  5655. * Gets the byte length of the given type.
  5656. * @param type the type
  5657. * @returns the number of bytes
  5658. */
  5659. static GetTypeByteLength(type: number): number;
  5660. /**
  5661. * Enumerates each value of the given parameters as numbers.
  5662. * @param data the data to enumerate
  5663. * @param byteOffset the byte offset of the data
  5664. * @param byteStride the byte stride of the data
  5665. * @param componentCount the number of components per element
  5666. * @param componentType the type of the component
  5667. * @param count the total number of components
  5668. * @param normalized whether the data is normalized
  5669. * @param callback the callback function called for each value
  5670. */
  5671. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5672. private static _GetFloatValue;
  5673. }
  5674. }
  5675. declare module "babylonjs/Maths/sphericalPolynomial" {
  5676. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5677. /**
  5678. * Class representing spherical polynomial coefficients to the 3rd degree
  5679. */
  5680. export class SphericalPolynomial {
  5681. /**
  5682. * The x coefficients of the spherical polynomial
  5683. */
  5684. x: Vector3;
  5685. /**
  5686. * The y coefficients of the spherical polynomial
  5687. */
  5688. y: Vector3;
  5689. /**
  5690. * The z coefficients of the spherical polynomial
  5691. */
  5692. z: Vector3;
  5693. /**
  5694. * The xx coefficients of the spherical polynomial
  5695. */
  5696. xx: Vector3;
  5697. /**
  5698. * The yy coefficients of the spherical polynomial
  5699. */
  5700. yy: Vector3;
  5701. /**
  5702. * The zz coefficients of the spherical polynomial
  5703. */
  5704. zz: Vector3;
  5705. /**
  5706. * The xy coefficients of the spherical polynomial
  5707. */
  5708. xy: Vector3;
  5709. /**
  5710. * The yz coefficients of the spherical polynomial
  5711. */
  5712. yz: Vector3;
  5713. /**
  5714. * The zx coefficients of the spherical polynomial
  5715. */
  5716. zx: Vector3;
  5717. /**
  5718. * Adds an ambient color to the spherical polynomial
  5719. * @param color the color to add
  5720. */
  5721. addAmbient(color: Color3): void;
  5722. /**
  5723. * Scales the spherical polynomial by the given amount
  5724. * @param scale the amount to scale
  5725. */
  5726. scale(scale: number): void;
  5727. /**
  5728. * Gets the spherical polynomial from harmonics
  5729. * @param harmonics the spherical harmonics
  5730. * @returns the spherical polynomial
  5731. */
  5732. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5733. /**
  5734. * Constructs a spherical polynomial from an array.
  5735. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5736. * @returns the spherical polynomial
  5737. */
  5738. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5739. }
  5740. /**
  5741. * Class representing spherical harmonics coefficients to the 3rd degree
  5742. */
  5743. export class SphericalHarmonics {
  5744. /**
  5745. * The l0,0 coefficients of the spherical harmonics
  5746. */
  5747. l00: Vector3;
  5748. /**
  5749. * The l1,-1 coefficients of the spherical harmonics
  5750. */
  5751. l1_1: Vector3;
  5752. /**
  5753. * The l1,0 coefficients of the spherical harmonics
  5754. */
  5755. l10: Vector3;
  5756. /**
  5757. * The l1,1 coefficients of the spherical harmonics
  5758. */
  5759. l11: Vector3;
  5760. /**
  5761. * The l2,-2 coefficients of the spherical harmonics
  5762. */
  5763. l2_2: Vector3;
  5764. /**
  5765. * The l2,-1 coefficients of the spherical harmonics
  5766. */
  5767. l2_1: Vector3;
  5768. /**
  5769. * The l2,0 coefficients of the spherical harmonics
  5770. */
  5771. l20: Vector3;
  5772. /**
  5773. * The l2,1 coefficients of the spherical harmonics
  5774. */
  5775. l21: Vector3;
  5776. /**
  5777. * The l2,2 coefficients of the spherical harmonics
  5778. */
  5779. lL22: Vector3;
  5780. /**
  5781. * Adds a light to the spherical harmonics
  5782. * @param direction the direction of the light
  5783. * @param color the color of the light
  5784. * @param deltaSolidAngle the delta solid angle of the light
  5785. */
  5786. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5787. /**
  5788. * Scales the spherical harmonics by the given amount
  5789. * @param scale the amount to scale
  5790. */
  5791. scale(scale: number): void;
  5792. /**
  5793. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5794. *
  5795. * ```
  5796. * E_lm = A_l * L_lm
  5797. * ```
  5798. *
  5799. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5800. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5801. * the scaling factors are given in equation 9.
  5802. */
  5803. convertIncidentRadianceToIrradiance(): void;
  5804. /**
  5805. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5806. *
  5807. * ```
  5808. * L = (1/pi) * E * rho
  5809. * ```
  5810. *
  5811. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5812. */
  5813. convertIrradianceToLambertianRadiance(): void;
  5814. /**
  5815. * Gets the spherical harmonics from polynomial
  5816. * @param polynomial the spherical polynomial
  5817. * @returns the spherical harmonics
  5818. */
  5819. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5820. /**
  5821. * Constructs a spherical harmonics from an array.
  5822. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5823. * @returns the spherical harmonics
  5824. */
  5825. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5826. }
  5827. }
  5828. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5829. import { Nullable } from "babylonjs/types";
  5830. /**
  5831. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5832. */
  5833. export interface CubeMapInfo {
  5834. /**
  5835. * The pixel array for the front face.
  5836. * This is stored in format, left to right, up to down format.
  5837. */
  5838. front: Nullable<ArrayBufferView>;
  5839. /**
  5840. * The pixel array for the back face.
  5841. * This is stored in format, left to right, up to down format.
  5842. */
  5843. back: Nullable<ArrayBufferView>;
  5844. /**
  5845. * The pixel array for the left face.
  5846. * This is stored in format, left to right, up to down format.
  5847. */
  5848. left: Nullable<ArrayBufferView>;
  5849. /**
  5850. * The pixel array for the right face.
  5851. * This is stored in format, left to right, up to down format.
  5852. */
  5853. right: Nullable<ArrayBufferView>;
  5854. /**
  5855. * The pixel array for the up face.
  5856. * This is stored in format, left to right, up to down format.
  5857. */
  5858. up: Nullable<ArrayBufferView>;
  5859. /**
  5860. * The pixel array for the down face.
  5861. * This is stored in format, left to right, up to down format.
  5862. */
  5863. down: Nullable<ArrayBufferView>;
  5864. /**
  5865. * The size of the cubemap stored.
  5866. *
  5867. * Each faces will be size * size pixels.
  5868. */
  5869. size: number;
  5870. /**
  5871. * The format of the texture.
  5872. *
  5873. * RGBA, RGB.
  5874. */
  5875. format: number;
  5876. /**
  5877. * The type of the texture data.
  5878. *
  5879. * UNSIGNED_INT, FLOAT.
  5880. */
  5881. type: number;
  5882. /**
  5883. * Specifies whether the texture is in gamma space.
  5884. */
  5885. gammaSpace: boolean;
  5886. }
  5887. /**
  5888. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5889. */
  5890. export class PanoramaToCubeMapTools {
  5891. private static FACE_FRONT;
  5892. private static FACE_BACK;
  5893. private static FACE_RIGHT;
  5894. private static FACE_LEFT;
  5895. private static FACE_DOWN;
  5896. private static FACE_UP;
  5897. /**
  5898. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5899. *
  5900. * @param float32Array The source data.
  5901. * @param inputWidth The width of the input panorama.
  5902. * @param inputHeight The height of the input panorama.
  5903. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5904. * @return The cubemap data
  5905. */
  5906. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5907. private static CreateCubemapTexture;
  5908. private static CalcProjectionSpherical;
  5909. }
  5910. }
  5911. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5912. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5913. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5914. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5915. /**
  5916. * Helper class dealing with the extraction of spherical polynomial dataArray
  5917. * from a cube map.
  5918. */
  5919. export class CubeMapToSphericalPolynomialTools {
  5920. private static FileFaces;
  5921. /**
  5922. * Converts a texture to the according Spherical Polynomial data.
  5923. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5924. *
  5925. * @param texture The texture to extract the information from.
  5926. * @return The Spherical Polynomial data.
  5927. */
  5928. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5929. /**
  5930. * Converts a cubemap to the according Spherical Polynomial data.
  5931. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5932. *
  5933. * @param cubeInfo The Cube map to extract the information from.
  5934. * @return The Spherical Polynomial data.
  5935. */
  5936. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5937. }
  5938. }
  5939. declare module "babylonjs/Engines/engineStore" {
  5940. import { Nullable } from "babylonjs/types";
  5941. import { Engine } from "babylonjs/Engines/engine";
  5942. import { Scene } from "babylonjs/scene";
  5943. /**
  5944. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5945. * during the life time of the application.
  5946. */
  5947. export class EngineStore {
  5948. /** Gets the list of created engines */
  5949. static Instances: import("babylonjs/Engines/engine").Engine[];
  5950. /**
  5951. * Gets the latest created engine
  5952. */
  5953. static readonly LastCreatedEngine: Nullable<Engine>;
  5954. /**
  5955. * Gets the latest created scene
  5956. */
  5957. static readonly LastCreatedScene: Nullable<Scene>;
  5958. }
  5959. }
  5960. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5961. /**
  5962. * Define options used to create a render target texture
  5963. */
  5964. export class RenderTargetCreationOptions {
  5965. /**
  5966. * Specifies is mipmaps must be generated
  5967. */
  5968. generateMipMaps?: boolean;
  5969. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5970. generateDepthBuffer?: boolean;
  5971. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5972. generateStencilBuffer?: boolean;
  5973. /** Defines texture type (int by default) */
  5974. type?: number;
  5975. /** Defines sampling mode (trilinear by default) */
  5976. samplingMode?: number;
  5977. /** Defines format (RGBA by default) */
  5978. format?: number;
  5979. }
  5980. }
  5981. declare module "babylonjs/States/alphaCullingState" {
  5982. /**
  5983. * @hidden
  5984. **/
  5985. export class _AlphaState {
  5986. private _isAlphaBlendDirty;
  5987. private _isBlendFunctionParametersDirty;
  5988. private _isBlendEquationParametersDirty;
  5989. private _isBlendConstantsDirty;
  5990. private _alphaBlend;
  5991. private _blendFunctionParameters;
  5992. private _blendEquationParameters;
  5993. private _blendConstants;
  5994. /**
  5995. * Initializes the state.
  5996. */
  5997. constructor();
  5998. readonly isDirty: boolean;
  5999. alphaBlend: boolean;
  6000. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6001. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6002. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6003. reset(): void;
  6004. apply(gl: WebGLRenderingContext): void;
  6005. }
  6006. }
  6007. declare module "babylonjs/States/depthCullingState" {
  6008. import { Nullable } from "babylonjs/types";
  6009. /**
  6010. * @hidden
  6011. **/
  6012. export class _DepthCullingState {
  6013. private _isDepthTestDirty;
  6014. private _isDepthMaskDirty;
  6015. private _isDepthFuncDirty;
  6016. private _isCullFaceDirty;
  6017. private _isCullDirty;
  6018. private _isZOffsetDirty;
  6019. private _isFrontFaceDirty;
  6020. private _depthTest;
  6021. private _depthMask;
  6022. private _depthFunc;
  6023. private _cull;
  6024. private _cullFace;
  6025. private _zOffset;
  6026. private _frontFace;
  6027. /**
  6028. * Initializes the state.
  6029. */
  6030. constructor();
  6031. readonly isDirty: boolean;
  6032. zOffset: number;
  6033. cullFace: Nullable<number>;
  6034. cull: Nullable<boolean>;
  6035. depthFunc: Nullable<number>;
  6036. depthMask: boolean;
  6037. depthTest: boolean;
  6038. frontFace: Nullable<number>;
  6039. reset(): void;
  6040. apply(gl: WebGLRenderingContext): void;
  6041. }
  6042. }
  6043. declare module "babylonjs/States/stencilState" {
  6044. /**
  6045. * @hidden
  6046. **/
  6047. export class _StencilState {
  6048. /** 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 */
  6049. static readonly ALWAYS: number;
  6050. /** Passed to stencilOperation to specify that stencil value must be kept */
  6051. static readonly KEEP: number;
  6052. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6053. static readonly REPLACE: number;
  6054. private _isStencilTestDirty;
  6055. private _isStencilMaskDirty;
  6056. private _isStencilFuncDirty;
  6057. private _isStencilOpDirty;
  6058. private _stencilTest;
  6059. private _stencilMask;
  6060. private _stencilFunc;
  6061. private _stencilFuncRef;
  6062. private _stencilFuncMask;
  6063. private _stencilOpStencilFail;
  6064. private _stencilOpDepthFail;
  6065. private _stencilOpStencilDepthPass;
  6066. readonly isDirty: boolean;
  6067. stencilFunc: number;
  6068. stencilFuncRef: number;
  6069. stencilFuncMask: number;
  6070. stencilOpStencilFail: number;
  6071. stencilOpDepthFail: number;
  6072. stencilOpStencilDepthPass: number;
  6073. stencilMask: number;
  6074. stencilTest: boolean;
  6075. constructor();
  6076. reset(): void;
  6077. apply(gl: WebGLRenderingContext): void;
  6078. }
  6079. }
  6080. declare module "babylonjs/States/index" {
  6081. export * from "babylonjs/States/alphaCullingState";
  6082. export * from "babylonjs/States/depthCullingState";
  6083. export * from "babylonjs/States/stencilState";
  6084. }
  6085. declare module "babylonjs/Instrumentation/timeToken" {
  6086. import { Nullable } from "babylonjs/types";
  6087. /**
  6088. * @hidden
  6089. **/
  6090. export class _TimeToken {
  6091. _startTimeQuery: Nullable<WebGLQuery>;
  6092. _endTimeQuery: Nullable<WebGLQuery>;
  6093. _timeElapsedQuery: Nullable<WebGLQuery>;
  6094. _timeElapsedQueryEnded: boolean;
  6095. }
  6096. }
  6097. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6098. import { Nullable } from "babylonjs/types";
  6099. /**
  6100. * Internal interface used to track InternalTexture already bound to the GL context
  6101. */
  6102. export interface IInternalTextureTracker {
  6103. /**
  6104. * Gets or set the previous tracker in the list
  6105. */
  6106. previous: Nullable<IInternalTextureTracker>;
  6107. /**
  6108. * Gets or set the next tracker in the list
  6109. */
  6110. next: Nullable<IInternalTextureTracker>;
  6111. }
  6112. /**
  6113. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6114. */
  6115. export class DummyInternalTextureTracker {
  6116. /**
  6117. * Gets or set the previous tracker in the list
  6118. */
  6119. previous: Nullable<IInternalTextureTracker>;
  6120. /**
  6121. * Gets or set the next tracker in the list
  6122. */
  6123. next: Nullable<IInternalTextureTracker>;
  6124. }
  6125. }
  6126. declare module "babylonjs/Materials/Textures/internalTexture" {
  6127. import { Observable } from "babylonjs/Misc/observable";
  6128. import { Nullable, int } from "babylonjs/types";
  6129. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6130. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6131. import { Engine } from "babylonjs/Engines/engine";
  6132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6133. /**
  6134. * Class used to store data associated with WebGL texture data for the engine
  6135. * This class should not be used directly
  6136. */
  6137. export class InternalTexture implements IInternalTextureTracker {
  6138. /** hidden */
  6139. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6140. /**
  6141. * The source of the texture data is unknown
  6142. */
  6143. static DATASOURCE_UNKNOWN: number;
  6144. /**
  6145. * Texture data comes from an URL
  6146. */
  6147. static DATASOURCE_URL: number;
  6148. /**
  6149. * Texture data is only used for temporary storage
  6150. */
  6151. static DATASOURCE_TEMP: number;
  6152. /**
  6153. * Texture data comes from raw data (ArrayBuffer)
  6154. */
  6155. static DATASOURCE_RAW: number;
  6156. /**
  6157. * Texture content is dynamic (video or dynamic texture)
  6158. */
  6159. static DATASOURCE_DYNAMIC: number;
  6160. /**
  6161. * Texture content is generated by rendering to it
  6162. */
  6163. static DATASOURCE_RENDERTARGET: number;
  6164. /**
  6165. * Texture content is part of a multi render target process
  6166. */
  6167. static DATASOURCE_MULTIRENDERTARGET: number;
  6168. /**
  6169. * Texture data comes from a cube data file
  6170. */
  6171. static DATASOURCE_CUBE: number;
  6172. /**
  6173. * Texture data comes from a raw cube data
  6174. */
  6175. static DATASOURCE_CUBERAW: number;
  6176. /**
  6177. * Texture data come from a prefiltered cube data file
  6178. */
  6179. static DATASOURCE_CUBEPREFILTERED: number;
  6180. /**
  6181. * Texture content is raw 3D data
  6182. */
  6183. static DATASOURCE_RAW3D: number;
  6184. /**
  6185. * Texture content is a depth texture
  6186. */
  6187. static DATASOURCE_DEPTHTEXTURE: number;
  6188. /**
  6189. * Texture data comes from a raw cube data encoded with RGBD
  6190. */
  6191. static DATASOURCE_CUBERAW_RGBD: number;
  6192. /**
  6193. * Defines if the texture is ready
  6194. */
  6195. isReady: boolean;
  6196. /**
  6197. * Defines if the texture is a cube texture
  6198. */
  6199. isCube: boolean;
  6200. /**
  6201. * Defines if the texture contains 3D data
  6202. */
  6203. is3D: boolean;
  6204. /**
  6205. * Gets the URL used to load this texture
  6206. */
  6207. url: string;
  6208. /**
  6209. * Gets the sampling mode of the texture
  6210. */
  6211. samplingMode: number;
  6212. /**
  6213. * Gets a boolean indicating if the texture needs mipmaps generation
  6214. */
  6215. generateMipMaps: boolean;
  6216. /**
  6217. * Gets the number of samples used by the texture (WebGL2+ only)
  6218. */
  6219. samples: number;
  6220. /**
  6221. * Gets the type of the texture (int, float...)
  6222. */
  6223. type: number;
  6224. /**
  6225. * Gets the format of the texture (RGB, RGBA...)
  6226. */
  6227. format: number;
  6228. /**
  6229. * Observable called when the texture is loaded
  6230. */
  6231. onLoadedObservable: Observable<InternalTexture>;
  6232. /**
  6233. * Gets the width of the texture
  6234. */
  6235. width: number;
  6236. /**
  6237. * Gets the height of the texture
  6238. */
  6239. height: number;
  6240. /**
  6241. * Gets the depth of the texture
  6242. */
  6243. depth: number;
  6244. /**
  6245. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6246. */
  6247. baseWidth: number;
  6248. /**
  6249. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6250. */
  6251. baseHeight: number;
  6252. /**
  6253. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6254. */
  6255. baseDepth: number;
  6256. /**
  6257. * Gets a boolean indicating if the texture is inverted on Y axis
  6258. */
  6259. invertY: boolean;
  6260. /**
  6261. * Gets or set the previous tracker in the list
  6262. */
  6263. previous: Nullable<IInternalTextureTracker>;
  6264. /**
  6265. * Gets or set the next tracker in the list
  6266. */
  6267. next: Nullable<IInternalTextureTracker>;
  6268. /** @hidden */
  6269. _invertVScale: boolean;
  6270. /** @hidden */
  6271. _initialSlot: number;
  6272. /** @hidden */
  6273. _designatedSlot: number;
  6274. /** @hidden */
  6275. _dataSource: number;
  6276. /** @hidden */
  6277. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6278. /** @hidden */
  6279. _bufferView: Nullable<ArrayBufferView>;
  6280. /** @hidden */
  6281. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6282. /** @hidden */
  6283. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6284. /** @hidden */
  6285. _size: number;
  6286. /** @hidden */
  6287. _extension: string;
  6288. /** @hidden */
  6289. _files: Nullable<string[]>;
  6290. /** @hidden */
  6291. _workingCanvas: HTMLCanvasElement;
  6292. /** @hidden */
  6293. _workingContext: CanvasRenderingContext2D;
  6294. /** @hidden */
  6295. _framebuffer: Nullable<WebGLFramebuffer>;
  6296. /** @hidden */
  6297. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6298. /** @hidden */
  6299. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6300. /** @hidden */
  6301. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6302. /** @hidden */
  6303. _attachments: Nullable<number[]>;
  6304. /** @hidden */
  6305. _cachedCoordinatesMode: Nullable<number>;
  6306. /** @hidden */
  6307. _cachedWrapU: Nullable<number>;
  6308. /** @hidden */
  6309. _cachedWrapV: Nullable<number>;
  6310. /** @hidden */
  6311. _cachedWrapR: Nullable<number>;
  6312. /** @hidden */
  6313. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6314. /** @hidden */
  6315. _isDisabled: boolean;
  6316. /** @hidden */
  6317. _compression: Nullable<string>;
  6318. /** @hidden */
  6319. _generateStencilBuffer: boolean;
  6320. /** @hidden */
  6321. _generateDepthBuffer: boolean;
  6322. /** @hidden */
  6323. _comparisonFunction: number;
  6324. /** @hidden */
  6325. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6326. /** @hidden */
  6327. _lodGenerationScale: number;
  6328. /** @hidden */
  6329. _lodGenerationOffset: number;
  6330. /** @hidden */
  6331. _lodTextureHigh: BaseTexture;
  6332. /** @hidden */
  6333. _lodTextureMid: BaseTexture;
  6334. /** @hidden */
  6335. _lodTextureLow: BaseTexture;
  6336. /** @hidden */
  6337. _isRGBD: boolean;
  6338. /** @hidden */
  6339. _webGLTexture: Nullable<WebGLTexture>;
  6340. /** @hidden */
  6341. _references: number;
  6342. private _engine;
  6343. /**
  6344. * Gets the Engine the texture belongs to.
  6345. * @returns The babylon engine
  6346. */
  6347. getEngine(): Engine;
  6348. /**
  6349. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6350. */
  6351. readonly dataSource: number;
  6352. /**
  6353. * Creates a new InternalTexture
  6354. * @param engine defines the engine to use
  6355. * @param dataSource defines the type of data that will be used
  6356. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6357. */
  6358. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6359. /**
  6360. * Increments the number of references (ie. the number of Texture that point to it)
  6361. */
  6362. incrementReferences(): void;
  6363. /**
  6364. * Change the size of the texture (not the size of the content)
  6365. * @param width defines the new width
  6366. * @param height defines the new height
  6367. * @param depth defines the new depth (1 by default)
  6368. */
  6369. updateSize(width: int, height: int, depth?: int): void;
  6370. /** @hidden */
  6371. _rebuild(): void;
  6372. /** @hidden */
  6373. _swapAndDie(target: InternalTexture): void;
  6374. /**
  6375. * Dispose the current allocated resources
  6376. */
  6377. dispose(): void;
  6378. }
  6379. }
  6380. declare module "babylonjs/Animations/easing" {
  6381. /**
  6382. * This represents the main contract an easing function should follow.
  6383. * Easing functions are used throughout the animation system.
  6384. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6385. */
  6386. export interface IEasingFunction {
  6387. /**
  6388. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6389. * of the easing function.
  6390. * The link below provides some of the most common examples of easing functions.
  6391. * @see https://easings.net/
  6392. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6393. * @returns the corresponding value on the curve defined by the easing function
  6394. */
  6395. ease(gradient: number): number;
  6396. }
  6397. /**
  6398. * Base class used for every default easing function.
  6399. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6400. */
  6401. export class EasingFunction implements IEasingFunction {
  6402. /**
  6403. * Interpolation follows the mathematical formula associated with the easing function.
  6404. */
  6405. static readonly EASINGMODE_EASEIN: number;
  6406. /**
  6407. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6408. */
  6409. static readonly EASINGMODE_EASEOUT: number;
  6410. /**
  6411. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6412. */
  6413. static readonly EASINGMODE_EASEINOUT: number;
  6414. private _easingMode;
  6415. /**
  6416. * Sets the easing mode of the current function.
  6417. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6418. */
  6419. setEasingMode(easingMode: number): void;
  6420. /**
  6421. * Gets the current easing mode.
  6422. * @returns the easing mode
  6423. */
  6424. getEasingMode(): number;
  6425. /**
  6426. * @hidden
  6427. */
  6428. easeInCore(gradient: number): number;
  6429. /**
  6430. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6431. * of the easing function.
  6432. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6433. * @returns the corresponding value on the curve defined by the easing function
  6434. */
  6435. ease(gradient: number): number;
  6436. }
  6437. /**
  6438. * Easing function with a circle shape (see link below).
  6439. * @see https://easings.net/#easeInCirc
  6440. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6441. */
  6442. export class CircleEase extends EasingFunction implements IEasingFunction {
  6443. /** @hidden */
  6444. easeInCore(gradient: number): number;
  6445. }
  6446. /**
  6447. * Easing function with a ease back shape (see link below).
  6448. * @see https://easings.net/#easeInBack
  6449. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6450. */
  6451. export class BackEase extends EasingFunction implements IEasingFunction {
  6452. /** Defines the amplitude of the function */
  6453. amplitude: number;
  6454. /**
  6455. * Instantiates a back ease easing
  6456. * @see https://easings.net/#easeInBack
  6457. * @param amplitude Defines the amplitude of the function
  6458. */
  6459. constructor(
  6460. /** Defines the amplitude of the function */
  6461. amplitude?: number);
  6462. /** @hidden */
  6463. easeInCore(gradient: number): number;
  6464. }
  6465. /**
  6466. * Easing function with a bouncing shape (see link below).
  6467. * @see https://easings.net/#easeInBounce
  6468. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6469. */
  6470. export class BounceEase extends EasingFunction implements IEasingFunction {
  6471. /** Defines the number of bounces */
  6472. bounces: number;
  6473. /** Defines the amplitude of the bounce */
  6474. bounciness: number;
  6475. /**
  6476. * Instantiates a bounce easing
  6477. * @see https://easings.net/#easeInBounce
  6478. * @param bounces Defines the number of bounces
  6479. * @param bounciness Defines the amplitude of the bounce
  6480. */
  6481. constructor(
  6482. /** Defines the number of bounces */
  6483. bounces?: number,
  6484. /** Defines the amplitude of the bounce */
  6485. bounciness?: number);
  6486. /** @hidden */
  6487. easeInCore(gradient: number): number;
  6488. }
  6489. /**
  6490. * Easing function with a power of 3 shape (see link below).
  6491. * @see https://easings.net/#easeInCubic
  6492. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6493. */
  6494. export class CubicEase extends EasingFunction implements IEasingFunction {
  6495. /** @hidden */
  6496. easeInCore(gradient: number): number;
  6497. }
  6498. /**
  6499. * Easing function with an elastic shape (see link below).
  6500. * @see https://easings.net/#easeInElastic
  6501. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6502. */
  6503. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6504. /** Defines the number of oscillations*/
  6505. oscillations: number;
  6506. /** Defines the amplitude of the oscillations*/
  6507. springiness: number;
  6508. /**
  6509. * Instantiates an elastic easing function
  6510. * @see https://easings.net/#easeInElastic
  6511. * @param oscillations Defines the number of oscillations
  6512. * @param springiness Defines the amplitude of the oscillations
  6513. */
  6514. constructor(
  6515. /** Defines the number of oscillations*/
  6516. oscillations?: number,
  6517. /** Defines the amplitude of the oscillations*/
  6518. springiness?: number);
  6519. /** @hidden */
  6520. easeInCore(gradient: number): number;
  6521. }
  6522. /**
  6523. * Easing function with an exponential shape (see link below).
  6524. * @see https://easings.net/#easeInExpo
  6525. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6526. */
  6527. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6528. /** Defines the exponent of the function */
  6529. exponent: number;
  6530. /**
  6531. * Instantiates an exponential easing function
  6532. * @see https://easings.net/#easeInExpo
  6533. * @param exponent Defines the exponent of the function
  6534. */
  6535. constructor(
  6536. /** Defines the exponent of the function */
  6537. exponent?: number);
  6538. /** @hidden */
  6539. easeInCore(gradient: number): number;
  6540. }
  6541. /**
  6542. * Easing function with a power shape (see link below).
  6543. * @see https://easings.net/#easeInQuad
  6544. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6545. */
  6546. export class PowerEase extends EasingFunction implements IEasingFunction {
  6547. /** Defines the power of the function */
  6548. power: number;
  6549. /**
  6550. * Instantiates an power base easing function
  6551. * @see https://easings.net/#easeInQuad
  6552. * @param power Defines the power of the function
  6553. */
  6554. constructor(
  6555. /** Defines the power of the function */
  6556. power?: number);
  6557. /** @hidden */
  6558. easeInCore(gradient: number): number;
  6559. }
  6560. /**
  6561. * Easing function with a power of 2 shape (see link below).
  6562. * @see https://easings.net/#easeInQuad
  6563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6564. */
  6565. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6566. /** @hidden */
  6567. easeInCore(gradient: number): number;
  6568. }
  6569. /**
  6570. * Easing function with a power of 4 shape (see link below).
  6571. * @see https://easings.net/#easeInQuart
  6572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6573. */
  6574. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6575. /** @hidden */
  6576. easeInCore(gradient: number): number;
  6577. }
  6578. /**
  6579. * Easing function with a power of 5 shape (see link below).
  6580. * @see https://easings.net/#easeInQuint
  6581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6582. */
  6583. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with a sin shape (see link below).
  6589. * @see https://easings.net/#easeInSine
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class SineEase extends EasingFunction implements IEasingFunction {
  6593. /** @hidden */
  6594. easeInCore(gradient: number): number;
  6595. }
  6596. /**
  6597. * Easing function with a bezier shape (see link below).
  6598. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6600. */
  6601. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6602. /** Defines the x component of the start tangent in the bezier curve */
  6603. x1: number;
  6604. /** Defines the y component of the start tangent in the bezier curve */
  6605. y1: number;
  6606. /** Defines the x component of the end tangent in the bezier curve */
  6607. x2: number;
  6608. /** Defines the y component of the end tangent in the bezier curve */
  6609. y2: number;
  6610. /**
  6611. * Instantiates a bezier function
  6612. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6613. * @param x1 Defines the x component of the start tangent in the bezier curve
  6614. * @param y1 Defines the y component of the start tangent in the bezier curve
  6615. * @param x2 Defines the x component of the end tangent in the bezier curve
  6616. * @param y2 Defines the y component of the end tangent in the bezier curve
  6617. */
  6618. constructor(
  6619. /** Defines the x component of the start tangent in the bezier curve */
  6620. x1?: number,
  6621. /** Defines the y component of the start tangent in the bezier curve */
  6622. y1?: number,
  6623. /** Defines the x component of the end tangent in the bezier curve */
  6624. x2?: number,
  6625. /** Defines the y component of the end tangent in the bezier curve */
  6626. y2?: number);
  6627. /** @hidden */
  6628. easeInCore(gradient: number): number;
  6629. }
  6630. }
  6631. declare module "babylonjs/Animations/animationKey" {
  6632. /**
  6633. * Defines an interface which represents an animation key frame
  6634. */
  6635. export interface IAnimationKey {
  6636. /**
  6637. * Frame of the key frame
  6638. */
  6639. frame: number;
  6640. /**
  6641. * Value at the specifies key frame
  6642. */
  6643. value: any;
  6644. /**
  6645. * The input tangent for the cubic hermite spline
  6646. */
  6647. inTangent?: any;
  6648. /**
  6649. * The output tangent for the cubic hermite spline
  6650. */
  6651. outTangent?: any;
  6652. /**
  6653. * The animation interpolation type
  6654. */
  6655. interpolation?: AnimationKeyInterpolation;
  6656. }
  6657. /**
  6658. * Enum for the animation key frame interpolation type
  6659. */
  6660. export enum AnimationKeyInterpolation {
  6661. /**
  6662. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6663. */
  6664. STEP = 1
  6665. }
  6666. }
  6667. declare module "babylonjs/Animations/animationRange" {
  6668. /**
  6669. * Represents the range of an animation
  6670. */
  6671. export class AnimationRange {
  6672. /**The name of the animation range**/
  6673. name: string;
  6674. /**The starting frame of the animation */
  6675. from: number;
  6676. /**The ending frame of the animation*/
  6677. to: number;
  6678. /**
  6679. * Initializes the range of an animation
  6680. * @param name The name of the animation range
  6681. * @param from The starting frame of the animation
  6682. * @param to The ending frame of the animation
  6683. */
  6684. constructor(
  6685. /**The name of the animation range**/
  6686. name: string,
  6687. /**The starting frame of the animation */
  6688. from: number,
  6689. /**The ending frame of the animation*/
  6690. to: number);
  6691. /**
  6692. * Makes a copy of the animation range
  6693. * @returns A copy of the animation range
  6694. */
  6695. clone(): AnimationRange;
  6696. }
  6697. }
  6698. declare module "babylonjs/Animations/animationEvent" {
  6699. /**
  6700. * Composed of a frame, and an action function
  6701. */
  6702. export class AnimationEvent {
  6703. /** The frame for which the event is triggered **/
  6704. frame: number;
  6705. /** The event to perform when triggered **/
  6706. action: (currentFrame: number) => void;
  6707. /** Specifies if the event should be triggered only once**/
  6708. onlyOnce?: boolean | undefined;
  6709. /**
  6710. * Specifies if the animation event is done
  6711. */
  6712. isDone: boolean;
  6713. /**
  6714. * Initializes the animation event
  6715. * @param frame The frame for which the event is triggered
  6716. * @param action The event to perform when triggered
  6717. * @param onlyOnce Specifies if the event should be triggered only once
  6718. */
  6719. constructor(
  6720. /** The frame for which the event is triggered **/
  6721. frame: number,
  6722. /** The event to perform when triggered **/
  6723. action: (currentFrame: number) => void,
  6724. /** Specifies if the event should be triggered only once**/
  6725. onlyOnce?: boolean | undefined);
  6726. /** @hidden */
  6727. _clone(): AnimationEvent;
  6728. }
  6729. }
  6730. declare module "babylonjs/Behaviors/behavior" {
  6731. import { Nullable } from "babylonjs/types";
  6732. /**
  6733. * Interface used to define a behavior
  6734. */
  6735. export interface Behavior<T> {
  6736. /** gets or sets behavior's name */
  6737. name: string;
  6738. /**
  6739. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6740. */
  6741. init(): void;
  6742. /**
  6743. * Called when the behavior is attached to a target
  6744. * @param target defines the target where the behavior is attached to
  6745. */
  6746. attach(target: T): void;
  6747. /**
  6748. * Called when the behavior is detached from its target
  6749. */
  6750. detach(): void;
  6751. }
  6752. /**
  6753. * Interface implemented by classes supporting behaviors
  6754. */
  6755. export interface IBehaviorAware<T> {
  6756. /**
  6757. * Attach a behavior
  6758. * @param behavior defines the behavior to attach
  6759. * @returns the current host
  6760. */
  6761. addBehavior(behavior: Behavior<T>): T;
  6762. /**
  6763. * Remove a behavior from the current object
  6764. * @param behavior defines the behavior to detach
  6765. * @returns the current host
  6766. */
  6767. removeBehavior(behavior: Behavior<T>): T;
  6768. /**
  6769. * Gets a behavior using its name to search
  6770. * @param name defines the name to search
  6771. * @returns the behavior or null if not found
  6772. */
  6773. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6774. }
  6775. }
  6776. declare module "babylonjs/Collisions/intersectionInfo" {
  6777. import { Nullable } from "babylonjs/types";
  6778. /**
  6779. * @hidden
  6780. */
  6781. export class IntersectionInfo {
  6782. bu: Nullable<number>;
  6783. bv: Nullable<number>;
  6784. distance: number;
  6785. faceId: number;
  6786. subMeshId: number;
  6787. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6788. }
  6789. }
  6790. declare module "babylonjs/Culling/boundingSphere" {
  6791. import { DeepImmutable } from "babylonjs/types";
  6792. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6793. /**
  6794. * Class used to store bounding sphere information
  6795. */
  6796. export class BoundingSphere {
  6797. /**
  6798. * Gets the center of the bounding sphere in local space
  6799. */
  6800. readonly center: Vector3;
  6801. /**
  6802. * Radius of the bounding sphere in local space
  6803. */
  6804. radius: number;
  6805. /**
  6806. * Gets the center of the bounding sphere in world space
  6807. */
  6808. readonly centerWorld: Vector3;
  6809. /**
  6810. * Radius of the bounding sphere in world space
  6811. */
  6812. radiusWorld: number;
  6813. /**
  6814. * Gets the minimum vector in local space
  6815. */
  6816. readonly minimum: Vector3;
  6817. /**
  6818. * Gets the maximum vector in local space
  6819. */
  6820. readonly maximum: Vector3;
  6821. private _worldMatrix;
  6822. private static readonly TmpVector3;
  6823. /**
  6824. * Creates a new bounding sphere
  6825. * @param min defines the minimum vector (in local space)
  6826. * @param max defines the maximum vector (in local space)
  6827. * @param worldMatrix defines the new world matrix
  6828. */
  6829. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6830. /**
  6831. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6832. * @param min defines the new minimum vector (in local space)
  6833. * @param max defines the new maximum vector (in local space)
  6834. * @param worldMatrix defines the new world matrix
  6835. */
  6836. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6837. /**
  6838. * Scale the current bounding sphere by applying a scale factor
  6839. * @param factor defines the scale factor to apply
  6840. * @returns the current bounding box
  6841. */
  6842. scale(factor: number): BoundingSphere;
  6843. /**
  6844. * Gets the world matrix of the bounding box
  6845. * @returns a matrix
  6846. */
  6847. getWorldMatrix(): DeepImmutable<Matrix>;
  6848. /** @hidden */
  6849. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6850. /**
  6851. * Tests if the bounding sphere is intersecting the frustum planes
  6852. * @param frustumPlanes defines the frustum planes to test
  6853. * @returns true if there is an intersection
  6854. */
  6855. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6856. /**
  6857. * Tests if the bounding sphere center is in between the frustum planes.
  6858. * Used for optimistic fast inclusion.
  6859. * @param frustumPlanes defines the frustum planes to test
  6860. * @returns true if the sphere center is in between the frustum planes
  6861. */
  6862. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6863. /**
  6864. * Tests if a point is inside the bounding sphere
  6865. * @param point defines the point to test
  6866. * @returns true if the point is inside the bounding sphere
  6867. */
  6868. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6869. /**
  6870. * Checks if two sphere intersct
  6871. * @param sphere0 sphere 0
  6872. * @param sphere1 sphere 1
  6873. * @returns true if the speres intersect
  6874. */
  6875. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6876. }
  6877. }
  6878. declare module "babylonjs/Culling/boundingBox" {
  6879. import { DeepImmutable } from "babylonjs/types";
  6880. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6881. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6882. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6883. /**
  6884. * Class used to store bounding box information
  6885. */
  6886. export class BoundingBox implements ICullable {
  6887. /**
  6888. * Gets the 8 vectors representing the bounding box in local space
  6889. */
  6890. readonly vectors: Vector3[];
  6891. /**
  6892. * Gets the center of the bounding box in local space
  6893. */
  6894. readonly center: Vector3;
  6895. /**
  6896. * Gets the center of the bounding box in world space
  6897. */
  6898. readonly centerWorld: Vector3;
  6899. /**
  6900. * Gets the extend size in local space
  6901. */
  6902. readonly extendSize: Vector3;
  6903. /**
  6904. * Gets the extend size in world space
  6905. */
  6906. readonly extendSizeWorld: Vector3;
  6907. /**
  6908. * Gets the OBB (object bounding box) directions
  6909. */
  6910. readonly directions: Vector3[];
  6911. /**
  6912. * Gets the 8 vectors representing the bounding box in world space
  6913. */
  6914. readonly vectorsWorld: Vector3[];
  6915. /**
  6916. * Gets the minimum vector in world space
  6917. */
  6918. readonly minimumWorld: Vector3;
  6919. /**
  6920. * Gets the maximum vector in world space
  6921. */
  6922. readonly maximumWorld: Vector3;
  6923. /**
  6924. * Gets the minimum vector in local space
  6925. */
  6926. readonly minimum: Vector3;
  6927. /**
  6928. * Gets the maximum vector in local space
  6929. */
  6930. readonly maximum: Vector3;
  6931. private _worldMatrix;
  6932. private static readonly TmpVector3;
  6933. /**
  6934. * @hidden
  6935. */
  6936. _tag: number;
  6937. /**
  6938. * Creates a new bounding box
  6939. * @param min defines the minimum vector (in local space)
  6940. * @param max defines the maximum vector (in local space)
  6941. * @param worldMatrix defines the new world matrix
  6942. */
  6943. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6944. /**
  6945. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6946. * @param min defines the new minimum vector (in local space)
  6947. * @param max defines the new maximum vector (in local space)
  6948. * @param worldMatrix defines the new world matrix
  6949. */
  6950. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6951. /**
  6952. * Scale the current bounding box by applying a scale factor
  6953. * @param factor defines the scale factor to apply
  6954. * @returns the current bounding box
  6955. */
  6956. scale(factor: number): BoundingBox;
  6957. /**
  6958. * Gets the world matrix of the bounding box
  6959. * @returns a matrix
  6960. */
  6961. getWorldMatrix(): DeepImmutable<Matrix>;
  6962. /** @hidden */
  6963. _update(world: DeepImmutable<Matrix>): void;
  6964. /**
  6965. * Tests if the bounding box is intersecting the frustum planes
  6966. * @param frustumPlanes defines the frustum planes to test
  6967. * @returns true if there is an intersection
  6968. */
  6969. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6970. /**
  6971. * Tests if the bounding box is entirely inside the frustum planes
  6972. * @param frustumPlanes defines the frustum planes to test
  6973. * @returns true if there is an inclusion
  6974. */
  6975. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6976. /**
  6977. * Tests if a point is inside the bounding box
  6978. * @param point defines the point to test
  6979. * @returns true if the point is inside the bounding box
  6980. */
  6981. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6982. /**
  6983. * Tests if the bounding box intersects with a bounding sphere
  6984. * @param sphere defines the sphere to test
  6985. * @returns true if there is an intersection
  6986. */
  6987. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6988. /**
  6989. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6990. * @param min defines the min vector to use
  6991. * @param max defines the max vector to use
  6992. * @returns true if there is an intersection
  6993. */
  6994. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6995. /**
  6996. * Tests if two bounding boxes are intersections
  6997. * @param box0 defines the first box to test
  6998. * @param box1 defines the second box to test
  6999. * @returns true if there is an intersection
  7000. */
  7001. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7002. /**
  7003. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7004. * @param minPoint defines the minimum vector of the bounding box
  7005. * @param maxPoint defines the maximum vector of the bounding box
  7006. * @param sphereCenter defines the sphere center
  7007. * @param sphereRadius defines the sphere radius
  7008. * @returns true if there is an intersection
  7009. */
  7010. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7011. /**
  7012. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7013. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7014. * @param frustumPlanes defines the frustum planes to test
  7015. * @return true if there is an inclusion
  7016. */
  7017. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7018. /**
  7019. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7020. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7021. * @param frustumPlanes defines the frustum planes to test
  7022. * @return true if there is an intersection
  7023. */
  7024. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7025. }
  7026. }
  7027. declare module "babylonjs/Collisions/collider" {
  7028. import { Nullable, IndicesArray } from "babylonjs/types";
  7029. import { Vector3, Plane } from "babylonjs/Maths/math";
  7030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7031. /** @hidden */
  7032. export class Collider {
  7033. /** Define if a collision was found */
  7034. collisionFound: boolean;
  7035. /**
  7036. * Define last intersection point in local space
  7037. */
  7038. intersectionPoint: Vector3;
  7039. /**
  7040. * Define last collided mesh
  7041. */
  7042. collidedMesh: Nullable<AbstractMesh>;
  7043. private _collisionPoint;
  7044. private _planeIntersectionPoint;
  7045. private _tempVector;
  7046. private _tempVector2;
  7047. private _tempVector3;
  7048. private _tempVector4;
  7049. private _edge;
  7050. private _baseToVertex;
  7051. private _destinationPoint;
  7052. private _slidePlaneNormal;
  7053. private _displacementVector;
  7054. /** @hidden */
  7055. _radius: Vector3;
  7056. /** @hidden */
  7057. _retry: number;
  7058. private _velocity;
  7059. private _basePoint;
  7060. private _epsilon;
  7061. /** @hidden */
  7062. _velocityWorldLength: number;
  7063. /** @hidden */
  7064. _basePointWorld: Vector3;
  7065. private _velocityWorld;
  7066. private _normalizedVelocity;
  7067. /** @hidden */
  7068. _initialVelocity: Vector3;
  7069. /** @hidden */
  7070. _initialPosition: Vector3;
  7071. private _nearestDistance;
  7072. private _collisionMask;
  7073. collisionMask: number;
  7074. /**
  7075. * Gets the plane normal used to compute the sliding response (in local space)
  7076. */
  7077. readonly slidePlaneNormal: Vector3;
  7078. /** @hidden */
  7079. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7080. /** @hidden */
  7081. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7082. /** @hidden */
  7083. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7084. /** @hidden */
  7085. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7086. /** @hidden */
  7087. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7088. /** @hidden */
  7089. _getResponse(pos: Vector3, vel: Vector3): void;
  7090. }
  7091. }
  7092. declare module "babylonjs/Culling/boundingInfo" {
  7093. import { DeepImmutable } from "babylonjs/types";
  7094. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7095. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7096. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7097. import { Collider } from "babylonjs/Collisions/collider";
  7098. /**
  7099. * Interface for cullable objects
  7100. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7101. */
  7102. export interface ICullable {
  7103. /**
  7104. * Checks if the object or part of the object is in the frustum
  7105. * @param frustumPlanes Camera near/planes
  7106. * @returns true if the object is in frustum otherwise false
  7107. */
  7108. isInFrustum(frustumPlanes: Plane[]): boolean;
  7109. /**
  7110. * Checks if a cullable object (mesh...) is in the camera frustum
  7111. * Unlike isInFrustum this cheks the full bounding box
  7112. * @param frustumPlanes Camera near/planes
  7113. * @returns true if the object is in frustum otherwise false
  7114. */
  7115. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7116. }
  7117. /**
  7118. * Info for a bounding data of a mesh
  7119. */
  7120. export class BoundingInfo implements ICullable {
  7121. /**
  7122. * Bounding box for the mesh
  7123. */
  7124. readonly boundingBox: BoundingBox;
  7125. /**
  7126. * Bounding sphere for the mesh
  7127. */
  7128. readonly boundingSphere: BoundingSphere;
  7129. private _isLocked;
  7130. private static readonly TmpVector3;
  7131. /**
  7132. * Constructs bounding info
  7133. * @param minimum min vector of the bounding box/sphere
  7134. * @param maximum max vector of the bounding box/sphere
  7135. * @param worldMatrix defines the new world matrix
  7136. */
  7137. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7138. /**
  7139. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7140. * @param min defines the new minimum vector (in local space)
  7141. * @param max defines the new maximum vector (in local space)
  7142. * @param worldMatrix defines the new world matrix
  7143. */
  7144. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7145. /**
  7146. * min vector of the bounding box/sphere
  7147. */
  7148. readonly minimum: Vector3;
  7149. /**
  7150. * max vector of the bounding box/sphere
  7151. */
  7152. readonly maximum: Vector3;
  7153. /**
  7154. * If the info is locked and won't be updated to avoid perf overhead
  7155. */
  7156. isLocked: boolean;
  7157. /**
  7158. * Updates the bounding sphere and box
  7159. * @param world world matrix to be used to update
  7160. */
  7161. update(world: DeepImmutable<Matrix>): void;
  7162. /**
  7163. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7164. * @param center New center of the bounding info
  7165. * @param extend New extend of the bounding info
  7166. * @returns the current bounding info
  7167. */
  7168. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7169. /**
  7170. * Scale the current bounding info by applying a scale factor
  7171. * @param factor defines the scale factor to apply
  7172. * @returns the current bounding info
  7173. */
  7174. scale(factor: number): BoundingInfo;
  7175. /**
  7176. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7177. * @param frustumPlanes defines the frustum to test
  7178. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7179. * @returns true if the bounding info is in the frustum planes
  7180. */
  7181. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7182. /**
  7183. * Gets the world distance between the min and max points of the bounding box
  7184. */
  7185. readonly diagonalLength: number;
  7186. /**
  7187. * Checks if a cullable object (mesh...) is in the camera frustum
  7188. * Unlike isInFrustum this cheks the full bounding box
  7189. * @param frustumPlanes Camera near/planes
  7190. * @returns true if the object is in frustum otherwise false
  7191. */
  7192. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7193. /** @hidden */
  7194. _checkCollision(collider: Collider): boolean;
  7195. /**
  7196. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7197. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7198. * @param point the point to check intersection with
  7199. * @returns if the point intersects
  7200. */
  7201. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7202. /**
  7203. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7204. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7205. * @param boundingInfo the bounding info to check intersection with
  7206. * @param precise if the intersection should be done using OBB
  7207. * @returns if the bounding info intersects
  7208. */
  7209. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7210. }
  7211. }
  7212. declare module "babylonjs/Misc/smartArray" {
  7213. /**
  7214. * Defines an array and its length.
  7215. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7216. */
  7217. export interface ISmartArrayLike<T> {
  7218. /**
  7219. * The data of the array.
  7220. */
  7221. data: Array<T>;
  7222. /**
  7223. * The active length of the array.
  7224. */
  7225. length: number;
  7226. }
  7227. /**
  7228. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7229. */
  7230. export class SmartArray<T> implements ISmartArrayLike<T> {
  7231. /**
  7232. * The full set of data from the array.
  7233. */
  7234. data: Array<T>;
  7235. /**
  7236. * The active length of the array.
  7237. */
  7238. length: number;
  7239. protected _id: number;
  7240. /**
  7241. * Instantiates a Smart Array.
  7242. * @param capacity defines the default capacity of the array.
  7243. */
  7244. constructor(capacity: number);
  7245. /**
  7246. * Pushes a value at the end of the active data.
  7247. * @param value defines the object to push in the array.
  7248. */
  7249. push(value: T): void;
  7250. /**
  7251. * Iterates over the active data and apply the lambda to them.
  7252. * @param func defines the action to apply on each value.
  7253. */
  7254. forEach(func: (content: T) => void): void;
  7255. /**
  7256. * Sorts the full sets of data.
  7257. * @param compareFn defines the comparison function to apply.
  7258. */
  7259. sort(compareFn: (a: T, b: T) => number): void;
  7260. /**
  7261. * Resets the active data to an empty array.
  7262. */
  7263. reset(): void;
  7264. /**
  7265. * Releases all the data from the array as well as the array.
  7266. */
  7267. dispose(): void;
  7268. /**
  7269. * Concats the active data with a given array.
  7270. * @param array defines the data to concatenate with.
  7271. */
  7272. concat(array: any): void;
  7273. /**
  7274. * Returns the position of a value in the active data.
  7275. * @param value defines the value to find the index for
  7276. * @returns the index if found in the active data otherwise -1
  7277. */
  7278. indexOf(value: T): number;
  7279. /**
  7280. * Returns whether an element is part of the active data.
  7281. * @param value defines the value to look for
  7282. * @returns true if found in the active data otherwise false
  7283. */
  7284. contains(value: T): boolean;
  7285. private static _GlobalId;
  7286. }
  7287. /**
  7288. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7289. * The data in this array can only be present once
  7290. */
  7291. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7292. private _duplicateId;
  7293. /**
  7294. * Pushes a value at the end of the active data.
  7295. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7296. * @param value defines the object to push in the array.
  7297. */
  7298. push(value: T): void;
  7299. /**
  7300. * Pushes a value at the end of the active data.
  7301. * If the data is already present, it won t be added again
  7302. * @param value defines the object to push in the array.
  7303. * @returns true if added false if it was already present
  7304. */
  7305. pushNoDuplicate(value: T): boolean;
  7306. /**
  7307. * Resets the active data to an empty array.
  7308. */
  7309. reset(): void;
  7310. /**
  7311. * Concats the active data with a given array.
  7312. * This ensures no dupplicate will be present in the result.
  7313. * @param array defines the data to concatenate with.
  7314. */
  7315. concatWithNoDuplicate(array: any): void;
  7316. }
  7317. }
  7318. declare module "babylonjs/Materials/multiMaterial" {
  7319. import { Nullable } from "babylonjs/types";
  7320. import { Scene } from "babylonjs/scene";
  7321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7322. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7323. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7324. import { Material } from "babylonjs/Materials/material";
  7325. /**
  7326. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7327. * separate meshes. This can be use to improve performances.
  7328. * @see http://doc.babylonjs.com/how_to/multi_materials
  7329. */
  7330. export class MultiMaterial extends Material {
  7331. private _subMaterials;
  7332. /**
  7333. * Gets or Sets the list of Materials used within the multi material.
  7334. * They need to be ordered according to the submeshes order in the associated mesh
  7335. */
  7336. subMaterials: Nullable<Material>[];
  7337. /**
  7338. * Function used to align with Node.getChildren()
  7339. * @returns the list of Materials used within the multi material
  7340. */
  7341. getChildren(): Nullable<Material>[];
  7342. /**
  7343. * Instantiates a new Multi Material
  7344. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7345. * separate meshes. This can be use to improve performances.
  7346. * @see http://doc.babylonjs.com/how_to/multi_materials
  7347. * @param name Define the name in the scene
  7348. * @param scene Define the scene the material belongs to
  7349. */
  7350. constructor(name: string, scene: Scene);
  7351. private _hookArray;
  7352. /**
  7353. * Get one of the submaterial by its index in the submaterials array
  7354. * @param index The index to look the sub material at
  7355. * @returns The Material if the index has been defined
  7356. */
  7357. getSubMaterial(index: number): Nullable<Material>;
  7358. /**
  7359. * Get the list of active textures for the whole sub materials list.
  7360. * @returns All the textures that will be used during the rendering
  7361. */
  7362. getActiveTextures(): BaseTexture[];
  7363. /**
  7364. * Gets the current class name of the material e.g. "MultiMaterial"
  7365. * Mainly use in serialization.
  7366. * @returns the class name
  7367. */
  7368. getClassName(): string;
  7369. /**
  7370. * Checks if the material is ready to render the requested sub mesh
  7371. * @param mesh Define the mesh the submesh belongs to
  7372. * @param subMesh Define the sub mesh to look readyness for
  7373. * @param useInstances Define whether or not the material is used with instances
  7374. * @returns true if ready, otherwise false
  7375. */
  7376. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7377. /**
  7378. * Clones the current material and its related sub materials
  7379. * @param name Define the name of the newly cloned material
  7380. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7381. * @returns the cloned material
  7382. */
  7383. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7384. /**
  7385. * Serializes the materials into a JSON representation.
  7386. * @returns the JSON representation
  7387. */
  7388. serialize(): any;
  7389. /**
  7390. * Dispose the material and release its associated resources
  7391. * @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)
  7392. * @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)
  7393. * @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)
  7394. */
  7395. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7396. /**
  7397. * Creates a MultiMaterial from parsed MultiMaterial data.
  7398. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7399. * @param scene defines the hosting scene
  7400. * @returns a new MultiMaterial
  7401. */
  7402. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7403. }
  7404. }
  7405. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7406. /**
  7407. * Class used to represent data loading progression
  7408. */
  7409. export class SceneLoaderFlags {
  7410. private static _ForceFullSceneLoadingForIncremental;
  7411. private static _ShowLoadingScreen;
  7412. private static _CleanBoneMatrixWeights;
  7413. private static _loggingLevel;
  7414. /**
  7415. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7416. */
  7417. static ForceFullSceneLoadingForIncremental: boolean;
  7418. /**
  7419. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7420. */
  7421. static ShowLoadingScreen: boolean;
  7422. /**
  7423. * Defines the current logging level (while loading the scene)
  7424. * @ignorenaming
  7425. */
  7426. static loggingLevel: number;
  7427. /**
  7428. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7429. */
  7430. static CleanBoneMatrixWeights: boolean;
  7431. }
  7432. }
  7433. declare module "babylonjs/Meshes/transformNode" {
  7434. import { DeepImmutable } from "babylonjs/types";
  7435. import { Observable } from "babylonjs/Misc/observable";
  7436. import { Nullable } from "babylonjs/types";
  7437. import { Camera } from "babylonjs/Cameras/camera";
  7438. import { Scene } from "babylonjs/scene";
  7439. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7440. import { Node } from "babylonjs/node";
  7441. import { Bone } from "babylonjs/Bones/bone";
  7442. /**
  7443. * 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.
  7444. * @see https://doc.babylonjs.com/how_to/transformnode
  7445. */
  7446. export class TransformNode extends Node {
  7447. /**
  7448. * Object will not rotate to face the camera
  7449. */
  7450. static BILLBOARDMODE_NONE: number;
  7451. /**
  7452. * Object will rotate to face the camera but only on the x axis
  7453. */
  7454. static BILLBOARDMODE_X: number;
  7455. /**
  7456. * Object will rotate to face the camera but only on the y axis
  7457. */
  7458. static BILLBOARDMODE_Y: number;
  7459. /**
  7460. * Object will rotate to face the camera but only on the z axis
  7461. */
  7462. static BILLBOARDMODE_Z: number;
  7463. /**
  7464. * Object will rotate to face the camera
  7465. */
  7466. static BILLBOARDMODE_ALL: number;
  7467. private _forward;
  7468. private _forwardInverted;
  7469. private _up;
  7470. private _right;
  7471. private _rightInverted;
  7472. private _position;
  7473. private _rotation;
  7474. private _rotationQuaternion;
  7475. protected _scaling: Vector3;
  7476. protected _isDirty: boolean;
  7477. private _transformToBoneReferal;
  7478. /**
  7479. * Set the billboard mode. Default is 0.
  7480. *
  7481. * | Value | Type | Description |
  7482. * | --- | --- | --- |
  7483. * | 0 | BILLBOARDMODE_NONE | |
  7484. * | 1 | BILLBOARDMODE_X | |
  7485. * | 2 | BILLBOARDMODE_Y | |
  7486. * | 4 | BILLBOARDMODE_Z | |
  7487. * | 7 | BILLBOARDMODE_ALL | |
  7488. *
  7489. */
  7490. billboardMode: number;
  7491. /**
  7492. * 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
  7493. */
  7494. scalingDeterminant: number;
  7495. /**
  7496. * Sets the distance of the object to max, often used by skybox
  7497. */
  7498. infiniteDistance: boolean;
  7499. /**
  7500. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7501. * By default the system will update normals to compensate
  7502. */
  7503. ignoreNonUniformScaling: boolean;
  7504. /** @hidden */
  7505. _poseMatrix: Matrix;
  7506. /** @hidden */
  7507. _localMatrix: Matrix;
  7508. private _absolutePosition;
  7509. private _pivotMatrix;
  7510. private _pivotMatrixInverse;
  7511. protected _postMultiplyPivotMatrix: boolean;
  7512. protected _isWorldMatrixFrozen: boolean;
  7513. /** @hidden */
  7514. _indexInSceneTransformNodesArray: number;
  7515. /**
  7516. * An event triggered after the world matrix is updated
  7517. */
  7518. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7519. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7520. /**
  7521. * Gets a string identifying the name of the class
  7522. * @returns "TransformNode" string
  7523. */
  7524. getClassName(): string;
  7525. /**
  7526. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7527. */
  7528. position: Vector3;
  7529. /**
  7530. * 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)).
  7531. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7532. */
  7533. rotation: Vector3;
  7534. /**
  7535. * 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)).
  7536. */
  7537. scaling: Vector3;
  7538. /**
  7539. * 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).
  7540. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7541. */
  7542. rotationQuaternion: Nullable<Quaternion>;
  7543. /**
  7544. * The forward direction of that transform in world space.
  7545. */
  7546. readonly forward: Vector3;
  7547. /**
  7548. * The up direction of that transform in world space.
  7549. */
  7550. readonly up: Vector3;
  7551. /**
  7552. * The right direction of that transform in world space.
  7553. */
  7554. readonly right: Vector3;
  7555. /**
  7556. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7557. * @param matrix the matrix to copy the pose from
  7558. * @returns this TransformNode.
  7559. */
  7560. updatePoseMatrix(matrix: Matrix): TransformNode;
  7561. /**
  7562. * Returns the mesh Pose matrix.
  7563. * @returns the pose matrix
  7564. */
  7565. getPoseMatrix(): Matrix;
  7566. /** @hidden */
  7567. _isSynchronized(): boolean;
  7568. /** @hidden */
  7569. _initCache(): void;
  7570. /**
  7571. * Flag the transform node as dirty (Forcing it to update everything)
  7572. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7573. * @returns this transform node
  7574. */
  7575. markAsDirty(property: string): TransformNode;
  7576. /**
  7577. * Returns the current mesh absolute position.
  7578. * Returns a Vector3.
  7579. */
  7580. readonly absolutePosition: Vector3;
  7581. /**
  7582. * Sets a new matrix to apply before all other transformation
  7583. * @param matrix defines the transform matrix
  7584. * @returns the current TransformNode
  7585. */
  7586. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7587. /**
  7588. * Sets a new pivot matrix to the current node
  7589. * @param matrix defines the new pivot matrix to use
  7590. * @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
  7591. * @returns the current TransformNode
  7592. */
  7593. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7594. /**
  7595. * Returns the mesh pivot matrix.
  7596. * Default : Identity.
  7597. * @returns the matrix
  7598. */
  7599. getPivotMatrix(): Matrix;
  7600. /**
  7601. * Prevents the World matrix to be computed any longer.
  7602. * @returns the TransformNode.
  7603. */
  7604. freezeWorldMatrix(): TransformNode;
  7605. /**
  7606. * Allows back the World matrix computation.
  7607. * @returns the TransformNode.
  7608. */
  7609. unfreezeWorldMatrix(): this;
  7610. /**
  7611. * True if the World matrix has been frozen.
  7612. */
  7613. readonly isWorldMatrixFrozen: boolean;
  7614. /**
  7615. * Retuns the mesh absolute position in the World.
  7616. * @returns a Vector3.
  7617. */
  7618. getAbsolutePosition(): Vector3;
  7619. /**
  7620. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7621. * @param absolutePosition the absolute position to set
  7622. * @returns the TransformNode.
  7623. */
  7624. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7625. /**
  7626. * Sets the mesh position in its local space.
  7627. * @param vector3 the position to set in localspace
  7628. * @returns the TransformNode.
  7629. */
  7630. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7631. /**
  7632. * Returns the mesh position in the local space from the current World matrix values.
  7633. * @returns a new Vector3.
  7634. */
  7635. getPositionExpressedInLocalSpace(): Vector3;
  7636. /**
  7637. * Translates the mesh along the passed Vector3 in its local space.
  7638. * @param vector3 the distance to translate in localspace
  7639. * @returns the TransformNode.
  7640. */
  7641. locallyTranslate(vector3: Vector3): TransformNode;
  7642. private static _lookAtVectorCache;
  7643. /**
  7644. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7645. * @param targetPoint the position (must be in same space as current mesh) to look at
  7646. * @param yawCor optional yaw (y-axis) correction in radians
  7647. * @param pitchCor optional pitch (x-axis) correction in radians
  7648. * @param rollCor optional roll (z-axis) correction in radians
  7649. * @param space the choosen space of the target
  7650. * @returns the TransformNode.
  7651. */
  7652. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7653. /**
  7654. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7655. * This Vector3 is expressed in the World space.
  7656. * @param localAxis axis to rotate
  7657. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7658. */
  7659. getDirection(localAxis: Vector3): Vector3;
  7660. /**
  7661. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7662. * localAxis is expressed in the mesh local space.
  7663. * result is computed in the Wordl space from the mesh World matrix.
  7664. * @param localAxis axis to rotate
  7665. * @param result the resulting transformnode
  7666. * @returns this TransformNode.
  7667. */
  7668. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7669. /**
  7670. * Sets this transform node rotation to the given local axis.
  7671. * @param localAxis the axis in local space
  7672. * @param yawCor optional yaw (y-axis) correction in radians
  7673. * @param pitchCor optional pitch (x-axis) correction in radians
  7674. * @param rollCor optional roll (z-axis) correction in radians
  7675. * @returns this TransformNode
  7676. */
  7677. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7678. /**
  7679. * Sets a new pivot point to the current node
  7680. * @param point defines the new pivot point to use
  7681. * @param space defines if the point is in world or local space (local by default)
  7682. * @returns the current TransformNode
  7683. */
  7684. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7685. /**
  7686. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7687. * @returns the pivot point
  7688. */
  7689. getPivotPoint(): Vector3;
  7690. /**
  7691. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7692. * @param result the vector3 to store the result
  7693. * @returns this TransformNode.
  7694. */
  7695. getPivotPointToRef(result: Vector3): TransformNode;
  7696. /**
  7697. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7698. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7699. */
  7700. getAbsolutePivotPoint(): Vector3;
  7701. /**
  7702. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7703. * @param result vector3 to store the result
  7704. * @returns this TransformNode.
  7705. */
  7706. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7707. /**
  7708. * Defines the passed node as the parent of the current node.
  7709. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7710. * @param node the node ot set as the parent
  7711. * @returns this TransformNode.
  7712. */
  7713. setParent(node: Nullable<Node>): TransformNode;
  7714. private _nonUniformScaling;
  7715. /**
  7716. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7717. */
  7718. readonly nonUniformScaling: boolean;
  7719. /** @hidden */
  7720. _updateNonUniformScalingState(value: boolean): boolean;
  7721. /**
  7722. * Attach the current TransformNode to another TransformNode associated with a bone
  7723. * @param bone Bone affecting the TransformNode
  7724. * @param affectedTransformNode TransformNode associated with the bone
  7725. * @returns this object
  7726. */
  7727. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7728. /**
  7729. * Detach the transform node if its associated with a bone
  7730. * @returns this object
  7731. */
  7732. detachFromBone(): TransformNode;
  7733. private static _rotationAxisCache;
  7734. /**
  7735. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7736. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7737. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7738. * The passed axis is also normalized.
  7739. * @param axis the axis to rotate around
  7740. * @param amount the amount to rotate in radians
  7741. * @param space Space to rotate in (Default: local)
  7742. * @returns the TransformNode.
  7743. */
  7744. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7745. /**
  7746. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7747. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7748. * The passed axis is also normalized. .
  7749. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7750. * @param point the point to rotate around
  7751. * @param axis the axis to rotate around
  7752. * @param amount the amount to rotate in radians
  7753. * @returns the TransformNode
  7754. */
  7755. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7756. /**
  7757. * Translates the mesh along the axis vector for the passed distance in the given space.
  7758. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7759. * @param axis the axis to translate in
  7760. * @param distance the distance to translate
  7761. * @param space Space to rotate in (Default: local)
  7762. * @returns the TransformNode.
  7763. */
  7764. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7765. /**
  7766. * Adds a rotation step to the mesh current rotation.
  7767. * x, y, z are Euler angles expressed in radians.
  7768. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7769. * This means this rotation is made in the mesh local space only.
  7770. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7771. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7772. * ```javascript
  7773. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7774. * ```
  7775. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7776. * 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.
  7777. * @param x Rotation to add
  7778. * @param y Rotation to add
  7779. * @param z Rotation to add
  7780. * @returns the TransformNode.
  7781. */
  7782. addRotation(x: number, y: number, z: number): TransformNode;
  7783. /**
  7784. * Computes the world matrix of the node
  7785. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7786. * @returns the world matrix
  7787. */
  7788. computeWorldMatrix(force?: boolean): Matrix;
  7789. protected _afterComputeWorldMatrix(): void;
  7790. /**
  7791. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7792. * @param func callback function to add
  7793. *
  7794. * @returns the TransformNode.
  7795. */
  7796. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7797. /**
  7798. * Removes a registered callback function.
  7799. * @param func callback function to remove
  7800. * @returns the TransformNode.
  7801. */
  7802. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7803. /**
  7804. * Gets the position of the current mesh in camera space
  7805. * @param camera defines the camera to use
  7806. * @returns a position
  7807. */
  7808. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7809. /**
  7810. * Returns the distance from the mesh to the active camera
  7811. * @param camera defines the camera to use
  7812. * @returns the distance
  7813. */
  7814. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7815. /**
  7816. * Clone the current transform node
  7817. * @param name Name of the new clone
  7818. * @param newParent New parent for the clone
  7819. * @param doNotCloneChildren Do not clone children hierarchy
  7820. * @returns the new transform node
  7821. */
  7822. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7823. /**
  7824. * Serializes the objects information.
  7825. * @param currentSerializationObject defines the object to serialize in
  7826. * @returns the serialized object
  7827. */
  7828. serialize(currentSerializationObject?: any): any;
  7829. /**
  7830. * Returns a new TransformNode object parsed from the source provided.
  7831. * @param parsedTransformNode is the source.
  7832. * @param scene the scne the object belongs to
  7833. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7834. * @returns a new TransformNode object parsed from the source provided.
  7835. */
  7836. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7837. /**
  7838. * Get all child-transformNodes of this node
  7839. * @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
  7840. * @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
  7841. * @returns an array of TransformNode
  7842. */
  7843. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7844. /**
  7845. * Releases resources associated with this transform node.
  7846. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7847. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7848. */
  7849. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7850. }
  7851. }
  7852. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7853. /**
  7854. * Class used to override all child animations of a given target
  7855. */
  7856. export class AnimationPropertiesOverride {
  7857. /**
  7858. * Gets or sets a value indicating if animation blending must be used
  7859. */
  7860. enableBlending: boolean;
  7861. /**
  7862. * Gets or sets the blending speed to use when enableBlending is true
  7863. */
  7864. blendingSpeed: number;
  7865. /**
  7866. * Gets or sets the default loop mode to use
  7867. */
  7868. loopMode: number;
  7869. }
  7870. }
  7871. declare module "babylonjs/Bones/bone" {
  7872. import { Skeleton } from "babylonjs/Bones/skeleton";
  7873. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7874. import { Nullable } from "babylonjs/types";
  7875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7876. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7877. import { Node } from "babylonjs/node";
  7878. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7879. /**
  7880. * Class used to store bone information
  7881. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7882. */
  7883. export class Bone extends Node {
  7884. /**
  7885. * defines the bone name
  7886. */
  7887. name: string;
  7888. private static _tmpVecs;
  7889. private static _tmpQuat;
  7890. private static _tmpMats;
  7891. /**
  7892. * Gets the list of child bones
  7893. */
  7894. children: Bone[];
  7895. /** Gets the animations associated with this bone */
  7896. animations: import("babylonjs/Animations/animation").Animation[];
  7897. /**
  7898. * Gets or sets bone length
  7899. */
  7900. length: number;
  7901. /**
  7902. * @hidden Internal only
  7903. * Set this value to map this bone to a different index in the transform matrices
  7904. * Set this value to -1 to exclude the bone from the transform matrices
  7905. */
  7906. _index: Nullable<number>;
  7907. private _skeleton;
  7908. private _localMatrix;
  7909. private _restPose;
  7910. private _baseMatrix;
  7911. private _absoluteTransform;
  7912. private _invertedAbsoluteTransform;
  7913. private _parent;
  7914. private _scalingDeterminant;
  7915. private _worldTransform;
  7916. private _localScaling;
  7917. private _localRotation;
  7918. private _localPosition;
  7919. private _needToDecompose;
  7920. private _needToCompose;
  7921. /** @hidden */
  7922. _linkedTransformNode: Nullable<TransformNode>;
  7923. /** @hidden */
  7924. /** @hidden */
  7925. _matrix: Matrix;
  7926. /**
  7927. * Create a new bone
  7928. * @param name defines the bone name
  7929. * @param skeleton defines the parent skeleton
  7930. * @param parentBone defines the parent (can be null if the bone is the root)
  7931. * @param localMatrix defines the local matrix
  7932. * @param restPose defines the rest pose matrix
  7933. * @param baseMatrix defines the base matrix
  7934. * @param index defines index of the bone in the hiearchy
  7935. */
  7936. constructor(
  7937. /**
  7938. * defines the bone name
  7939. */
  7940. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7941. /**
  7942. * Gets the current object class name.
  7943. * @return the class name
  7944. */
  7945. getClassName(): string;
  7946. /**
  7947. * Gets the parent skeleton
  7948. * @returns a skeleton
  7949. */
  7950. getSkeleton(): Skeleton;
  7951. /**
  7952. * Gets parent bone
  7953. * @returns a bone or null if the bone is the root of the bone hierarchy
  7954. */
  7955. getParent(): Nullable<Bone>;
  7956. /**
  7957. * Returns an array containing the root bones
  7958. * @returns an array containing the root bones
  7959. */
  7960. getChildren(): Array<Bone>;
  7961. /**
  7962. * Sets the parent bone
  7963. * @param parent defines the parent (can be null if the bone is the root)
  7964. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7965. */
  7966. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7967. /**
  7968. * Gets the local matrix
  7969. * @returns a matrix
  7970. */
  7971. getLocalMatrix(): Matrix;
  7972. /**
  7973. * Gets the base matrix (initial matrix which remains unchanged)
  7974. * @returns a matrix
  7975. */
  7976. getBaseMatrix(): Matrix;
  7977. /**
  7978. * Gets the rest pose matrix
  7979. * @returns a matrix
  7980. */
  7981. getRestPose(): Matrix;
  7982. /**
  7983. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7984. */
  7985. getWorldMatrix(): Matrix;
  7986. /**
  7987. * Sets the local matrix to rest pose matrix
  7988. */
  7989. returnToRest(): void;
  7990. /**
  7991. * Gets the inverse of the absolute transform matrix.
  7992. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7993. * @returns a matrix
  7994. */
  7995. getInvertedAbsoluteTransform(): Matrix;
  7996. /**
  7997. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7998. * @returns a matrix
  7999. */
  8000. getAbsoluteTransform(): Matrix;
  8001. /**
  8002. * Links with the given transform node.
  8003. * The local matrix of this bone is copied from the transform node every frame.
  8004. * @param transformNode defines the transform node to link to
  8005. */
  8006. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8007. /** Gets or sets current position (in local space) */
  8008. position: Vector3;
  8009. /** Gets or sets current rotation (in local space) */
  8010. rotation: Vector3;
  8011. /** Gets or sets current rotation quaternion (in local space) */
  8012. rotationQuaternion: Quaternion;
  8013. /** Gets or sets current scaling (in local space) */
  8014. scaling: Vector3;
  8015. /**
  8016. * Gets the animation properties override
  8017. */
  8018. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8019. private _decompose;
  8020. private _compose;
  8021. /**
  8022. * Update the base and local matrices
  8023. * @param matrix defines the new base or local matrix
  8024. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8025. * @param updateLocalMatrix defines if the local matrix should be updated
  8026. */
  8027. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8028. /** @hidden */
  8029. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8030. /**
  8031. * Flag the bone as dirty (Forcing it to update everything)
  8032. */
  8033. markAsDirty(): void;
  8034. private _markAsDirtyAndCompose;
  8035. private _markAsDirtyAndDecompose;
  8036. /**
  8037. * Translate the bone in local or world space
  8038. * @param vec The amount to translate the bone
  8039. * @param space The space that the translation is in
  8040. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8041. */
  8042. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8043. /**
  8044. * Set the postion of the bone in local or world space
  8045. * @param position The position to set the bone
  8046. * @param space The space that the position is in
  8047. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8048. */
  8049. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8050. /**
  8051. * Set the absolute position of the bone (world space)
  8052. * @param position The position to set the bone
  8053. * @param mesh The mesh that this bone is attached to
  8054. */
  8055. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8056. /**
  8057. * Scale the bone on the x, y and z axes (in local space)
  8058. * @param x The amount to scale the bone on the x axis
  8059. * @param y The amount to scale the bone on the y axis
  8060. * @param z The amount to scale the bone on the z axis
  8061. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8062. */
  8063. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8064. /**
  8065. * Set the bone scaling in local space
  8066. * @param scale defines the scaling vector
  8067. */
  8068. setScale(scale: Vector3): void;
  8069. /**
  8070. * Gets the current scaling in local space
  8071. * @returns the current scaling vector
  8072. */
  8073. getScale(): Vector3;
  8074. /**
  8075. * Gets the current scaling in local space and stores it in a target vector
  8076. * @param result defines the target vector
  8077. */
  8078. getScaleToRef(result: Vector3): void;
  8079. /**
  8080. * Set the yaw, pitch, and roll of the bone in local or world space
  8081. * @param yaw The rotation of the bone on the y axis
  8082. * @param pitch The rotation of the bone on the x axis
  8083. * @param roll The rotation of the bone on the z axis
  8084. * @param space The space that the axes of rotation are in
  8085. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8086. */
  8087. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8088. /**
  8089. * Add a rotation to the bone on an axis in local or world space
  8090. * @param axis The axis to rotate the bone on
  8091. * @param amount The amount to rotate the bone
  8092. * @param space The space that the axis is in
  8093. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8094. */
  8095. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8096. /**
  8097. * Set the rotation of the bone to a particular axis angle in local or world space
  8098. * @param axis The axis to rotate the bone on
  8099. * @param angle The angle that the bone should be rotated to
  8100. * @param space The space that the axis is in
  8101. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8102. */
  8103. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8104. /**
  8105. * Set the euler rotation of the bone in local of world space
  8106. * @param rotation The euler rotation that the bone should be set to
  8107. * @param space The space that the rotation is in
  8108. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8109. */
  8110. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8111. /**
  8112. * Set the quaternion rotation of the bone in local of world space
  8113. * @param quat The quaternion rotation that the bone should be set to
  8114. * @param space The space that the rotation is in
  8115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8116. */
  8117. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8118. /**
  8119. * Set the rotation matrix of the bone in local of world space
  8120. * @param rotMat The rotation matrix that the bone should be set to
  8121. * @param space The space that the rotation is in
  8122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8123. */
  8124. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8125. private _rotateWithMatrix;
  8126. private _getNegativeRotationToRef;
  8127. /**
  8128. * Get the position of the bone in local or world space
  8129. * @param space The space that the returned position is in
  8130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8131. * @returns The position of the bone
  8132. */
  8133. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8134. /**
  8135. * Copy the position of the bone to a vector3 in local or world space
  8136. * @param space The space that the returned position is in
  8137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8138. * @param result The vector3 to copy the position to
  8139. */
  8140. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8141. /**
  8142. * Get the absolute position of the bone (world space)
  8143. * @param mesh The mesh that this bone is attached to
  8144. * @returns The absolute position of the bone
  8145. */
  8146. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8147. /**
  8148. * Copy the absolute position of the bone (world space) to the result param
  8149. * @param mesh The mesh that this bone is attached to
  8150. * @param result The vector3 to copy the absolute position to
  8151. */
  8152. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8153. /**
  8154. * Compute the absolute transforms of this bone and its children
  8155. */
  8156. computeAbsoluteTransforms(): void;
  8157. /**
  8158. * Get the world direction from an axis that is in the local space of the bone
  8159. * @param localAxis The local direction that is used to compute the world direction
  8160. * @param mesh The mesh that this bone is attached to
  8161. * @returns The world direction
  8162. */
  8163. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8164. /**
  8165. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8166. * @param localAxis The local direction that is used to compute the world direction
  8167. * @param mesh The mesh that this bone is attached to
  8168. * @param result The vector3 that the world direction will be copied to
  8169. */
  8170. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8171. /**
  8172. * Get the euler rotation of the bone in local or world space
  8173. * @param space The space that the rotation should be in
  8174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8175. * @returns The euler rotation
  8176. */
  8177. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8178. /**
  8179. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8180. * @param space The space that the rotation should be in
  8181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8182. * @param result The vector3 that the rotation should be copied to
  8183. */
  8184. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8185. /**
  8186. * Get the quaternion rotation of the bone in either local or world space
  8187. * @param space The space that the rotation should be in
  8188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8189. * @returns The quaternion rotation
  8190. */
  8191. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8192. /**
  8193. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8194. * @param space The space that the rotation should be in
  8195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8196. * @param result The quaternion that the rotation should be copied to
  8197. */
  8198. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8199. /**
  8200. * Get the rotation matrix of the bone in local or world space
  8201. * @param space The space that the rotation should be in
  8202. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8203. * @returns The rotation matrix
  8204. */
  8205. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8206. /**
  8207. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8208. * @param space The space that the rotation should be in
  8209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8210. * @param result The quaternion that the rotation should be copied to
  8211. */
  8212. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8213. /**
  8214. * Get the world position of a point that is in the local space of the bone
  8215. * @param position The local position
  8216. * @param mesh The mesh that this bone is attached to
  8217. * @returns The world position
  8218. */
  8219. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8220. /**
  8221. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8222. * @param position The local position
  8223. * @param mesh The mesh that this bone is attached to
  8224. * @param result The vector3 that the world position should be copied to
  8225. */
  8226. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8227. /**
  8228. * Get the local position of a point that is in world space
  8229. * @param position The world position
  8230. * @param mesh The mesh that this bone is attached to
  8231. * @returns The local position
  8232. */
  8233. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8234. /**
  8235. * Get the local position of a point that is in world space and copy it to the result param
  8236. * @param position The world position
  8237. * @param mesh The mesh that this bone is attached to
  8238. * @param result The vector3 that the local position should be copied to
  8239. */
  8240. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8241. }
  8242. }
  8243. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8244. import { Nullable } from "babylonjs/types";
  8245. import { Scene } from "babylonjs/scene";
  8246. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8248. /**
  8249. * Class for creating a cube texture
  8250. */
  8251. export class CubeTexture extends BaseTexture {
  8252. private _delayedOnLoad;
  8253. /**
  8254. * The url of the texture
  8255. */
  8256. url: string;
  8257. /**
  8258. * Gets or sets the center of the bounding box associated with the cube texture.
  8259. * It must define where the camera used to render the texture was set
  8260. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8261. */
  8262. boundingBoxPosition: Vector3;
  8263. private _boundingBoxSize;
  8264. /**
  8265. * Gets or sets the size of the bounding box associated with the cube texture
  8266. * When defined, the cubemap will switch to local mode
  8267. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8268. * @example https://www.babylonjs-playground.com/#RNASML
  8269. */
  8270. /**
  8271. * Returns the bounding box size
  8272. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8273. */
  8274. boundingBoxSize: Vector3;
  8275. protected _rotationY: number;
  8276. /**
  8277. * Sets texture matrix rotation angle around Y axis in radians.
  8278. */
  8279. /**
  8280. * Gets texture matrix rotation angle around Y axis radians.
  8281. */
  8282. rotationY: number;
  8283. /**
  8284. * Are mip maps generated for this texture or not.
  8285. */
  8286. readonly noMipmap: boolean;
  8287. private _noMipmap;
  8288. private _files;
  8289. private _extensions;
  8290. private _textureMatrix;
  8291. private _format;
  8292. private _createPolynomials;
  8293. /** @hidden */
  8294. _prefiltered: boolean;
  8295. /**
  8296. * Creates a cube texture from an array of image urls
  8297. * @param files defines an array of image urls
  8298. * @param scene defines the hosting scene
  8299. * @param noMipmap specifies if mip maps are not used
  8300. * @returns a cube texture
  8301. */
  8302. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8303. /**
  8304. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8305. * @param url defines the url of the prefiltered texture
  8306. * @param scene defines the scene the texture is attached to
  8307. * @param forcedExtension defines the extension of the file if different from the url
  8308. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8309. * @return the prefiltered texture
  8310. */
  8311. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8312. /**
  8313. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8314. * as prefiltered data.
  8315. * @param rootUrl defines the url of the texture or the root name of the six images
  8316. * @param scene defines the scene the texture is attached to
  8317. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8318. * @param noMipmap defines if mipmaps should be created or not
  8319. * @param files defines the six files to load for the different faces
  8320. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8321. * @param onError defines a callback triggered in case of error during load
  8322. * @param format defines the internal format to use for the texture once loaded
  8323. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8324. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8325. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8326. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8327. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8328. * @return the cube texture
  8329. */
  8330. 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);
  8331. /**
  8332. * Get the current class name of the texture useful for serialization or dynamic coding.
  8333. * @returns "CubeTexture"
  8334. */
  8335. getClassName(): string;
  8336. /**
  8337. * Update the url (and optional buffer) of this texture if url was null during construction.
  8338. * @param url the url of the texture
  8339. * @param forcedExtension defines the extension to use
  8340. * @param onLoad callback called when the texture is loaded (defaults to null)
  8341. */
  8342. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8343. /**
  8344. * Delays loading of the cube texture
  8345. * @param forcedExtension defines the extension to use
  8346. */
  8347. delayLoad(forcedExtension?: string): void;
  8348. /**
  8349. * Returns the reflection texture matrix
  8350. * @returns the reflection texture matrix
  8351. */
  8352. getReflectionTextureMatrix(): Matrix;
  8353. /**
  8354. * Sets the reflection texture matrix
  8355. * @param value Reflection texture matrix
  8356. */
  8357. setReflectionTextureMatrix(value: Matrix): void;
  8358. /**
  8359. * Parses text to create a cube texture
  8360. * @param parsedTexture define the serialized text to read from
  8361. * @param scene defines the hosting scene
  8362. * @param rootUrl defines the root url of the cube texture
  8363. * @returns a cube texture
  8364. */
  8365. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8366. /**
  8367. * Makes a clone, or deep copy, of the cube texture
  8368. * @returns a new cube texture
  8369. */
  8370. clone(): CubeTexture;
  8371. }
  8372. }
  8373. declare module "babylonjs/Shaders/postprocess.vertex" {
  8374. /** @hidden */
  8375. export var postprocessVertexShader: {
  8376. name: string;
  8377. shader: string;
  8378. };
  8379. }
  8380. declare module "babylonjs/Cameras/targetCamera" {
  8381. import { Nullable } from "babylonjs/types";
  8382. import { Camera } from "babylonjs/Cameras/camera";
  8383. import { Scene } from "babylonjs/scene";
  8384. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8385. /**
  8386. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8387. * This is the base of the follow, arc rotate cameras and Free camera
  8388. * @see http://doc.babylonjs.com/features/cameras
  8389. */
  8390. export class TargetCamera extends Camera {
  8391. private static _RigCamTransformMatrix;
  8392. private static _TargetTransformMatrix;
  8393. private static _TargetFocalPoint;
  8394. /**
  8395. * Define the current direction the camera is moving to
  8396. */
  8397. cameraDirection: Vector3;
  8398. /**
  8399. * Define the current rotation the camera is rotating to
  8400. */
  8401. cameraRotation: Vector2;
  8402. /**
  8403. * When set, the up vector of the camera will be updated by the rotation of the camera
  8404. */
  8405. updateUpVectorFromRotation: boolean;
  8406. private _tmpQuaternion;
  8407. /**
  8408. * Define the current rotation of the camera
  8409. */
  8410. rotation: Vector3;
  8411. /**
  8412. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8413. */
  8414. rotationQuaternion: Quaternion;
  8415. /**
  8416. * Define the current speed of the camera
  8417. */
  8418. speed: number;
  8419. /**
  8420. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8421. * around all axis.
  8422. */
  8423. noRotationConstraint: boolean;
  8424. /**
  8425. * Define the current target of the camera as an object or a position.
  8426. */
  8427. lockedTarget: any;
  8428. /** @hidden */
  8429. _currentTarget: Vector3;
  8430. /** @hidden */
  8431. _initialFocalDistance: number;
  8432. /** @hidden */
  8433. _viewMatrix: Matrix;
  8434. /** @hidden */
  8435. _camMatrix: Matrix;
  8436. /** @hidden */
  8437. _cameraTransformMatrix: Matrix;
  8438. /** @hidden */
  8439. _cameraRotationMatrix: Matrix;
  8440. /** @hidden */
  8441. _referencePoint: Vector3;
  8442. /** @hidden */
  8443. _transformedReferencePoint: Vector3;
  8444. protected _globalCurrentTarget: Vector3;
  8445. protected _globalCurrentUpVector: Vector3;
  8446. /** @hidden */
  8447. _reset: () => void;
  8448. private _defaultUp;
  8449. /**
  8450. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8451. * This is the base of the follow, arc rotate cameras and Free camera
  8452. * @see http://doc.babylonjs.com/features/cameras
  8453. * @param name Defines the name of the camera in the scene
  8454. * @param position Defines the start position of the camera in the scene
  8455. * @param scene Defines the scene the camera belongs to
  8456. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8457. */
  8458. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8459. /**
  8460. * Gets the position in front of the camera at a given distance.
  8461. * @param distance The distance from the camera we want the position to be
  8462. * @returns the position
  8463. */
  8464. getFrontPosition(distance: number): Vector3;
  8465. /** @hidden */
  8466. _getLockedTargetPosition(): Nullable<Vector3>;
  8467. private _storedPosition;
  8468. private _storedRotation;
  8469. private _storedRotationQuaternion;
  8470. /**
  8471. * Store current camera state of the camera (fov, position, rotation, etc..)
  8472. * @returns the camera
  8473. */
  8474. storeState(): Camera;
  8475. /**
  8476. * Restored camera state. You must call storeState() first
  8477. * @returns whether it was successful or not
  8478. * @hidden
  8479. */
  8480. _restoreStateValues(): boolean;
  8481. /** @hidden */
  8482. _initCache(): void;
  8483. /** @hidden */
  8484. _updateCache(ignoreParentClass?: boolean): void;
  8485. /** @hidden */
  8486. _isSynchronizedViewMatrix(): boolean;
  8487. /** @hidden */
  8488. _computeLocalCameraSpeed(): number;
  8489. /** @hidden */
  8490. setTarget(target: Vector3): void;
  8491. /**
  8492. * Return the current target position of the camera. This value is expressed in local space.
  8493. * @returns the target position
  8494. */
  8495. getTarget(): Vector3;
  8496. /** @hidden */
  8497. _decideIfNeedsToMove(): boolean;
  8498. /** @hidden */
  8499. _updatePosition(): void;
  8500. /** @hidden */
  8501. _checkInputs(): void;
  8502. protected _updateCameraRotationMatrix(): void;
  8503. /**
  8504. * 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)
  8505. * @returns the current camera
  8506. */
  8507. private _rotateUpVectorWithCameraRotationMatrix;
  8508. private _cachedRotationZ;
  8509. private _cachedQuaternionRotationZ;
  8510. /** @hidden */
  8511. _getViewMatrix(): Matrix;
  8512. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8513. /**
  8514. * @hidden
  8515. */
  8516. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8517. /**
  8518. * @hidden
  8519. */
  8520. _updateRigCameras(): void;
  8521. private _getRigCamPositionAndTarget;
  8522. /**
  8523. * Gets the current object class name.
  8524. * @return the class name
  8525. */
  8526. getClassName(): string;
  8527. }
  8528. }
  8529. declare module "babylonjs/Cameras/cameraInputsManager" {
  8530. import { Nullable } from "babylonjs/types";
  8531. import { Camera } from "babylonjs/Cameras/camera";
  8532. /**
  8533. * @ignore
  8534. * This is a list of all the different input types that are available in the application.
  8535. * Fo instance: ArcRotateCameraGamepadInput...
  8536. */
  8537. export var CameraInputTypes: {};
  8538. /**
  8539. * This is the contract to implement in order to create a new input class.
  8540. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8541. */
  8542. export interface ICameraInput<TCamera extends Camera> {
  8543. /**
  8544. * Defines the camera the input is attached to.
  8545. */
  8546. camera: Nullable<TCamera>;
  8547. /**
  8548. * Gets the class name of the current intput.
  8549. * @returns the class name
  8550. */
  8551. getClassName(): string;
  8552. /**
  8553. * Get the friendly name associated with the input class.
  8554. * @returns the input friendly name
  8555. */
  8556. getSimpleName(): string;
  8557. /**
  8558. * Attach the input controls to a specific dom element to get the input from.
  8559. * @param element Defines the element the controls should be listened from
  8560. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8561. */
  8562. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8563. /**
  8564. * Detach the current controls from the specified dom element.
  8565. * @param element Defines the element to stop listening the inputs from
  8566. */
  8567. detachControl(element: Nullable<HTMLElement>): void;
  8568. /**
  8569. * Update the current camera state depending on the inputs that have been used this frame.
  8570. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8571. */
  8572. checkInputs?: () => void;
  8573. }
  8574. /**
  8575. * Represents a map of input types to input instance or input index to input instance.
  8576. */
  8577. export interface CameraInputsMap<TCamera extends Camera> {
  8578. /**
  8579. * Accessor to the input by input type.
  8580. */
  8581. [name: string]: ICameraInput<TCamera>;
  8582. /**
  8583. * Accessor to the input by input index.
  8584. */
  8585. [idx: number]: ICameraInput<TCamera>;
  8586. }
  8587. /**
  8588. * This represents the input manager used within a camera.
  8589. * It helps dealing with all the different kind of input attached to a camera.
  8590. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8591. */
  8592. export class CameraInputsManager<TCamera extends Camera> {
  8593. /**
  8594. * Defines the list of inputs attahed to the camera.
  8595. */
  8596. attached: CameraInputsMap<TCamera>;
  8597. /**
  8598. * Defines the dom element the camera is collecting inputs from.
  8599. * This is null if the controls have not been attached.
  8600. */
  8601. attachedElement: Nullable<HTMLElement>;
  8602. /**
  8603. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8604. */
  8605. noPreventDefault: boolean;
  8606. /**
  8607. * Defined the camera the input manager belongs to.
  8608. */
  8609. camera: TCamera;
  8610. /**
  8611. * Update the current camera state depending on the inputs that have been used this frame.
  8612. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8613. */
  8614. checkInputs: () => void;
  8615. /**
  8616. * Instantiate a new Camera Input Manager.
  8617. * @param camera Defines the camera the input manager blongs to
  8618. */
  8619. constructor(camera: TCamera);
  8620. /**
  8621. * Add an input method to a camera
  8622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8623. * @param input camera input method
  8624. */
  8625. add(input: ICameraInput<TCamera>): void;
  8626. /**
  8627. * Remove a specific input method from a camera
  8628. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8629. * @param inputToRemove camera input method
  8630. */
  8631. remove(inputToRemove: ICameraInput<TCamera>): void;
  8632. /**
  8633. * Remove a specific input type from a camera
  8634. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8635. * @param inputType the type of the input to remove
  8636. */
  8637. removeByType(inputType: string): void;
  8638. private _addCheckInputs;
  8639. /**
  8640. * Attach the input controls to the currently attached dom element to listen the events from.
  8641. * @param input Defines the input to attach
  8642. */
  8643. attachInput(input: ICameraInput<TCamera>): void;
  8644. /**
  8645. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8646. * @param element Defines the dom element to collect the events from
  8647. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8648. */
  8649. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8650. /**
  8651. * Detach the current manager inputs controls from a specific dom element.
  8652. * @param element Defines the dom element to collect the events from
  8653. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8654. */
  8655. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8656. /**
  8657. * Rebuild the dynamic inputCheck function from the current list of
  8658. * defined inputs in the manager.
  8659. */
  8660. rebuildInputCheck(): void;
  8661. /**
  8662. * Remove all attached input methods from a camera
  8663. */
  8664. clear(): void;
  8665. /**
  8666. * Serialize the current input manager attached to a camera.
  8667. * This ensures than once parsed,
  8668. * the input associated to the camera will be identical to the current ones
  8669. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8670. */
  8671. serialize(serializedCamera: any): void;
  8672. /**
  8673. * Parses an input manager serialized JSON to restore the previous list of inputs
  8674. * and states associated to a camera.
  8675. * @param parsedCamera Defines the JSON to parse
  8676. */
  8677. parse(parsedCamera: any): void;
  8678. }
  8679. }
  8680. declare module "babylonjs/Events/keyboardEvents" {
  8681. /**
  8682. * Gather the list of keyboard event types as constants.
  8683. */
  8684. export class KeyboardEventTypes {
  8685. /**
  8686. * The keydown event is fired when a key becomes active (pressed).
  8687. */
  8688. static readonly KEYDOWN: number;
  8689. /**
  8690. * The keyup event is fired when a key has been released.
  8691. */
  8692. static readonly KEYUP: number;
  8693. }
  8694. /**
  8695. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8696. */
  8697. export class KeyboardInfo {
  8698. /**
  8699. * Defines the type of event (KeyboardEventTypes)
  8700. */
  8701. type: number;
  8702. /**
  8703. * Defines the related dom event
  8704. */
  8705. event: KeyboardEvent;
  8706. /**
  8707. * Instantiates a new keyboard info.
  8708. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8709. * @param type Defines the type of event (KeyboardEventTypes)
  8710. * @param event Defines the related dom event
  8711. */
  8712. constructor(
  8713. /**
  8714. * Defines the type of event (KeyboardEventTypes)
  8715. */
  8716. type: number,
  8717. /**
  8718. * Defines the related dom event
  8719. */
  8720. event: KeyboardEvent);
  8721. }
  8722. /**
  8723. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8724. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8725. */
  8726. export class KeyboardInfoPre extends KeyboardInfo {
  8727. /**
  8728. * Defines the type of event (KeyboardEventTypes)
  8729. */
  8730. type: number;
  8731. /**
  8732. * Defines the related dom event
  8733. */
  8734. event: KeyboardEvent;
  8735. /**
  8736. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8737. */
  8738. skipOnPointerObservable: boolean;
  8739. /**
  8740. * Instantiates a new keyboard pre info.
  8741. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8742. * @param type Defines the type of event (KeyboardEventTypes)
  8743. * @param event Defines the related dom event
  8744. */
  8745. constructor(
  8746. /**
  8747. * Defines the type of event (KeyboardEventTypes)
  8748. */
  8749. type: number,
  8750. /**
  8751. * Defines the related dom event
  8752. */
  8753. event: KeyboardEvent);
  8754. }
  8755. }
  8756. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8757. import { Nullable } from "babylonjs/types";
  8758. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8759. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8760. /**
  8761. * Manage the keyboard inputs to control the movement of a free camera.
  8762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8763. */
  8764. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8765. /**
  8766. * Defines the camera the input is attached to.
  8767. */
  8768. camera: FreeCamera;
  8769. /**
  8770. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8771. */
  8772. keysUp: number[];
  8773. /**
  8774. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8775. */
  8776. keysDown: number[];
  8777. /**
  8778. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8779. */
  8780. keysLeft: number[];
  8781. /**
  8782. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8783. */
  8784. keysRight: number[];
  8785. private _keys;
  8786. private _onCanvasBlurObserver;
  8787. private _onKeyboardObserver;
  8788. private _engine;
  8789. private _scene;
  8790. /**
  8791. * Attach the input controls to a specific dom element to get the input from.
  8792. * @param element Defines the element the controls should be listened 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. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8796. /**
  8797. * Detach the current controls from the specified dom element.
  8798. * @param element Defines the element to stop listening the inputs from
  8799. */
  8800. detachControl(element: Nullable<HTMLElement>): void;
  8801. /**
  8802. * Update the current camera state depending on the inputs that have been used this frame.
  8803. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8804. */
  8805. checkInputs(): void;
  8806. /**
  8807. * Gets the class name of the current intput.
  8808. * @returns the class name
  8809. */
  8810. getClassName(): string;
  8811. /** @hidden */
  8812. _onLostFocus(): void;
  8813. /**
  8814. * Get the friendly name associated with the input class.
  8815. * @returns the input friendly name
  8816. */
  8817. getSimpleName(): string;
  8818. }
  8819. }
  8820. declare module "babylonjs/Lights/shadowLight" {
  8821. import { Camera } from "babylonjs/Cameras/camera";
  8822. import { Scene } from "babylonjs/scene";
  8823. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8825. import { Light } from "babylonjs/Lights/light";
  8826. /**
  8827. * Interface describing all the common properties and methods a shadow light needs to implement.
  8828. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8829. * as well as binding the different shadow properties to the effects.
  8830. */
  8831. export interface IShadowLight extends Light {
  8832. /**
  8833. * The light id in the scene (used in scene.findLighById for instance)
  8834. */
  8835. id: string;
  8836. /**
  8837. * The position the shdow will be casted from.
  8838. */
  8839. position: Vector3;
  8840. /**
  8841. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8842. */
  8843. direction: Vector3;
  8844. /**
  8845. * The transformed position. Position of the light in world space taking parenting in account.
  8846. */
  8847. transformedPosition: Vector3;
  8848. /**
  8849. * The transformed direction. Direction of the light in world space taking parenting in account.
  8850. */
  8851. transformedDirection: Vector3;
  8852. /**
  8853. * The friendly name of the light in the scene.
  8854. */
  8855. name: string;
  8856. /**
  8857. * Defines the shadow projection clipping minimum z value.
  8858. */
  8859. shadowMinZ: number;
  8860. /**
  8861. * Defines the shadow projection clipping maximum z value.
  8862. */
  8863. shadowMaxZ: number;
  8864. /**
  8865. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8866. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8867. */
  8868. computeTransformedInformation(): boolean;
  8869. /**
  8870. * Gets the scene the light belongs to.
  8871. * @returns The scene
  8872. */
  8873. getScene(): Scene;
  8874. /**
  8875. * Callback defining a custom Projection Matrix Builder.
  8876. * This can be used to override the default projection matrix computation.
  8877. */
  8878. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8879. /**
  8880. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8881. * @param matrix The materix to updated with the projection information
  8882. * @param viewMatrix The transform matrix of the light
  8883. * @param renderList The list of mesh to render in the map
  8884. * @returns The current light
  8885. */
  8886. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8887. /**
  8888. * Gets the current depth scale used in ESM.
  8889. * @returns The scale
  8890. */
  8891. getDepthScale(): number;
  8892. /**
  8893. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8894. * @returns true if a cube texture needs to be use
  8895. */
  8896. needCube(): boolean;
  8897. /**
  8898. * Detects if the projection matrix requires to be recomputed this frame.
  8899. * @returns true if it requires to be recomputed otherwise, false.
  8900. */
  8901. needProjectionMatrixCompute(): boolean;
  8902. /**
  8903. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8904. */
  8905. forceProjectionMatrixCompute(): void;
  8906. /**
  8907. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8908. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8909. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8910. */
  8911. getShadowDirection(faceIndex?: number): Vector3;
  8912. /**
  8913. * Gets the minZ used for shadow according to both the scene and the light.
  8914. * @param activeCamera The camera we are returning the min for
  8915. * @returns the depth min z
  8916. */
  8917. getDepthMinZ(activeCamera: Camera): number;
  8918. /**
  8919. * Gets the maxZ used for shadow according to both the scene and the light.
  8920. * @param activeCamera The camera we are returning the max for
  8921. * @returns the depth max z
  8922. */
  8923. getDepthMaxZ(activeCamera: Camera): number;
  8924. }
  8925. /**
  8926. * Base implementation IShadowLight
  8927. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8928. */
  8929. export abstract class ShadowLight extends Light implements IShadowLight {
  8930. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8931. protected _position: Vector3;
  8932. protected _setPosition(value: Vector3): void;
  8933. /**
  8934. * Sets the position the shadow will be casted from. Also use as the light position for both
  8935. * point and spot lights.
  8936. */
  8937. /**
  8938. * Sets the position the shadow will be casted from. Also use as the light position for both
  8939. * point and spot lights.
  8940. */
  8941. position: Vector3;
  8942. protected _direction: Vector3;
  8943. protected _setDirection(value: Vector3): void;
  8944. /**
  8945. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8946. * Also use as the light direction on spot and directional lights.
  8947. */
  8948. /**
  8949. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8950. * Also use as the light direction on spot and directional lights.
  8951. */
  8952. direction: Vector3;
  8953. private _shadowMinZ;
  8954. /**
  8955. * Gets the shadow projection clipping minimum z value.
  8956. */
  8957. /**
  8958. * Sets the shadow projection clipping minimum z value.
  8959. */
  8960. shadowMinZ: number;
  8961. private _shadowMaxZ;
  8962. /**
  8963. * Sets the shadow projection clipping maximum z value.
  8964. */
  8965. /**
  8966. * Gets the shadow projection clipping maximum z value.
  8967. */
  8968. shadowMaxZ: number;
  8969. /**
  8970. * Callback defining a custom Projection Matrix Builder.
  8971. * This can be used to override the default projection matrix computation.
  8972. */
  8973. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8974. /**
  8975. * The transformed position. Position of the light in world space taking parenting in account.
  8976. */
  8977. transformedPosition: Vector3;
  8978. /**
  8979. * The transformed direction. Direction of the light in world space taking parenting in account.
  8980. */
  8981. transformedDirection: Vector3;
  8982. private _needProjectionMatrixCompute;
  8983. /**
  8984. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8985. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8986. */
  8987. computeTransformedInformation(): boolean;
  8988. /**
  8989. * Return the depth scale used for the shadow map.
  8990. * @returns the depth scale.
  8991. */
  8992. getDepthScale(): number;
  8993. /**
  8994. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8995. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8996. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8997. */
  8998. getShadowDirection(faceIndex?: number): Vector3;
  8999. /**
  9000. * Returns the ShadowLight absolute position in the World.
  9001. * @returns the position vector in world space
  9002. */
  9003. getAbsolutePosition(): Vector3;
  9004. /**
  9005. * Sets the ShadowLight direction toward the passed target.
  9006. * @param target The point to target in local space
  9007. * @returns the updated ShadowLight direction
  9008. */
  9009. setDirectionToTarget(target: Vector3): Vector3;
  9010. /**
  9011. * Returns the light rotation in euler definition.
  9012. * @returns the x y z rotation in local space.
  9013. */
  9014. getRotation(): Vector3;
  9015. /**
  9016. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9017. * @returns true if a cube texture needs to be use
  9018. */
  9019. needCube(): boolean;
  9020. /**
  9021. * Detects if the projection matrix requires to be recomputed this frame.
  9022. * @returns true if it requires to be recomputed otherwise, false.
  9023. */
  9024. needProjectionMatrixCompute(): boolean;
  9025. /**
  9026. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9027. */
  9028. forceProjectionMatrixCompute(): void;
  9029. /** @hidden */
  9030. _initCache(): void;
  9031. /** @hidden */
  9032. _isSynchronized(): boolean;
  9033. /**
  9034. * Computes the world matrix of the node
  9035. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9036. * @returns the world matrix
  9037. */
  9038. computeWorldMatrix(force?: boolean): Matrix;
  9039. /**
  9040. * Gets the minZ used for shadow according to both the scene and the light.
  9041. * @param activeCamera The camera we are returning the min for
  9042. * @returns the depth min z
  9043. */
  9044. getDepthMinZ(activeCamera: Camera): number;
  9045. /**
  9046. * Gets the maxZ used for shadow according to both the scene and the light.
  9047. * @param activeCamera The camera we are returning the max for
  9048. * @returns the depth max z
  9049. */
  9050. getDepthMaxZ(activeCamera: Camera): number;
  9051. /**
  9052. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9053. * @param matrix The materix to updated with the projection information
  9054. * @param viewMatrix The transform matrix of the light
  9055. * @param renderList The list of mesh to render in the map
  9056. * @returns The current light
  9057. */
  9058. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9059. }
  9060. }
  9061. declare module "babylonjs/Materials/materialHelper" {
  9062. import { Nullable } from "babylonjs/types";
  9063. import { Scene } from "babylonjs/scene";
  9064. import { Engine } from "babylonjs/Engines/engine";
  9065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9066. import { Light } from "babylonjs/Lights/light";
  9067. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9068. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9069. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9070. /**
  9071. * "Static Class" containing the most commonly used helper while dealing with material for
  9072. * rendering purpose.
  9073. *
  9074. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9075. *
  9076. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9077. */
  9078. export class MaterialHelper {
  9079. /**
  9080. * Bind the current view position to an effect.
  9081. * @param effect The effect to be bound
  9082. * @param scene The scene the eyes position is used from
  9083. */
  9084. static BindEyePosition(effect: Effect, scene: Scene): void;
  9085. /**
  9086. * Helps preparing the defines values about the UVs in used in the effect.
  9087. * UVs are shared as much as we can accross channels in the shaders.
  9088. * @param texture The texture we are preparing the UVs for
  9089. * @param defines The defines to update
  9090. * @param key The channel key "diffuse", "specular"... used in the shader
  9091. */
  9092. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9093. /**
  9094. * Binds a texture matrix value to its corrsponding uniform
  9095. * @param texture The texture to bind the matrix for
  9096. * @param uniformBuffer The uniform buffer receivin the data
  9097. * @param key The channel key "diffuse", "specular"... used in the shader
  9098. */
  9099. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9100. /**
  9101. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9102. * @param mesh defines the current mesh
  9103. * @param scene defines the current scene
  9104. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9105. * @param pointsCloud defines if point cloud rendering has to be turned on
  9106. * @param fogEnabled defines if fog has to be turned on
  9107. * @param alphaTest defines if alpha testing has to be turned on
  9108. * @param defines defines the current list of defines
  9109. */
  9110. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9111. /**
  9112. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9113. * @param scene defines the current scene
  9114. * @param engine defines the current engine
  9115. * @param defines specifies the list of active defines
  9116. * @param useInstances defines if instances have to be turned on
  9117. * @param useClipPlane defines if clip plane have to be turned on
  9118. */
  9119. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9120. /**
  9121. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9122. * @param mesh The mesh containing the geometry data we will draw
  9123. * @param defines The defines to update
  9124. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9125. * @param useBones Precise whether bones should be used or not (override mesh info)
  9126. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9127. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9128. * @returns false if defines are considered not dirty and have not been checked
  9129. */
  9130. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9131. /**
  9132. * Prepares the defines related to the light information passed in parameter
  9133. * @param scene The scene we are intending to draw
  9134. * @param mesh The mesh the effect is compiling for
  9135. * @param defines The defines to update
  9136. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9137. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9138. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9139. * @returns true if normals will be required for the rest of the effect
  9140. */
  9141. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9142. /**
  9143. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9144. * that won t be acctive due to defines being turned off.
  9145. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9146. * @param samplersList The samplers list
  9147. * @param defines The defines helping in the list generation
  9148. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9149. */
  9150. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9151. /**
  9152. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9153. * @param defines The defines to update while falling back
  9154. * @param fallbacks The authorized effect fallbacks
  9155. * @param maxSimultaneousLights The maximum number of lights allowed
  9156. * @param rank the current rank of the Effect
  9157. * @returns The newly affected rank
  9158. */
  9159. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9160. /**
  9161. * Prepares the list of attributes required for morph targets according to the effect defines.
  9162. * @param attribs The current list of supported attribs
  9163. * @param mesh The mesh to prepare the morph targets attributes for
  9164. * @param defines The current Defines of the effect
  9165. */
  9166. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9167. /**
  9168. * Prepares the list of attributes required for bones according to the effect defines.
  9169. * @param attribs The current list of supported attribs
  9170. * @param mesh The mesh to prepare the bones attributes for
  9171. * @param defines The current Defines of the effect
  9172. * @param fallbacks The current efffect fallback strategy
  9173. */
  9174. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9175. /**
  9176. * Prepares the list of attributes required for instances according to the effect defines.
  9177. * @param attribs The current list of supported attribs
  9178. * @param defines The current Defines of the effect
  9179. */
  9180. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9181. /**
  9182. * Binds the light shadow information to the effect for the given mesh.
  9183. * @param light The light containing the generator
  9184. * @param scene The scene the lights belongs to
  9185. * @param mesh The mesh we are binding the information to render
  9186. * @param lightIndex The light index in the effect used to render the mesh
  9187. * @param effect The effect we are binding the data to
  9188. */
  9189. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9190. /**
  9191. * Binds the light information to the effect.
  9192. * @param light The light containing the generator
  9193. * @param effect The effect we are binding the data to
  9194. * @param lightIndex The light index in the effect used to render
  9195. */
  9196. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9197. /**
  9198. * Binds the lights information from the scene to the effect for the given mesh.
  9199. * @param scene The scene the lights belongs to
  9200. * @param mesh The mesh we are binding the information to render
  9201. * @param effect The effect we are binding the data to
  9202. * @param defines The generated defines for the effect
  9203. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9204. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9205. */
  9206. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9207. private static _tempFogColor;
  9208. /**
  9209. * Binds the fog information from the scene to the effect for the given mesh.
  9210. * @param scene The scene the lights belongs to
  9211. * @param mesh The mesh we are binding the information to render
  9212. * @param effect The effect we are binding the data to
  9213. * @param linearSpace Defines if the fog effect is applied in linear space
  9214. */
  9215. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9216. /**
  9217. * Binds the bones information from the mesh to the effect.
  9218. * @param mesh The mesh we are binding the information to render
  9219. * @param effect The effect we are binding the data to
  9220. */
  9221. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9222. /**
  9223. * Binds the morph targets information from the mesh to the effect.
  9224. * @param abstractMesh The mesh we are binding the information to render
  9225. * @param effect The effect we are binding the data to
  9226. */
  9227. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9228. /**
  9229. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9230. * @param defines The generated defines used in the effect
  9231. * @param effect The effect we are binding the data to
  9232. * @param scene The scene we are willing to render with logarithmic scale for
  9233. */
  9234. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9235. /**
  9236. * Binds the clip plane information from the scene to the effect.
  9237. * @param scene The scene the clip plane information are extracted from
  9238. * @param effect The effect we are binding the data to
  9239. */
  9240. static BindClipPlane(effect: Effect, scene: Scene): void;
  9241. }
  9242. }
  9243. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9244. /** @hidden */
  9245. export var kernelBlurVaryingDeclaration: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9251. /** @hidden */
  9252. export var kernelBlurFragment: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9258. /** @hidden */
  9259. export var kernelBlurFragment2: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9265. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9266. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9267. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9268. /** @hidden */
  9269. export var kernelBlurPixelShader: {
  9270. name: string;
  9271. shader: string;
  9272. };
  9273. }
  9274. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9275. /** @hidden */
  9276. export var kernelBlurVertex: {
  9277. name: string;
  9278. shader: string;
  9279. };
  9280. }
  9281. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9282. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9283. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9284. /** @hidden */
  9285. export var kernelBlurVertexShader: {
  9286. name: string;
  9287. shader: string;
  9288. };
  9289. }
  9290. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9291. import { Vector2 } from "babylonjs/Maths/math";
  9292. import { Nullable } from "babylonjs/types";
  9293. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9294. import { Camera } from "babylonjs/Cameras/camera";
  9295. import { Effect } from "babylonjs/Materials/effect";
  9296. import { Engine } from "babylonjs/Engines/engine";
  9297. import "babylonjs/Shaders/kernelBlur.fragment";
  9298. import "babylonjs/Shaders/kernelBlur.vertex";
  9299. /**
  9300. * The Blur Post Process which blurs an image based on a kernel and direction.
  9301. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9302. */
  9303. export class BlurPostProcess extends PostProcess {
  9304. /** The direction in which to blur the image. */
  9305. direction: Vector2;
  9306. private blockCompilation;
  9307. protected _kernel: number;
  9308. protected _idealKernel: number;
  9309. protected _packedFloat: boolean;
  9310. private _staticDefines;
  9311. /**
  9312. * Sets the length in pixels of the blur sample region
  9313. */
  9314. /**
  9315. * Gets the length in pixels of the blur sample region
  9316. */
  9317. kernel: number;
  9318. /**
  9319. * Sets wether or not the blur needs to unpack/repack floats
  9320. */
  9321. /**
  9322. * Gets wether or not the blur is unpacking/repacking floats
  9323. */
  9324. packedFloat: boolean;
  9325. /**
  9326. * Creates a new instance BlurPostProcess
  9327. * @param name The name of the effect.
  9328. * @param direction The direction in which to blur the image.
  9329. * @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.
  9330. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9331. * @param camera The camera to apply the render pass to.
  9332. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9333. * @param engine The engine which the post process will be applied. (default: current engine)
  9334. * @param reusable If the post process can be reused on the same frame. (default: false)
  9335. * @param textureType Type of textures used when performing the post process. (default: 0)
  9336. * @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)
  9337. */
  9338. constructor(name: string,
  9339. /** The direction in which to blur the image. */
  9340. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9341. /**
  9342. * Updates the effect with the current post process compile time values and recompiles the shader.
  9343. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9344. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9345. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9346. * @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
  9347. * @param onCompiled Called when the shader has been compiled.
  9348. * @param onError Called if there is an error when compiling a shader.
  9349. */
  9350. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9351. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9352. /**
  9353. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9354. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9355. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9356. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9357. * The gaps between physical kernels are compensated for in the weighting of the samples
  9358. * @param idealKernel Ideal blur kernel.
  9359. * @return Nearest best kernel.
  9360. */
  9361. protected _nearestBestKernel(idealKernel: number): number;
  9362. /**
  9363. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9364. * @param x The point on the Gaussian distribution to sample.
  9365. * @return the value of the Gaussian function at x.
  9366. */
  9367. protected _gaussianWeight(x: number): number;
  9368. /**
  9369. * Generates a string that can be used as a floating point number in GLSL.
  9370. * @param x Value to print.
  9371. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9372. * @return GLSL float string.
  9373. */
  9374. protected _glslFloat(x: number, decimalFigures?: number): string;
  9375. }
  9376. }
  9377. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9378. /** @hidden */
  9379. export var shadowMapPixelShader: {
  9380. name: string;
  9381. shader: string;
  9382. };
  9383. }
  9384. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9385. /** @hidden */
  9386. export var bonesDeclaration: {
  9387. name: string;
  9388. shader: string;
  9389. };
  9390. }
  9391. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9392. /** @hidden */
  9393. export var morphTargetsVertexGlobalDeclaration: {
  9394. name: string;
  9395. shader: string;
  9396. };
  9397. }
  9398. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9399. /** @hidden */
  9400. export var morphTargetsVertexDeclaration: {
  9401. name: string;
  9402. shader: string;
  9403. };
  9404. }
  9405. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9406. /** @hidden */
  9407. export var instancesDeclaration: {
  9408. name: string;
  9409. shader: string;
  9410. };
  9411. }
  9412. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9413. /** @hidden */
  9414. export var helperFunctions: {
  9415. name: string;
  9416. shader: string;
  9417. };
  9418. }
  9419. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9420. /** @hidden */
  9421. export var morphTargetsVertex: {
  9422. name: string;
  9423. shader: string;
  9424. };
  9425. }
  9426. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9427. /** @hidden */
  9428. export var instancesVertex: {
  9429. name: string;
  9430. shader: string;
  9431. };
  9432. }
  9433. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9434. /** @hidden */
  9435. export var bonesVertex: {
  9436. name: string;
  9437. shader: string;
  9438. };
  9439. }
  9440. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9441. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9442. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9443. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9444. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9445. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9446. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9447. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9448. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9449. /** @hidden */
  9450. export var shadowMapVertexShader: {
  9451. name: string;
  9452. shader: string;
  9453. };
  9454. }
  9455. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9456. /** @hidden */
  9457. export var depthBoxBlurPixelShader: {
  9458. name: string;
  9459. shader: string;
  9460. };
  9461. }
  9462. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9463. import { Nullable } from "babylonjs/types";
  9464. import { Scene } from "babylonjs/scene";
  9465. import { Matrix } from "babylonjs/Maths/math";
  9466. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9468. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9469. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9470. import { Effect } from "babylonjs/Materials/effect";
  9471. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9472. import "babylonjs/Shaders/shadowMap.fragment";
  9473. import "babylonjs/Shaders/shadowMap.vertex";
  9474. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9475. import { Observable } from "babylonjs/Misc/observable";
  9476. /**
  9477. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9478. */
  9479. export interface ICustomShaderOptions {
  9480. /**
  9481. * Gets or sets the custom shader name to use
  9482. */
  9483. shaderName: string;
  9484. /**
  9485. * The list of attribute names used in the shader
  9486. */
  9487. attributes?: string[];
  9488. /**
  9489. * The list of unifrom names used in the shader
  9490. */
  9491. uniforms?: string[];
  9492. /**
  9493. * The list of sampler names used in the shader
  9494. */
  9495. samplers?: string[];
  9496. /**
  9497. * The list of defines used in the shader
  9498. */
  9499. defines?: string[];
  9500. }
  9501. /**
  9502. * Interface to implement to create a shadow generator compatible with BJS.
  9503. */
  9504. export interface IShadowGenerator {
  9505. /**
  9506. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9507. * @returns The render target texture if present otherwise, null
  9508. */
  9509. getShadowMap(): Nullable<RenderTargetTexture>;
  9510. /**
  9511. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9512. * @returns The render target texture if the shadow map is present otherwise, null
  9513. */
  9514. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9515. /**
  9516. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9517. * @param subMesh The submesh we want to render in the shadow map
  9518. * @param useInstances Defines wether will draw in the map using instances
  9519. * @returns true if ready otherwise, false
  9520. */
  9521. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9522. /**
  9523. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9524. * @param defines Defines of the material we want to update
  9525. * @param lightIndex Index of the light in the enabled light list of the material
  9526. */
  9527. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9528. /**
  9529. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9530. * defined in the generator but impacting the effect).
  9531. * It implies the unifroms available on the materials are the standard BJS ones.
  9532. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9533. * @param effect The effect we are binfing the information for
  9534. */
  9535. bindShadowLight(lightIndex: string, effect: Effect): void;
  9536. /**
  9537. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9538. * (eq to shadow prjection matrix * light transform matrix)
  9539. * @returns The transform matrix used to create the shadow map
  9540. */
  9541. getTransformMatrix(): Matrix;
  9542. /**
  9543. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9544. * Cube and 2D textures for instance.
  9545. */
  9546. recreateShadowMap(): void;
  9547. /**
  9548. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9549. * @param onCompiled Callback triggered at the and of the effects compilation
  9550. * @param options Sets of optional options forcing the compilation with different modes
  9551. */
  9552. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9553. useInstances: boolean;
  9554. }>): void;
  9555. /**
  9556. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9557. * @param options Sets of optional options forcing the compilation with different modes
  9558. * @returns A promise that resolves when the compilation completes
  9559. */
  9560. forceCompilationAsync(options?: Partial<{
  9561. useInstances: boolean;
  9562. }>): Promise<void>;
  9563. /**
  9564. * Serializes the shadow generator setup to a json object.
  9565. * @returns The serialized JSON object
  9566. */
  9567. serialize(): any;
  9568. /**
  9569. * Disposes the Shadow map and related Textures and effects.
  9570. */
  9571. dispose(): void;
  9572. }
  9573. /**
  9574. * Default implementation IShadowGenerator.
  9575. * This is the main object responsible of generating shadows in the framework.
  9576. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9577. */
  9578. export class ShadowGenerator implements IShadowGenerator {
  9579. /**
  9580. * Shadow generator mode None: no filtering applied.
  9581. */
  9582. static readonly FILTER_NONE: number;
  9583. /**
  9584. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9585. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9586. */
  9587. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9588. /**
  9589. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9590. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9591. */
  9592. static readonly FILTER_POISSONSAMPLING: number;
  9593. /**
  9594. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9595. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9596. */
  9597. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9598. /**
  9599. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9600. * edge artifacts on steep falloff.
  9601. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9602. */
  9603. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9604. /**
  9605. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9606. * edge artifacts on steep falloff.
  9607. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9608. */
  9609. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9610. /**
  9611. * Shadow generator mode PCF: Percentage Closer Filtering
  9612. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9613. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9614. */
  9615. static readonly FILTER_PCF: number;
  9616. /**
  9617. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9618. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9619. * Contact Hardening
  9620. */
  9621. static readonly FILTER_PCSS: number;
  9622. /**
  9623. * Reserved for PCF and PCSS
  9624. * Highest Quality.
  9625. *
  9626. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9627. *
  9628. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9629. */
  9630. static readonly QUALITY_HIGH: number;
  9631. /**
  9632. * Reserved for PCF and PCSS
  9633. * Good tradeoff for quality/perf cross devices
  9634. *
  9635. * Execute PCF on a 3*3 kernel.
  9636. *
  9637. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9638. */
  9639. static readonly QUALITY_MEDIUM: number;
  9640. /**
  9641. * Reserved for PCF and PCSS
  9642. * The lowest quality but the fastest.
  9643. *
  9644. * Execute PCF on a 1*1 kernel.
  9645. *
  9646. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9647. */
  9648. static readonly QUALITY_LOW: number;
  9649. /** Gets or sets the custom shader name to use */
  9650. customShaderOptions: ICustomShaderOptions;
  9651. /**
  9652. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9653. */
  9654. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9655. private _bias;
  9656. /**
  9657. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9658. */
  9659. /**
  9660. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9661. */
  9662. bias: number;
  9663. private _normalBias;
  9664. /**
  9665. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9666. */
  9667. /**
  9668. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9669. */
  9670. normalBias: number;
  9671. private _blurBoxOffset;
  9672. /**
  9673. * Gets the blur box offset: offset applied during the blur pass.
  9674. * Only useful if useKernelBlur = false
  9675. */
  9676. /**
  9677. * Sets the blur box offset: offset applied during the blur pass.
  9678. * Only useful if useKernelBlur = false
  9679. */
  9680. blurBoxOffset: number;
  9681. private _blurScale;
  9682. /**
  9683. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9684. * 2 means half of the size.
  9685. */
  9686. /**
  9687. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9688. * 2 means half of the size.
  9689. */
  9690. blurScale: number;
  9691. private _blurKernel;
  9692. /**
  9693. * Gets the blur kernel: kernel size of the blur pass.
  9694. * Only useful if useKernelBlur = true
  9695. */
  9696. /**
  9697. * Sets the blur kernel: kernel size of the blur pass.
  9698. * Only useful if useKernelBlur = true
  9699. */
  9700. blurKernel: number;
  9701. private _useKernelBlur;
  9702. /**
  9703. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9704. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9705. */
  9706. /**
  9707. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9708. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9709. */
  9710. useKernelBlur: boolean;
  9711. private _depthScale;
  9712. /**
  9713. * Gets the depth scale used in ESM mode.
  9714. */
  9715. /**
  9716. * Sets the depth scale used in ESM mode.
  9717. * This can override the scale stored on the light.
  9718. */
  9719. depthScale: number;
  9720. private _filter;
  9721. /**
  9722. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9723. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9724. */
  9725. /**
  9726. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9727. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9728. */
  9729. filter: number;
  9730. /**
  9731. * Gets if the current filter is set to Poisson Sampling.
  9732. */
  9733. /**
  9734. * Sets the current filter to Poisson Sampling.
  9735. */
  9736. usePoissonSampling: boolean;
  9737. /**
  9738. * Gets if the current filter is set to ESM.
  9739. */
  9740. /**
  9741. * Sets the current filter is to ESM.
  9742. */
  9743. useExponentialShadowMap: boolean;
  9744. /**
  9745. * Gets if the current filter is set to filtered ESM.
  9746. */
  9747. /**
  9748. * Gets if the current filter is set to filtered ESM.
  9749. */
  9750. useBlurExponentialShadowMap: boolean;
  9751. /**
  9752. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9753. * exponential to prevent steep falloff artifacts).
  9754. */
  9755. /**
  9756. * Sets the current filter to "close ESM" (using the inverse of the
  9757. * exponential to prevent steep falloff artifacts).
  9758. */
  9759. useCloseExponentialShadowMap: boolean;
  9760. /**
  9761. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9762. * exponential to prevent steep falloff artifacts).
  9763. */
  9764. /**
  9765. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9766. * exponential to prevent steep falloff artifacts).
  9767. */
  9768. useBlurCloseExponentialShadowMap: boolean;
  9769. /**
  9770. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9771. */
  9772. /**
  9773. * Sets the current filter to "PCF" (percentage closer filtering).
  9774. */
  9775. usePercentageCloserFiltering: boolean;
  9776. private _filteringQuality;
  9777. /**
  9778. * Gets the PCF or PCSS Quality.
  9779. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9780. */
  9781. /**
  9782. * Sets the PCF or PCSS Quality.
  9783. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9784. */
  9785. filteringQuality: number;
  9786. /**
  9787. * Gets if the current filter is set to "PCSS" (contact hardening).
  9788. */
  9789. /**
  9790. * Sets the current filter to "PCSS" (contact hardening).
  9791. */
  9792. useContactHardeningShadow: boolean;
  9793. private _contactHardeningLightSizeUVRatio;
  9794. /**
  9795. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9796. * Using a ratio helps keeping shape stability independently of the map size.
  9797. *
  9798. * It does not account for the light projection as it was having too much
  9799. * instability during the light setup or during light position changes.
  9800. *
  9801. * Only valid if useContactHardeningShadow is true.
  9802. */
  9803. /**
  9804. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9805. * Using a ratio helps keeping shape stability independently of the map size.
  9806. *
  9807. * It does not account for the light projection as it was having too much
  9808. * instability during the light setup or during light position changes.
  9809. *
  9810. * Only valid if useContactHardeningShadow is true.
  9811. */
  9812. contactHardeningLightSizeUVRatio: number;
  9813. private _darkness;
  9814. /**
  9815. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9816. * 0 means strongest and 1 would means no shadow.
  9817. * @returns the darkness.
  9818. */
  9819. getDarkness(): number;
  9820. /**
  9821. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9822. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9823. * @returns the shadow generator allowing fluent coding.
  9824. */
  9825. setDarkness(darkness: number): ShadowGenerator;
  9826. private _transparencyShadow;
  9827. /**
  9828. * Sets the ability to have transparent shadow (boolean).
  9829. * @param transparent True if transparent else False
  9830. * @returns the shadow generator allowing fluent coding
  9831. */
  9832. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9833. private _shadowMap;
  9834. private _shadowMap2;
  9835. /**
  9836. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9837. * @returns The render target texture if present otherwise, null
  9838. */
  9839. getShadowMap(): Nullable<RenderTargetTexture>;
  9840. /**
  9841. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9842. * @returns The render target texture if the shadow map is present otherwise, null
  9843. */
  9844. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9845. /**
  9846. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9847. * @param mesh Mesh to add
  9848. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9849. * @returns the Shadow Generator itself
  9850. */
  9851. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9852. /**
  9853. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9854. * @param mesh Mesh to remove
  9855. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9856. * @returns the Shadow Generator itself
  9857. */
  9858. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9859. /**
  9860. * Controls the extent to which the shadows fade out at the edge of the frustum
  9861. * Used only by directionals and spots
  9862. */
  9863. frustumEdgeFalloff: number;
  9864. private _light;
  9865. /**
  9866. * Returns the associated light object.
  9867. * @returns the light generating the shadow
  9868. */
  9869. getLight(): IShadowLight;
  9870. /**
  9871. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9872. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9873. * It might on the other hand introduce peter panning.
  9874. */
  9875. forceBackFacesOnly: boolean;
  9876. private _scene;
  9877. private _lightDirection;
  9878. private _effect;
  9879. private _viewMatrix;
  9880. private _projectionMatrix;
  9881. private _transformMatrix;
  9882. private _cachedPosition;
  9883. private _cachedDirection;
  9884. private _cachedDefines;
  9885. private _currentRenderID;
  9886. private _boxBlurPostprocess;
  9887. private _kernelBlurXPostprocess;
  9888. private _kernelBlurYPostprocess;
  9889. private _blurPostProcesses;
  9890. private _mapSize;
  9891. private _currentFaceIndex;
  9892. private _currentFaceIndexCache;
  9893. private _textureType;
  9894. private _defaultTextureMatrix;
  9895. /** @hidden */
  9896. static _SceneComponentInitialization: (scene: Scene) => void;
  9897. /**
  9898. * Creates a ShadowGenerator object.
  9899. * A ShadowGenerator is the required tool to use the shadows.
  9900. * Each light casting shadows needs to use its own ShadowGenerator.
  9901. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9902. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9903. * @param light The light object generating the shadows.
  9904. * @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.
  9905. */
  9906. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9907. private _initializeGenerator;
  9908. private _initializeShadowMap;
  9909. private _initializeBlurRTTAndPostProcesses;
  9910. private _renderForShadowMap;
  9911. private _renderSubMeshForShadowMap;
  9912. private _applyFilterValues;
  9913. /**
  9914. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9915. * @param onCompiled Callback triggered at the and of the effects compilation
  9916. * @param options Sets of optional options forcing the compilation with different modes
  9917. */
  9918. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9919. useInstances: boolean;
  9920. }>): void;
  9921. /**
  9922. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9923. * @param options Sets of optional options forcing the compilation with different modes
  9924. * @returns A promise that resolves when the compilation completes
  9925. */
  9926. forceCompilationAsync(options?: Partial<{
  9927. useInstances: boolean;
  9928. }>): Promise<void>;
  9929. /**
  9930. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9931. * @param subMesh The submesh we want to render in the shadow map
  9932. * @param useInstances Defines wether will draw in the map using instances
  9933. * @returns true if ready otherwise, false
  9934. */
  9935. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9936. /**
  9937. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9938. * @param defines Defines of the material we want to update
  9939. * @param lightIndex Index of the light in the enabled light list of the material
  9940. */
  9941. prepareDefines(defines: any, lightIndex: number): void;
  9942. /**
  9943. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9944. * defined in the generator but impacting the effect).
  9945. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9946. * @param effect The effect we are binfing the information for
  9947. */
  9948. bindShadowLight(lightIndex: string, effect: Effect): void;
  9949. /**
  9950. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9951. * (eq to shadow prjection matrix * light transform matrix)
  9952. * @returns The transform matrix used to create the shadow map
  9953. */
  9954. getTransformMatrix(): Matrix;
  9955. /**
  9956. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9957. * Cube and 2D textures for instance.
  9958. */
  9959. recreateShadowMap(): void;
  9960. private _disposeBlurPostProcesses;
  9961. private _disposeRTTandPostProcesses;
  9962. /**
  9963. * Disposes the ShadowGenerator.
  9964. * Returns nothing.
  9965. */
  9966. dispose(): void;
  9967. /**
  9968. * Serializes the shadow generator setup to a json object.
  9969. * @returns The serialized JSON object
  9970. */
  9971. serialize(): any;
  9972. /**
  9973. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9974. * @param parsedShadowGenerator The JSON object to parse
  9975. * @param scene The scene to create the shadow map for
  9976. * @returns The parsed shadow generator
  9977. */
  9978. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9979. }
  9980. }
  9981. declare module "babylonjs/Lights/light" {
  9982. import { Nullable } from "babylonjs/types";
  9983. import { Scene } from "babylonjs/scene";
  9984. import { Vector3, Color3 } from "babylonjs/Maths/math";
  9985. import { Node } from "babylonjs/node";
  9986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9987. import { Effect } from "babylonjs/Materials/effect";
  9988. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9989. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9990. /**
  9991. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9992. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9993. * 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.
  9994. */
  9995. export abstract class Light extends Node {
  9996. /**
  9997. * Falloff Default: light is falling off following the material specification:
  9998. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9999. */
  10000. static readonly FALLOFF_DEFAULT: number;
  10001. /**
  10002. * Falloff Physical: light is falling off following the inverse squared distance law.
  10003. */
  10004. static readonly FALLOFF_PHYSICAL: number;
  10005. /**
  10006. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10007. * to enhance interoperability with other engines.
  10008. */
  10009. static readonly FALLOFF_GLTF: number;
  10010. /**
  10011. * Falloff Standard: light is falling off like in the standard material
  10012. * to enhance interoperability with other materials.
  10013. */
  10014. static readonly FALLOFF_STANDARD: number;
  10015. /**
  10016. * If every light affecting the material is in this lightmapMode,
  10017. * material.lightmapTexture adds or multiplies
  10018. * (depends on material.useLightmapAsShadowmap)
  10019. * after every other light calculations.
  10020. */
  10021. static readonly LIGHTMAP_DEFAULT: number;
  10022. /**
  10023. * material.lightmapTexture as only diffuse lighting from this light
  10024. * adds only specular lighting from this light
  10025. * adds dynamic shadows
  10026. */
  10027. static readonly LIGHTMAP_SPECULAR: number;
  10028. /**
  10029. * material.lightmapTexture as only lighting
  10030. * no light calculation from this light
  10031. * only adds dynamic shadows from this light
  10032. */
  10033. static readonly LIGHTMAP_SHADOWSONLY: number;
  10034. /**
  10035. * Each light type uses the default quantity according to its type:
  10036. * point/spot lights use luminous intensity
  10037. * directional lights use illuminance
  10038. */
  10039. static readonly INTENSITYMODE_AUTOMATIC: number;
  10040. /**
  10041. * lumen (lm)
  10042. */
  10043. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10044. /**
  10045. * candela (lm/sr)
  10046. */
  10047. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10048. /**
  10049. * lux (lm/m^2)
  10050. */
  10051. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10052. /**
  10053. * nit (cd/m^2)
  10054. */
  10055. static readonly INTENSITYMODE_LUMINANCE: number;
  10056. /**
  10057. * Light type const id of the point light.
  10058. */
  10059. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10060. /**
  10061. * Light type const id of the directional light.
  10062. */
  10063. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10064. /**
  10065. * Light type const id of the spot light.
  10066. */
  10067. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10068. /**
  10069. * Light type const id of the hemispheric light.
  10070. */
  10071. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10072. /**
  10073. * Diffuse gives the basic color to an object.
  10074. */
  10075. diffuse: Color3;
  10076. /**
  10077. * Specular produces a highlight color on an object.
  10078. * Note: This is note affecting PBR materials.
  10079. */
  10080. specular: Color3;
  10081. /**
  10082. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10083. * falling off base on range or angle.
  10084. * This can be set to any values in Light.FALLOFF_x.
  10085. *
  10086. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10087. * other types of materials.
  10088. */
  10089. falloffType: number;
  10090. /**
  10091. * Strength of the light.
  10092. * Note: By default it is define in the framework own unit.
  10093. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10094. */
  10095. intensity: number;
  10096. private _range;
  10097. protected _inverseSquaredRange: number;
  10098. /**
  10099. * Defines how far from the source the light is impacting in scene units.
  10100. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10101. */
  10102. /**
  10103. * Defines how far from the source the light is impacting in scene units.
  10104. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10105. */
  10106. range: number;
  10107. /**
  10108. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10109. * of light.
  10110. */
  10111. private _photometricScale;
  10112. private _intensityMode;
  10113. /**
  10114. * Gets the photometric scale used to interpret the intensity.
  10115. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10116. */
  10117. /**
  10118. * Sets the photometric scale used to interpret the intensity.
  10119. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10120. */
  10121. intensityMode: number;
  10122. private _radius;
  10123. /**
  10124. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10125. */
  10126. /**
  10127. * sets the light radius used by PBR Materials to simulate soft area lights.
  10128. */
  10129. radius: number;
  10130. private _renderPriority;
  10131. /**
  10132. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10133. * exceeding the number allowed of the materials.
  10134. */
  10135. renderPriority: number;
  10136. private _shadowEnabled;
  10137. /**
  10138. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10139. * the current shadow generator.
  10140. */
  10141. /**
  10142. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10143. * the current shadow generator.
  10144. */
  10145. shadowEnabled: boolean;
  10146. private _includedOnlyMeshes;
  10147. /**
  10148. * Gets the only meshes impacted by this light.
  10149. */
  10150. /**
  10151. * Sets the only meshes impacted by this light.
  10152. */
  10153. includedOnlyMeshes: AbstractMesh[];
  10154. private _excludedMeshes;
  10155. /**
  10156. * Gets the meshes not impacted by this light.
  10157. */
  10158. /**
  10159. * Sets the meshes not impacted by this light.
  10160. */
  10161. excludedMeshes: AbstractMesh[];
  10162. private _excludeWithLayerMask;
  10163. /**
  10164. * Gets the layer id use to find what meshes are not impacted by the light.
  10165. * Inactive if 0
  10166. */
  10167. /**
  10168. * Sets the layer id use to find what meshes are not impacted by the light.
  10169. * Inactive if 0
  10170. */
  10171. excludeWithLayerMask: number;
  10172. private _includeOnlyWithLayerMask;
  10173. /**
  10174. * Gets the layer id use to find what meshes are impacted by the light.
  10175. * Inactive if 0
  10176. */
  10177. /**
  10178. * Sets the layer id use to find what meshes are impacted by the light.
  10179. * Inactive if 0
  10180. */
  10181. includeOnlyWithLayerMask: number;
  10182. private _lightmapMode;
  10183. /**
  10184. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10185. */
  10186. /**
  10187. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10188. */
  10189. lightmapMode: number;
  10190. /**
  10191. * Shadow generator associted to the light.
  10192. * @hidden Internal use only.
  10193. */
  10194. _shadowGenerator: Nullable<IShadowGenerator>;
  10195. /**
  10196. * @hidden Internal use only.
  10197. */
  10198. _excludedMeshesIds: string[];
  10199. /**
  10200. * @hidden Internal use only.
  10201. */
  10202. _includedOnlyMeshesIds: string[];
  10203. /**
  10204. * The current light unifom buffer.
  10205. * @hidden Internal use only.
  10206. */
  10207. _uniformBuffer: UniformBuffer;
  10208. /**
  10209. * Creates a Light object in the scene.
  10210. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10211. * @param name The firendly name of the light
  10212. * @param scene The scene the light belongs too
  10213. */
  10214. constructor(name: string, scene: Scene);
  10215. protected abstract _buildUniformLayout(): void;
  10216. /**
  10217. * Sets the passed Effect "effect" with the Light information.
  10218. * @param effect The effect to update
  10219. * @param lightIndex The index of the light in the effect to update
  10220. * @returns The light
  10221. */
  10222. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10223. /**
  10224. * Returns the string "Light".
  10225. * @returns the class name
  10226. */
  10227. getClassName(): string;
  10228. /** @hidden */
  10229. readonly _isLight: boolean;
  10230. /**
  10231. * Converts the light information to a readable string for debug purpose.
  10232. * @param fullDetails Supports for multiple levels of logging within scene loading
  10233. * @returns the human readable light info
  10234. */
  10235. toString(fullDetails?: boolean): string;
  10236. /** @hidden */
  10237. protected _syncParentEnabledState(): void;
  10238. /**
  10239. * Set the enabled state of this node.
  10240. * @param value - the new enabled state
  10241. */
  10242. setEnabled(value: boolean): void;
  10243. /**
  10244. * Returns the Light associated shadow generator if any.
  10245. * @return the associated shadow generator.
  10246. */
  10247. getShadowGenerator(): Nullable<IShadowGenerator>;
  10248. /**
  10249. * Returns a Vector3, the absolute light position in the World.
  10250. * @returns the world space position of the light
  10251. */
  10252. getAbsolutePosition(): Vector3;
  10253. /**
  10254. * Specifies if the light will affect the passed mesh.
  10255. * @param mesh The mesh to test against the light
  10256. * @return true the mesh is affected otherwise, false.
  10257. */
  10258. canAffectMesh(mesh: AbstractMesh): boolean;
  10259. /**
  10260. * Sort function to order lights for rendering.
  10261. * @param a First Light object to compare to second.
  10262. * @param b Second Light object to compare first.
  10263. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10264. */
  10265. static CompareLightsPriority(a: Light, b: Light): number;
  10266. /**
  10267. * Releases resources associated with this node.
  10268. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10269. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10270. */
  10271. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10272. /**
  10273. * Returns the light type ID (integer).
  10274. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10275. */
  10276. getTypeID(): number;
  10277. /**
  10278. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10279. * @returns the scaled intensity in intensity mode unit
  10280. */
  10281. getScaledIntensity(): number;
  10282. /**
  10283. * Returns a new Light object, named "name", from the current one.
  10284. * @param name The name of the cloned light
  10285. * @returns the new created light
  10286. */
  10287. clone(name: string): Nullable<Light>;
  10288. /**
  10289. * Serializes the current light into a Serialization object.
  10290. * @returns the serialized object.
  10291. */
  10292. serialize(): any;
  10293. /**
  10294. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10295. * This new light is named "name" and added to the passed scene.
  10296. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10297. * @param name The friendly name of the light
  10298. * @param scene The scene the new light will belong to
  10299. * @returns the constructor function
  10300. */
  10301. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10302. /**
  10303. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10304. * @param parsedLight The JSON representation of the light
  10305. * @param scene The scene to create the parsed light in
  10306. * @returns the created light after parsing
  10307. */
  10308. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10309. private _hookArrayForExcluded;
  10310. private _hookArrayForIncludedOnly;
  10311. private _resyncMeshes;
  10312. /**
  10313. * Forces the meshes to update their light related information in their rendering used effects
  10314. * @hidden Internal Use Only
  10315. */
  10316. _markMeshesAsLightDirty(): void;
  10317. /**
  10318. * Recomputes the cached photometric scale if needed.
  10319. */
  10320. private _computePhotometricScale;
  10321. /**
  10322. * Returns the Photometric Scale according to the light type and intensity mode.
  10323. */
  10324. private _getPhotometricScale;
  10325. /**
  10326. * Reorder the light in the scene according to their defined priority.
  10327. * @hidden Internal Use Only
  10328. */
  10329. _reorderLightsInScene(): void;
  10330. /**
  10331. * Prepares the list of defines specific to the light type.
  10332. * @param defines the list of defines
  10333. * @param lightIndex defines the index of the light for the effect
  10334. */
  10335. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10336. }
  10337. }
  10338. declare module "babylonjs/Actions/action" {
  10339. import { Observable } from "babylonjs/Misc/observable";
  10340. import { Condition } from "babylonjs/Actions/condition";
  10341. import { ActionManager } from "babylonjs/Actions/actionManager";
  10342. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10343. /**
  10344. * Interface used to define Action
  10345. */
  10346. export interface IAction {
  10347. /**
  10348. * Trigger for the action
  10349. */
  10350. trigger: number;
  10351. /** Options of the trigger */
  10352. triggerOptions: any;
  10353. /**
  10354. * Gets the trigger parameters
  10355. * @returns the trigger parameters
  10356. */
  10357. getTriggerParameter(): any;
  10358. /**
  10359. * Internal only - executes current action event
  10360. * @hidden
  10361. */
  10362. _executeCurrent(evt?: ActionEvent): void;
  10363. /**
  10364. * Serialize placeholder for child classes
  10365. * @param parent of child
  10366. * @returns the serialized object
  10367. */
  10368. serialize(parent: any): any;
  10369. }
  10370. /**
  10371. * The action to be carried out following a trigger
  10372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10373. */
  10374. export class Action implements IAction {
  10375. /** the trigger, with or without parameters, for the action */
  10376. triggerOptions: any;
  10377. /**
  10378. * Trigger for the action
  10379. */
  10380. trigger: number;
  10381. /**
  10382. * Internal only - manager for action
  10383. * @hidden
  10384. */
  10385. _actionManager: ActionManager;
  10386. private _nextActiveAction;
  10387. private _child;
  10388. private _condition?;
  10389. private _triggerParameter;
  10390. /**
  10391. * An event triggered prior to action being executed.
  10392. */
  10393. onBeforeExecuteObservable: Observable<Action>;
  10394. /**
  10395. * Creates a new Action
  10396. * @param triggerOptions the trigger, with or without parameters, for the action
  10397. * @param condition an optional determinant of action
  10398. */
  10399. constructor(
  10400. /** the trigger, with or without parameters, for the action */
  10401. triggerOptions: any, condition?: Condition);
  10402. /**
  10403. * Internal only
  10404. * @hidden
  10405. */
  10406. _prepare(): void;
  10407. /**
  10408. * Gets the trigger parameters
  10409. * @returns the trigger parameters
  10410. */
  10411. getTriggerParameter(): any;
  10412. /**
  10413. * Internal only - executes current action event
  10414. * @hidden
  10415. */
  10416. _executeCurrent(evt?: ActionEvent): void;
  10417. /**
  10418. * Execute placeholder for child classes
  10419. * @param evt optional action event
  10420. */
  10421. execute(evt?: ActionEvent): void;
  10422. /**
  10423. * Skips to next active action
  10424. */
  10425. skipToNextActiveAction(): void;
  10426. /**
  10427. * Adds action to chain of actions, may be a DoNothingAction
  10428. * @param action defines the next action to execute
  10429. * @returns The action passed in
  10430. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10431. */
  10432. then(action: Action): Action;
  10433. /**
  10434. * Internal only
  10435. * @hidden
  10436. */
  10437. _getProperty(propertyPath: string): string;
  10438. /**
  10439. * Internal only
  10440. * @hidden
  10441. */
  10442. _getEffectiveTarget(target: any, propertyPath: string): any;
  10443. /**
  10444. * Serialize placeholder for child classes
  10445. * @param parent of child
  10446. * @returns the serialized object
  10447. */
  10448. serialize(parent: any): any;
  10449. /**
  10450. * Internal only called by serialize
  10451. * @hidden
  10452. */
  10453. protected _serialize(serializedAction: any, parent?: any): any;
  10454. /**
  10455. * Internal only
  10456. * @hidden
  10457. */
  10458. static _SerializeValueAsString: (value: any) => string;
  10459. /**
  10460. * Internal only
  10461. * @hidden
  10462. */
  10463. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10464. name: string;
  10465. targetType: string;
  10466. value: string;
  10467. };
  10468. }
  10469. }
  10470. declare module "babylonjs/Actions/condition" {
  10471. import { ActionManager } from "babylonjs/Actions/actionManager";
  10472. /**
  10473. * A Condition applied to an Action
  10474. */
  10475. export class Condition {
  10476. /**
  10477. * Internal only - manager for action
  10478. * @hidden
  10479. */
  10480. _actionManager: ActionManager;
  10481. /**
  10482. * Internal only
  10483. * @hidden
  10484. */
  10485. _evaluationId: number;
  10486. /**
  10487. * Internal only
  10488. * @hidden
  10489. */
  10490. _currentResult: boolean;
  10491. /**
  10492. * Creates a new Condition
  10493. * @param actionManager the manager of the action the condition is applied to
  10494. */
  10495. constructor(actionManager: ActionManager);
  10496. /**
  10497. * Check if the current condition is valid
  10498. * @returns a boolean
  10499. */
  10500. isValid(): boolean;
  10501. /**
  10502. * Internal only
  10503. * @hidden
  10504. */
  10505. _getProperty(propertyPath: string): string;
  10506. /**
  10507. * Internal only
  10508. * @hidden
  10509. */
  10510. _getEffectiveTarget(target: any, propertyPath: string): any;
  10511. /**
  10512. * Serialize placeholder for child classes
  10513. * @returns the serialized object
  10514. */
  10515. serialize(): any;
  10516. /**
  10517. * Internal only
  10518. * @hidden
  10519. */
  10520. protected _serialize(serializedCondition: any): any;
  10521. }
  10522. /**
  10523. * Defines specific conditional operators as extensions of Condition
  10524. */
  10525. export class ValueCondition extends Condition {
  10526. /** path to specify the property of the target the conditional operator uses */
  10527. propertyPath: string;
  10528. /** the value compared by the conditional operator against the current value of the property */
  10529. value: any;
  10530. /** the conditional operator, default ValueCondition.IsEqual */
  10531. operator: number;
  10532. /**
  10533. * Internal only
  10534. * @hidden
  10535. */
  10536. private static _IsEqual;
  10537. /**
  10538. * Internal only
  10539. * @hidden
  10540. */
  10541. private static _IsDifferent;
  10542. /**
  10543. * Internal only
  10544. * @hidden
  10545. */
  10546. private static _IsGreater;
  10547. /**
  10548. * Internal only
  10549. * @hidden
  10550. */
  10551. private static _IsLesser;
  10552. /**
  10553. * returns the number for IsEqual
  10554. */
  10555. static readonly IsEqual: number;
  10556. /**
  10557. * Returns the number for IsDifferent
  10558. */
  10559. static readonly IsDifferent: number;
  10560. /**
  10561. * Returns the number for IsGreater
  10562. */
  10563. static readonly IsGreater: number;
  10564. /**
  10565. * Returns the number for IsLesser
  10566. */
  10567. static readonly IsLesser: number;
  10568. /**
  10569. * Internal only The action manager for the condition
  10570. * @hidden
  10571. */
  10572. _actionManager: ActionManager;
  10573. /**
  10574. * Internal only
  10575. * @hidden
  10576. */
  10577. private _target;
  10578. /**
  10579. * Internal only
  10580. * @hidden
  10581. */
  10582. private _effectiveTarget;
  10583. /**
  10584. * Internal only
  10585. * @hidden
  10586. */
  10587. private _property;
  10588. /**
  10589. * Creates a new ValueCondition
  10590. * @param actionManager manager for the action the condition applies to
  10591. * @param target for the action
  10592. * @param propertyPath path to specify the property of the target the conditional operator uses
  10593. * @param value the value compared by the conditional operator against the current value of the property
  10594. * @param operator the conditional operator, default ValueCondition.IsEqual
  10595. */
  10596. constructor(actionManager: ActionManager, target: any,
  10597. /** path to specify the property of the target the conditional operator uses */
  10598. propertyPath: string,
  10599. /** the value compared by the conditional operator against the current value of the property */
  10600. value: any,
  10601. /** the conditional operator, default ValueCondition.IsEqual */
  10602. operator?: number);
  10603. /**
  10604. * Compares the given value with the property value for the specified conditional operator
  10605. * @returns the result of the comparison
  10606. */
  10607. isValid(): boolean;
  10608. /**
  10609. * Serialize the ValueCondition into a JSON compatible object
  10610. * @returns serialization object
  10611. */
  10612. serialize(): any;
  10613. /**
  10614. * Gets the name of the conditional operator for the ValueCondition
  10615. * @param operator the conditional operator
  10616. * @returns the name
  10617. */
  10618. static GetOperatorName(operator: number): string;
  10619. }
  10620. /**
  10621. * Defines a predicate condition as an extension of Condition
  10622. */
  10623. export class PredicateCondition extends Condition {
  10624. /** defines the predicate function used to validate the condition */
  10625. predicate: () => boolean;
  10626. /**
  10627. * Internal only - manager for action
  10628. * @hidden
  10629. */
  10630. _actionManager: ActionManager;
  10631. /**
  10632. * Creates a new PredicateCondition
  10633. * @param actionManager manager for the action the condition applies to
  10634. * @param predicate defines the predicate function used to validate the condition
  10635. */
  10636. constructor(actionManager: ActionManager,
  10637. /** defines the predicate function used to validate the condition */
  10638. predicate: () => boolean);
  10639. /**
  10640. * @returns the validity of the predicate condition
  10641. */
  10642. isValid(): boolean;
  10643. }
  10644. /**
  10645. * Defines a state condition as an extension of Condition
  10646. */
  10647. export class StateCondition extends Condition {
  10648. /** Value to compare with target state */
  10649. value: string;
  10650. /**
  10651. * Internal only - manager for action
  10652. * @hidden
  10653. */
  10654. _actionManager: ActionManager;
  10655. /**
  10656. * Internal only
  10657. * @hidden
  10658. */
  10659. private _target;
  10660. /**
  10661. * Creates a new StateCondition
  10662. * @param actionManager manager for the action the condition applies to
  10663. * @param target of the condition
  10664. * @param value to compare with target state
  10665. */
  10666. constructor(actionManager: ActionManager, target: any,
  10667. /** Value to compare with target state */
  10668. value: string);
  10669. /**
  10670. * Gets a boolean indicating if the current condition is met
  10671. * @returns the validity of the state
  10672. */
  10673. isValid(): boolean;
  10674. /**
  10675. * Serialize the StateCondition into a JSON compatible object
  10676. * @returns serialization object
  10677. */
  10678. serialize(): any;
  10679. }
  10680. }
  10681. declare module "babylonjs/Actions/directActions" {
  10682. import { Action } from "babylonjs/Actions/action";
  10683. import { Condition } from "babylonjs/Actions/condition";
  10684. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10685. /**
  10686. * This defines an action responsible to toggle a boolean once triggered.
  10687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10688. */
  10689. export class SwitchBooleanAction extends Action {
  10690. /**
  10691. * The path to the boolean property in the target object
  10692. */
  10693. propertyPath: string;
  10694. private _target;
  10695. private _effectiveTarget;
  10696. private _property;
  10697. /**
  10698. * Instantiate the action
  10699. * @param triggerOptions defines the trigger options
  10700. * @param target defines the object containing the boolean
  10701. * @param propertyPath defines the path to the boolean property in the target object
  10702. * @param condition defines the trigger related conditions
  10703. */
  10704. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10705. /** @hidden */
  10706. _prepare(): void;
  10707. /**
  10708. * Execute the action toggle the boolean value.
  10709. */
  10710. execute(): void;
  10711. /**
  10712. * Serializes the actions and its related information.
  10713. * @param parent defines the object to serialize in
  10714. * @returns the serialized object
  10715. */
  10716. serialize(parent: any): any;
  10717. }
  10718. /**
  10719. * This defines an action responsible to set a the state field of the target
  10720. * to a desired value once triggered.
  10721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10722. */
  10723. export class SetStateAction extends Action {
  10724. /**
  10725. * The value to store in the state field.
  10726. */
  10727. value: string;
  10728. private _target;
  10729. /**
  10730. * Instantiate the action
  10731. * @param triggerOptions defines the trigger options
  10732. * @param target defines the object containing the state property
  10733. * @param value defines the value to store in the state field
  10734. * @param condition defines the trigger related conditions
  10735. */
  10736. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10737. /**
  10738. * Execute the action and store the value on the target state property.
  10739. */
  10740. execute(): void;
  10741. /**
  10742. * Serializes the actions and its related information.
  10743. * @param parent defines the object to serialize in
  10744. * @returns the serialized object
  10745. */
  10746. serialize(parent: any): any;
  10747. }
  10748. /**
  10749. * This defines an action responsible to set a property of the target
  10750. * to a desired value once triggered.
  10751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10752. */
  10753. export class SetValueAction extends Action {
  10754. /**
  10755. * The path of the property to set in the target.
  10756. */
  10757. propertyPath: string;
  10758. /**
  10759. * The value to set in the property
  10760. */
  10761. value: any;
  10762. private _target;
  10763. private _effectiveTarget;
  10764. private _property;
  10765. /**
  10766. * Instantiate the action
  10767. * @param triggerOptions defines the trigger options
  10768. * @param target defines the object containing the property
  10769. * @param propertyPath defines the path of the property to set in the target
  10770. * @param value defines the value to set in the property
  10771. * @param condition defines the trigger related conditions
  10772. */
  10773. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10774. /** @hidden */
  10775. _prepare(): void;
  10776. /**
  10777. * Execute the action and set the targetted property to the desired value.
  10778. */
  10779. execute(): void;
  10780. /**
  10781. * Serializes the actions and its related information.
  10782. * @param parent defines the object to serialize in
  10783. * @returns the serialized object
  10784. */
  10785. serialize(parent: any): any;
  10786. }
  10787. /**
  10788. * This defines an action responsible to increment the target value
  10789. * to a desired value once triggered.
  10790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10791. */
  10792. export class IncrementValueAction extends Action {
  10793. /**
  10794. * The path of the property to increment in the target.
  10795. */
  10796. propertyPath: string;
  10797. /**
  10798. * The value we should increment the property by.
  10799. */
  10800. value: any;
  10801. private _target;
  10802. private _effectiveTarget;
  10803. private _property;
  10804. /**
  10805. * Instantiate the action
  10806. * @param triggerOptions defines the trigger options
  10807. * @param target defines the object containing the property
  10808. * @param propertyPath defines the path of the property to increment in the target
  10809. * @param value defines the value value we should increment the property by
  10810. * @param condition defines the trigger related conditions
  10811. */
  10812. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10813. /** @hidden */
  10814. _prepare(): void;
  10815. /**
  10816. * Execute the action and increment the target of the value amount.
  10817. */
  10818. execute(): void;
  10819. /**
  10820. * Serializes the actions and its related information.
  10821. * @param parent defines the object to serialize in
  10822. * @returns the serialized object
  10823. */
  10824. serialize(parent: any): any;
  10825. }
  10826. /**
  10827. * This defines an action responsible to start an animation once triggered.
  10828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10829. */
  10830. export class PlayAnimationAction extends Action {
  10831. /**
  10832. * Where the animation should start (animation frame)
  10833. */
  10834. from: number;
  10835. /**
  10836. * Where the animation should stop (animation frame)
  10837. */
  10838. to: number;
  10839. /**
  10840. * Define if the animation should loop or stop after the first play.
  10841. */
  10842. loop?: boolean;
  10843. private _target;
  10844. /**
  10845. * Instantiate the action
  10846. * @param triggerOptions defines the trigger options
  10847. * @param target defines the target animation or animation name
  10848. * @param from defines from where the animation should start (animation frame)
  10849. * @param end defines where the animation should stop (animation frame)
  10850. * @param loop defines if the animation should loop or stop after the first play
  10851. * @param condition defines the trigger related conditions
  10852. */
  10853. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10854. /** @hidden */
  10855. _prepare(): void;
  10856. /**
  10857. * Execute the action and play the animation.
  10858. */
  10859. execute(): void;
  10860. /**
  10861. * Serializes the actions and its related information.
  10862. * @param parent defines the object to serialize in
  10863. * @returns the serialized object
  10864. */
  10865. serialize(parent: any): any;
  10866. }
  10867. /**
  10868. * This defines an action responsible to stop an animation once triggered.
  10869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10870. */
  10871. export class StopAnimationAction extends Action {
  10872. private _target;
  10873. /**
  10874. * Instantiate the action
  10875. * @param triggerOptions defines the trigger options
  10876. * @param target defines the target animation or animation name
  10877. * @param condition defines the trigger related conditions
  10878. */
  10879. constructor(triggerOptions: any, target: any, condition?: Condition);
  10880. /** @hidden */
  10881. _prepare(): void;
  10882. /**
  10883. * Execute the action and stop the animation.
  10884. */
  10885. execute(): void;
  10886. /**
  10887. * Serializes the actions and its related information.
  10888. * @param parent defines the object to serialize in
  10889. * @returns the serialized object
  10890. */
  10891. serialize(parent: any): any;
  10892. }
  10893. /**
  10894. * This defines an action responsible that does nothing once triggered.
  10895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10896. */
  10897. export class DoNothingAction extends Action {
  10898. /**
  10899. * Instantiate the action
  10900. * @param triggerOptions defines the trigger options
  10901. * @param condition defines the trigger related conditions
  10902. */
  10903. constructor(triggerOptions?: any, condition?: Condition);
  10904. /**
  10905. * Execute the action and do nothing.
  10906. */
  10907. execute(): void;
  10908. /**
  10909. * Serializes the actions and its related information.
  10910. * @param parent defines the object to serialize in
  10911. * @returns the serialized object
  10912. */
  10913. serialize(parent: any): any;
  10914. }
  10915. /**
  10916. * This defines an action responsible to trigger several actions once triggered.
  10917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10918. */
  10919. export class CombineAction extends Action {
  10920. /**
  10921. * The list of aggregated animations to run.
  10922. */
  10923. children: Action[];
  10924. /**
  10925. * Instantiate the action
  10926. * @param triggerOptions defines the trigger options
  10927. * @param children defines the list of aggregated animations to run
  10928. * @param condition defines the trigger related conditions
  10929. */
  10930. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10931. /** @hidden */
  10932. _prepare(): void;
  10933. /**
  10934. * Execute the action and executes all the aggregated actions.
  10935. */
  10936. execute(evt: ActionEvent): void;
  10937. /**
  10938. * Serializes the actions and its related information.
  10939. * @param parent defines the object to serialize in
  10940. * @returns the serialized object
  10941. */
  10942. serialize(parent: any): any;
  10943. }
  10944. /**
  10945. * This defines an action responsible to run code (external event) once triggered.
  10946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10947. */
  10948. export class ExecuteCodeAction extends Action {
  10949. /**
  10950. * The callback function to run.
  10951. */
  10952. func: (evt: ActionEvent) => void;
  10953. /**
  10954. * Instantiate the action
  10955. * @param triggerOptions defines the trigger options
  10956. * @param func defines the callback function to run
  10957. * @param condition defines the trigger related conditions
  10958. */
  10959. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10960. /**
  10961. * Execute the action and run the attached code.
  10962. */
  10963. execute(evt: ActionEvent): void;
  10964. }
  10965. /**
  10966. * This defines an action responsible to set the parent property of the target once triggered.
  10967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10968. */
  10969. export class SetParentAction extends Action {
  10970. private _parent;
  10971. private _target;
  10972. /**
  10973. * Instantiate the action
  10974. * @param triggerOptions defines the trigger options
  10975. * @param target defines the target containing the parent property
  10976. * @param parent defines from where the animation should start (animation frame)
  10977. * @param condition defines the trigger related conditions
  10978. */
  10979. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10980. /** @hidden */
  10981. _prepare(): void;
  10982. /**
  10983. * Execute the action and set the parent property.
  10984. */
  10985. execute(): void;
  10986. /**
  10987. * Serializes the actions and its related information.
  10988. * @param parent defines the object to serialize in
  10989. * @returns the serialized object
  10990. */
  10991. serialize(parent: any): any;
  10992. }
  10993. }
  10994. declare module "babylonjs/Actions/actionManager" {
  10995. import { Nullable } from "babylonjs/types";
  10996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10997. import { Scene } from "babylonjs/scene";
  10998. import { Action } from "babylonjs/Actions/action";
  10999. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11000. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11001. /**
  11002. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11003. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11005. */
  11006. export class ActionManager extends AbstractActionManager {
  11007. /**
  11008. * Nothing
  11009. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11010. */
  11011. static readonly NothingTrigger: number;
  11012. /**
  11013. * On pick
  11014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11015. */
  11016. static readonly OnPickTrigger: number;
  11017. /**
  11018. * On left pick
  11019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11020. */
  11021. static readonly OnLeftPickTrigger: number;
  11022. /**
  11023. * On right pick
  11024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11025. */
  11026. static readonly OnRightPickTrigger: number;
  11027. /**
  11028. * On center pick
  11029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11030. */
  11031. static readonly OnCenterPickTrigger: number;
  11032. /**
  11033. * On pick down
  11034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11035. */
  11036. static readonly OnPickDownTrigger: number;
  11037. /**
  11038. * On double pick
  11039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11040. */
  11041. static readonly OnDoublePickTrigger: number;
  11042. /**
  11043. * On pick up
  11044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11045. */
  11046. static readonly OnPickUpTrigger: number;
  11047. /**
  11048. * On pick out.
  11049. * This trigger will only be raised if you also declared a OnPickDown
  11050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11051. */
  11052. static readonly OnPickOutTrigger: number;
  11053. /**
  11054. * On long press
  11055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11056. */
  11057. static readonly OnLongPressTrigger: number;
  11058. /**
  11059. * On pointer over
  11060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11061. */
  11062. static readonly OnPointerOverTrigger: number;
  11063. /**
  11064. * On pointer out
  11065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11066. */
  11067. static readonly OnPointerOutTrigger: number;
  11068. /**
  11069. * On every frame
  11070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11071. */
  11072. static readonly OnEveryFrameTrigger: number;
  11073. /**
  11074. * On intersection enter
  11075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11076. */
  11077. static readonly OnIntersectionEnterTrigger: number;
  11078. /**
  11079. * On intersection exit
  11080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11081. */
  11082. static readonly OnIntersectionExitTrigger: number;
  11083. /**
  11084. * On key down
  11085. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11086. */
  11087. static readonly OnKeyDownTrigger: number;
  11088. /**
  11089. * On key up
  11090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11091. */
  11092. static readonly OnKeyUpTrigger: number;
  11093. private _scene;
  11094. /**
  11095. * Creates a new action manager
  11096. * @param scene defines the hosting scene
  11097. */
  11098. constructor(scene: Scene);
  11099. /**
  11100. * Releases all associated resources
  11101. */
  11102. dispose(): void;
  11103. /**
  11104. * Gets hosting scene
  11105. * @returns the hosting scene
  11106. */
  11107. getScene(): Scene;
  11108. /**
  11109. * Does this action manager handles actions of any of the given triggers
  11110. * @param triggers defines the triggers to be tested
  11111. * @return a boolean indicating whether one (or more) of the triggers is handled
  11112. */
  11113. hasSpecificTriggers(triggers: number[]): boolean;
  11114. /**
  11115. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11116. * speed.
  11117. * @param triggerA defines the trigger to be tested
  11118. * @param triggerB defines the trigger to be tested
  11119. * @return a boolean indicating whether one (or more) of the triggers is handled
  11120. */
  11121. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11122. /**
  11123. * Does this action manager handles actions of a given trigger
  11124. * @param trigger defines the trigger to be tested
  11125. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11126. * @return whether the trigger is handled
  11127. */
  11128. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11129. /**
  11130. * Does this action manager has pointer triggers
  11131. */
  11132. readonly hasPointerTriggers: boolean;
  11133. /**
  11134. * Does this action manager has pick triggers
  11135. */
  11136. readonly hasPickTriggers: boolean;
  11137. /**
  11138. * Registers an action to this action manager
  11139. * @param action defines the action to be registered
  11140. * @return the action amended (prepared) after registration
  11141. */
  11142. registerAction(action: Action): Nullable<Action>;
  11143. /**
  11144. * Unregisters an action to this action manager
  11145. * @param action defines the action to be unregistered
  11146. * @return a boolean indicating whether the action has been unregistered
  11147. */
  11148. unregisterAction(action: Action): Boolean;
  11149. /**
  11150. * Process a specific trigger
  11151. * @param trigger defines the trigger to process
  11152. * @param evt defines the event details to be processed
  11153. */
  11154. processTrigger(trigger: number, evt?: IActionEvent): void;
  11155. /** @hidden */
  11156. _getEffectiveTarget(target: any, propertyPath: string): any;
  11157. /** @hidden */
  11158. _getProperty(propertyPath: string): string;
  11159. /**
  11160. * Serialize this manager to a JSON object
  11161. * @param name defines the property name to store this manager
  11162. * @returns a JSON representation of this manager
  11163. */
  11164. serialize(name: string): any;
  11165. /**
  11166. * Creates a new ActionManager from a JSON data
  11167. * @param parsedActions defines the JSON data to read from
  11168. * @param object defines the hosting mesh
  11169. * @param scene defines the hosting scene
  11170. */
  11171. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11172. /**
  11173. * Get a trigger name by index
  11174. * @param trigger defines the trigger index
  11175. * @returns a trigger name
  11176. */
  11177. static GetTriggerName(trigger: number): string;
  11178. }
  11179. }
  11180. declare module "babylonjs/Culling/ray" {
  11181. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11182. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11184. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11185. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11186. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11187. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11188. /**
  11189. * Class representing a ray with position and direction
  11190. */
  11191. export class Ray {
  11192. /** origin point */
  11193. origin: Vector3;
  11194. /** direction */
  11195. direction: Vector3;
  11196. /** length of the ray */
  11197. length: number;
  11198. private static readonly TmpVector3;
  11199. private _tmpRay;
  11200. /**
  11201. * Creates a new ray
  11202. * @param origin origin point
  11203. * @param direction direction
  11204. * @param length length of the ray
  11205. */
  11206. constructor(
  11207. /** origin point */
  11208. origin: Vector3,
  11209. /** direction */
  11210. direction: Vector3,
  11211. /** length of the ray */
  11212. length?: number);
  11213. /**
  11214. * Checks if the ray intersects a box
  11215. * @param minimum bound of the box
  11216. * @param maximum bound of the box
  11217. * @param intersectionTreshold extra extend to be added to the box in all direction
  11218. * @returns if the box was hit
  11219. */
  11220. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11221. /**
  11222. * Checks if the ray intersects a box
  11223. * @param box the bounding box to check
  11224. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11225. * @returns if the box was hit
  11226. */
  11227. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11228. /**
  11229. * If the ray hits a sphere
  11230. * @param sphere the bounding sphere to check
  11231. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11232. * @returns true if it hits the sphere
  11233. */
  11234. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11235. /**
  11236. * If the ray hits a triange
  11237. * @param vertex0 triangle vertex
  11238. * @param vertex1 triangle vertex
  11239. * @param vertex2 triangle vertex
  11240. * @returns intersection information if hit
  11241. */
  11242. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11243. /**
  11244. * Checks if ray intersects a plane
  11245. * @param plane the plane to check
  11246. * @returns the distance away it was hit
  11247. */
  11248. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11249. /**
  11250. * Checks if ray intersects a mesh
  11251. * @param mesh the mesh to check
  11252. * @param fastCheck if only the bounding box should checked
  11253. * @returns picking info of the intersecton
  11254. */
  11255. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11256. /**
  11257. * Checks if ray intersects a mesh
  11258. * @param meshes the meshes to check
  11259. * @param fastCheck if only the bounding box should checked
  11260. * @param results array to store result in
  11261. * @returns Array of picking infos
  11262. */
  11263. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11264. private _comparePickingInfo;
  11265. private static smallnum;
  11266. private static rayl;
  11267. /**
  11268. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11269. * @param sega the first point of the segment to test the intersection against
  11270. * @param segb the second point of the segment to test the intersection against
  11271. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11272. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11273. */
  11274. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11275. /**
  11276. * Update the ray from viewport position
  11277. * @param x position
  11278. * @param y y position
  11279. * @param viewportWidth viewport width
  11280. * @param viewportHeight viewport height
  11281. * @param world world matrix
  11282. * @param view view matrix
  11283. * @param projection projection matrix
  11284. * @returns this ray updated
  11285. */
  11286. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11287. /**
  11288. * Creates a ray with origin and direction of 0,0,0
  11289. * @returns the new ray
  11290. */
  11291. static Zero(): Ray;
  11292. /**
  11293. * Creates a new ray from screen space and viewport
  11294. * @param x position
  11295. * @param y y position
  11296. * @param viewportWidth viewport width
  11297. * @param viewportHeight viewport height
  11298. * @param world world matrix
  11299. * @param view view matrix
  11300. * @param projection projection matrix
  11301. * @returns new ray
  11302. */
  11303. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11304. /**
  11305. * 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
  11306. * transformed to the given world matrix.
  11307. * @param origin The origin point
  11308. * @param end The end point
  11309. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11310. * @returns the new ray
  11311. */
  11312. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11313. /**
  11314. * Transforms a ray by a matrix
  11315. * @param ray ray to transform
  11316. * @param matrix matrix to apply
  11317. * @returns the resulting new ray
  11318. */
  11319. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11320. /**
  11321. * Transforms a ray by a matrix
  11322. * @param ray ray to transform
  11323. * @param matrix matrix to apply
  11324. * @param result ray to store result in
  11325. */
  11326. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11327. /**
  11328. * Unproject a ray from screen space to object space
  11329. * @param sourceX defines the screen space x coordinate to use
  11330. * @param sourceY defines the screen space y coordinate to use
  11331. * @param viewportWidth defines the current width of the viewport
  11332. * @param viewportHeight defines the current height of the viewport
  11333. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11334. * @param view defines the view matrix to use
  11335. * @param projection defines the projection matrix to use
  11336. */
  11337. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11338. }
  11339. module "babylonjs/scene" {
  11340. interface Scene {
  11341. /** @hidden */
  11342. _tempPickingRay: Nullable<Ray>;
  11343. /** @hidden */
  11344. _cachedRayForTransform: Ray;
  11345. /** @hidden */
  11346. _pickWithRayInverseMatrix: Matrix;
  11347. /** @hidden */
  11348. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11349. /** @hidden */
  11350. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  11351. }
  11352. }
  11353. }
  11354. declare module "babylonjs/sceneComponent" {
  11355. import { Scene } from "babylonjs/scene";
  11356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11357. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11358. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11359. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11360. import { Nullable } from "babylonjs/types";
  11361. import { Camera } from "babylonjs/Cameras/camera";
  11362. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11363. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11364. import { AbstractScene } from "babylonjs/abstractScene";
  11365. /**
  11366. * Groups all the scene component constants in one place to ease maintenance.
  11367. * @hidden
  11368. */
  11369. export class SceneComponentConstants {
  11370. static readonly NAME_EFFECTLAYER: string;
  11371. static readonly NAME_LAYER: string;
  11372. static readonly NAME_LENSFLARESYSTEM: string;
  11373. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11374. static readonly NAME_PARTICLESYSTEM: string;
  11375. static readonly NAME_GAMEPAD: string;
  11376. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11377. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11378. static readonly NAME_DEPTHRENDERER: string;
  11379. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11380. static readonly NAME_SPRITE: string;
  11381. static readonly NAME_OUTLINERENDERER: string;
  11382. static readonly NAME_PROCEDURALTEXTURE: string;
  11383. static readonly NAME_SHADOWGENERATOR: string;
  11384. static readonly NAME_OCTREE: string;
  11385. static readonly NAME_PHYSICSENGINE: string;
  11386. static readonly NAME_AUDIO: string;
  11387. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11388. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11389. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11390. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11391. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11392. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11393. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11394. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11395. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11396. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11397. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11398. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11399. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11400. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11401. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11402. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11403. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11404. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11405. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11406. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11407. static readonly STEP_AFTERRENDER_AUDIO: number;
  11408. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11409. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11410. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11411. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11412. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11413. static readonly STEP_POINTERMOVE_SPRITE: number;
  11414. static readonly STEP_POINTERDOWN_SPRITE: number;
  11415. static readonly STEP_POINTERUP_SPRITE: number;
  11416. }
  11417. /**
  11418. * This represents a scene component.
  11419. *
  11420. * This is used to decouple the dependency the scene is having on the different workloads like
  11421. * layers, post processes...
  11422. */
  11423. export interface ISceneComponent {
  11424. /**
  11425. * The name of the component. Each component must have a unique name.
  11426. */
  11427. name: string;
  11428. /**
  11429. * The scene the component belongs to.
  11430. */
  11431. scene: Scene;
  11432. /**
  11433. * Register the component to one instance of a scene.
  11434. */
  11435. register(): void;
  11436. /**
  11437. * Rebuilds the elements related to this component in case of
  11438. * context lost for instance.
  11439. */
  11440. rebuild(): void;
  11441. /**
  11442. * Disposes the component and the associated ressources.
  11443. */
  11444. dispose(): void;
  11445. }
  11446. /**
  11447. * This represents a SERIALIZABLE scene component.
  11448. *
  11449. * This extends Scene Component to add Serialization methods on top.
  11450. */
  11451. export interface ISceneSerializableComponent extends ISceneComponent {
  11452. /**
  11453. * Adds all the element from the container to the scene
  11454. * @param container the container holding the elements
  11455. */
  11456. addFromContainer(container: AbstractScene): void;
  11457. /**
  11458. * Removes all the elements in the container from the scene
  11459. * @param container contains the elements to remove
  11460. */
  11461. removeFromContainer(container: AbstractScene): void;
  11462. /**
  11463. * Serializes the component data to the specified json object
  11464. * @param serializationObject The object to serialize to
  11465. */
  11466. serialize(serializationObject: any): void;
  11467. }
  11468. /**
  11469. * Strong typing of a Mesh related stage step action
  11470. */
  11471. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11472. /**
  11473. * Strong typing of a Evaluate Sub Mesh related stage step action
  11474. */
  11475. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11476. /**
  11477. * Strong typing of a Active Mesh related stage step action
  11478. */
  11479. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11480. /**
  11481. * Strong typing of a Camera related stage step action
  11482. */
  11483. export type CameraStageAction = (camera: Camera) => void;
  11484. /**
  11485. * Strong typing of a Render Target related stage step action
  11486. */
  11487. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11488. /**
  11489. * Strong typing of a RenderingGroup related stage step action
  11490. */
  11491. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11492. /**
  11493. * Strong typing of a Mesh Render related stage step action
  11494. */
  11495. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11496. /**
  11497. * Strong typing of a simple stage step action
  11498. */
  11499. export type SimpleStageAction = () => void;
  11500. /**
  11501. * Strong typing of a render target action.
  11502. */
  11503. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11504. /**
  11505. * Strong typing of a pointer move action.
  11506. */
  11507. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11508. /**
  11509. * Strong typing of a pointer up/down action.
  11510. */
  11511. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11512. /**
  11513. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11514. * @hidden
  11515. */
  11516. export class Stage<T extends Function> extends Array<{
  11517. index: number;
  11518. component: ISceneComponent;
  11519. action: T;
  11520. }> {
  11521. /**
  11522. * Hide ctor from the rest of the world.
  11523. * @param items The items to add.
  11524. */
  11525. private constructor();
  11526. /**
  11527. * Creates a new Stage.
  11528. * @returns A new instance of a Stage
  11529. */
  11530. static Create<T extends Function>(): Stage<T>;
  11531. /**
  11532. * Registers a step in an ordered way in the targeted stage.
  11533. * @param index Defines the position to register the step in
  11534. * @param component Defines the component attached to the step
  11535. * @param action Defines the action to launch during the step
  11536. */
  11537. registerStep(index: number, component: ISceneComponent, action: T): void;
  11538. /**
  11539. * Clears all the steps from the stage.
  11540. */
  11541. clear(): void;
  11542. }
  11543. }
  11544. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11545. import { Nullable } from "babylonjs/types";
  11546. import { Observable } from "babylonjs/Misc/observable";
  11547. import { Scene } from "babylonjs/scene";
  11548. import { Sprite } from "babylonjs/Sprites/sprite";
  11549. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11550. import { Ray } from "babylonjs/Culling/ray";
  11551. import { Camera } from "babylonjs/Cameras/camera";
  11552. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11553. import { ISceneComponent } from "babylonjs/sceneComponent";
  11554. module "babylonjs/scene" {
  11555. interface Scene {
  11556. /** @hidden */
  11557. _pointerOverSprite: Nullable<Sprite>;
  11558. /** @hidden */
  11559. _pickedDownSprite: Nullable<Sprite>;
  11560. /** @hidden */
  11561. _tempSpritePickingRay: Nullable<Ray>;
  11562. /**
  11563. * All of the sprite managers added to this scene
  11564. * @see http://doc.babylonjs.com/babylon101/sprites
  11565. */
  11566. spriteManagers: Array<ISpriteManager>;
  11567. /**
  11568. * An event triggered when sprites rendering is about to start
  11569. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11570. */
  11571. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11572. /**
  11573. * An event triggered when sprites rendering is done
  11574. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11575. */
  11576. onAfterSpritesRenderingObservable: Observable<Scene>;
  11577. /** @hidden */
  11578. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11579. /** Launch a ray to try to pick a sprite in the scene
  11580. * @param x position on screen
  11581. * @param y position on screen
  11582. * @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
  11583. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11584. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11585. * @returns a PickingInfo
  11586. */
  11587. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11588. /** Use the given ray to pick a sprite in the scene
  11589. * @param ray The ray (in world space) to use to pick meshes
  11590. * @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
  11591. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11592. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11593. * @returns a PickingInfo
  11594. */
  11595. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11596. /**
  11597. * Force the sprite under the pointer
  11598. * @param sprite defines the sprite to use
  11599. */
  11600. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11601. /**
  11602. * Gets the sprite under the pointer
  11603. * @returns a Sprite or null if no sprite is under the pointer
  11604. */
  11605. getPointerOverSprite(): Nullable<Sprite>;
  11606. }
  11607. }
  11608. /**
  11609. * Defines the sprite scene component responsible to manage sprites
  11610. * in a given scene.
  11611. */
  11612. export class SpriteSceneComponent implements ISceneComponent {
  11613. /**
  11614. * The component name helpfull to identify the component in the list of scene components.
  11615. */
  11616. readonly name: string;
  11617. /**
  11618. * The scene the component belongs to.
  11619. */
  11620. scene: Scene;
  11621. /** @hidden */
  11622. private _spritePredicate;
  11623. /**
  11624. * Creates a new instance of the component for the given scene
  11625. * @param scene Defines the scene to register the component in
  11626. */
  11627. constructor(scene: Scene);
  11628. /**
  11629. * Registers the component in a given scene
  11630. */
  11631. register(): void;
  11632. /**
  11633. * Rebuilds the elements related to this component in case of
  11634. * context lost for instance.
  11635. */
  11636. rebuild(): void;
  11637. /**
  11638. * Disposes the component and the associated ressources.
  11639. */
  11640. dispose(): void;
  11641. private _pickSpriteButKeepRay;
  11642. private _pointerMove;
  11643. private _pointerDown;
  11644. private _pointerUp;
  11645. }
  11646. }
  11647. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11648. /** @hidden */
  11649. export var fogFragmentDeclaration: {
  11650. name: string;
  11651. shader: string;
  11652. };
  11653. }
  11654. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11655. /** @hidden */
  11656. export var fogFragment: {
  11657. name: string;
  11658. shader: string;
  11659. };
  11660. }
  11661. declare module "babylonjs/Shaders/sprites.fragment" {
  11662. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11663. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11664. /** @hidden */
  11665. export var spritesPixelShader: {
  11666. name: string;
  11667. shader: string;
  11668. };
  11669. }
  11670. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11671. /** @hidden */
  11672. export var fogVertexDeclaration: {
  11673. name: string;
  11674. shader: string;
  11675. };
  11676. }
  11677. declare module "babylonjs/Shaders/sprites.vertex" {
  11678. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11679. /** @hidden */
  11680. export var spritesVertexShader: {
  11681. name: string;
  11682. shader: string;
  11683. };
  11684. }
  11685. declare module "babylonjs/Sprites/spriteManager" {
  11686. import { IDisposable, Scene } from "babylonjs/scene";
  11687. import { Nullable } from "babylonjs/types";
  11688. import { Observable } from "babylonjs/Misc/observable";
  11689. import { Sprite } from "babylonjs/Sprites/sprite";
  11690. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11691. import { Camera } from "babylonjs/Cameras/camera";
  11692. import { Texture } from "babylonjs/Materials/Textures/texture";
  11693. import "babylonjs/Shaders/sprites.fragment";
  11694. import "babylonjs/Shaders/sprites.vertex";
  11695. import { Ray } from "babylonjs/Culling/ray";
  11696. /**
  11697. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11698. */
  11699. export interface ISpriteManager extends IDisposable {
  11700. /**
  11701. * Restricts the camera to viewing objects with the same layerMask.
  11702. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11703. */
  11704. layerMask: number;
  11705. /**
  11706. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11707. */
  11708. isPickable: boolean;
  11709. /**
  11710. * Specifies the rendering group id for this mesh (0 by default)
  11711. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11712. */
  11713. renderingGroupId: number;
  11714. /**
  11715. * Defines the list of sprites managed by the manager.
  11716. */
  11717. sprites: Array<Sprite>;
  11718. /**
  11719. * Tests the intersection of a sprite with a specific ray.
  11720. * @param ray The ray we are sending to test the collision
  11721. * @param camera The camera space we are sending rays in
  11722. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11723. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11724. * @returns picking info or null.
  11725. */
  11726. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11727. /**
  11728. * Renders the list of sprites on screen.
  11729. */
  11730. render(): void;
  11731. }
  11732. /**
  11733. * Class used to manage multiple sprites on the same spritesheet
  11734. * @see http://doc.babylonjs.com/babylon101/sprites
  11735. */
  11736. export class SpriteManager implements ISpriteManager {
  11737. /** defines the manager's name */
  11738. name: string;
  11739. /** Gets the list of sprites */
  11740. sprites: Sprite[];
  11741. /** Gets or sets the rendering group id (0 by default) */
  11742. renderingGroupId: number;
  11743. /** Gets or sets camera layer mask */
  11744. layerMask: number;
  11745. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11746. fogEnabled: boolean;
  11747. /** Gets or sets a boolean indicating if the sprites are pickable */
  11748. isPickable: boolean;
  11749. /** Defines the default width of a cell in the spritesheet */
  11750. cellWidth: number;
  11751. /** Defines the default height of a cell in the spritesheet */
  11752. cellHeight: number;
  11753. /**
  11754. * An event triggered when the manager is disposed.
  11755. */
  11756. onDisposeObservable: Observable<SpriteManager>;
  11757. private _onDisposeObserver;
  11758. /**
  11759. * Callback called when the manager is disposed
  11760. */
  11761. onDispose: () => void;
  11762. private _capacity;
  11763. private _spriteTexture;
  11764. private _epsilon;
  11765. private _scene;
  11766. private _vertexData;
  11767. private _buffer;
  11768. private _vertexBuffers;
  11769. private _indexBuffer;
  11770. private _effectBase;
  11771. private _effectFog;
  11772. /**
  11773. * Gets or sets the spritesheet texture
  11774. */
  11775. texture: Texture;
  11776. /**
  11777. * Creates a new sprite manager
  11778. * @param name defines the manager's name
  11779. * @param imgUrl defines the sprite sheet url
  11780. * @param capacity defines the maximum allowed number of sprites
  11781. * @param cellSize defines the size of a sprite cell
  11782. * @param scene defines the hosting scene
  11783. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11784. * @param samplingMode defines the smapling mode to use with spritesheet
  11785. */
  11786. constructor(
  11787. /** defines the manager's name */
  11788. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11789. private _appendSpriteVertex;
  11790. /**
  11791. * Intersects the sprites with a ray
  11792. * @param ray defines the ray to intersect with
  11793. * @param camera defines the current active camera
  11794. * @param predicate defines a predicate used to select candidate sprites
  11795. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11796. * @returns null if no hit or a PickingInfo
  11797. */
  11798. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11799. /**
  11800. * Render all child sprites
  11801. */
  11802. render(): void;
  11803. /**
  11804. * Release associated resources
  11805. */
  11806. dispose(): void;
  11807. }
  11808. }
  11809. declare module "babylonjs/Sprites/sprite" {
  11810. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11811. import { Nullable } from "babylonjs/types";
  11812. import { ActionManager } from "babylonjs/Actions/actionManager";
  11813. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11814. /**
  11815. * Class used to represent a sprite
  11816. * @see http://doc.babylonjs.com/babylon101/sprites
  11817. */
  11818. export class Sprite {
  11819. /** defines the name */
  11820. name: string;
  11821. /** Gets or sets the current world position */
  11822. position: Vector3;
  11823. /** Gets or sets the main color */
  11824. color: Color4;
  11825. /** Gets or sets the width */
  11826. width: number;
  11827. /** Gets or sets the height */
  11828. height: number;
  11829. /** Gets or sets rotation angle */
  11830. angle: number;
  11831. /** Gets or sets the cell index in the sprite sheet */
  11832. cellIndex: number;
  11833. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11834. invertU: number;
  11835. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11836. invertV: number;
  11837. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11838. disposeWhenFinishedAnimating: boolean;
  11839. /** Gets the list of attached animations */
  11840. animations: Animation[];
  11841. /** Gets or sets a boolean indicating if the sprite can be picked */
  11842. isPickable: boolean;
  11843. /**
  11844. * Gets or sets the associated action manager
  11845. */
  11846. actionManager: Nullable<ActionManager>;
  11847. private _animationStarted;
  11848. private _loopAnimation;
  11849. private _fromIndex;
  11850. private _toIndex;
  11851. private _delay;
  11852. private _direction;
  11853. private _manager;
  11854. private _time;
  11855. private _onAnimationEnd;
  11856. /**
  11857. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11858. */
  11859. isVisible: boolean;
  11860. /**
  11861. * Gets or sets the sprite size
  11862. */
  11863. size: number;
  11864. /**
  11865. * Creates a new Sprite
  11866. * @param name defines the name
  11867. * @param manager defines the manager
  11868. */
  11869. constructor(
  11870. /** defines the name */
  11871. name: string, manager: ISpriteManager);
  11872. /**
  11873. * Starts an animation
  11874. * @param from defines the initial key
  11875. * @param to defines the end key
  11876. * @param loop defines if the animation must loop
  11877. * @param delay defines the start delay (in ms)
  11878. * @param onAnimationEnd defines a callback to call when animation ends
  11879. */
  11880. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11881. /** Stops current animation (if any) */
  11882. stopAnimation(): void;
  11883. /** @hidden */
  11884. _animate(deltaTime: number): void;
  11885. /** Release associated resources */
  11886. dispose(): void;
  11887. }
  11888. }
  11889. declare module "babylonjs/Collisions/pickingInfo" {
  11890. import { Nullable } from "babylonjs/types";
  11891. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11893. import { Sprite } from "babylonjs/Sprites/sprite";
  11894. import { Ray } from "babylonjs/Culling/ray";
  11895. /**
  11896. * Information about the result of picking within a scene
  11897. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11898. */
  11899. export class PickingInfo {
  11900. /** @hidden */
  11901. _pickingUnavailable: boolean;
  11902. /**
  11903. * If the pick collided with an object
  11904. */
  11905. hit: boolean;
  11906. /**
  11907. * Distance away where the pick collided
  11908. */
  11909. distance: number;
  11910. /**
  11911. * The location of pick collision
  11912. */
  11913. pickedPoint: Nullable<Vector3>;
  11914. /**
  11915. * The mesh corresponding the the pick collision
  11916. */
  11917. pickedMesh: Nullable<AbstractMesh>;
  11918. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11919. bu: number;
  11920. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11921. bv: number;
  11922. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11923. faceId: number;
  11924. /** Id of the the submesh that was picked */
  11925. subMeshId: number;
  11926. /** If a sprite was picked, this will be the sprite the pick collided with */
  11927. pickedSprite: Nullable<Sprite>;
  11928. /**
  11929. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11930. */
  11931. originMesh: Nullable<AbstractMesh>;
  11932. /**
  11933. * The ray that was used to perform the picking.
  11934. */
  11935. ray: Nullable<Ray>;
  11936. /**
  11937. * Gets the normal correspodning to the face the pick collided with
  11938. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11939. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11940. * @returns The normal correspodning to the face the pick collided with
  11941. */
  11942. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11943. /**
  11944. * Gets the texture coordinates of where the pick occured
  11945. * @returns the vector containing the coordnates of the texture
  11946. */
  11947. getTextureCoordinates(): Nullable<Vector2>;
  11948. }
  11949. }
  11950. declare module "babylonjs/Events/pointerEvents" {
  11951. import { Nullable } from "babylonjs/types";
  11952. import { Vector2 } from "babylonjs/Maths/math";
  11953. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11954. import { Ray } from "babylonjs/Culling/ray";
  11955. /**
  11956. * Gather the list of pointer event types as constants.
  11957. */
  11958. export class PointerEventTypes {
  11959. /**
  11960. * 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.
  11961. */
  11962. static readonly POINTERDOWN: number;
  11963. /**
  11964. * The pointerup event is fired when a pointer is no longer active.
  11965. */
  11966. static readonly POINTERUP: number;
  11967. /**
  11968. * The pointermove event is fired when a pointer changes coordinates.
  11969. */
  11970. static readonly POINTERMOVE: number;
  11971. /**
  11972. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11973. */
  11974. static readonly POINTERWHEEL: number;
  11975. /**
  11976. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11977. */
  11978. static readonly POINTERPICK: number;
  11979. /**
  11980. * The pointertap event is fired when a the object has been touched and released without drag.
  11981. */
  11982. static readonly POINTERTAP: number;
  11983. /**
  11984. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11985. */
  11986. static readonly POINTERDOUBLETAP: number;
  11987. }
  11988. /**
  11989. * Base class of pointer info types.
  11990. */
  11991. export class PointerInfoBase {
  11992. /**
  11993. * Defines the type of event (PointerEventTypes)
  11994. */
  11995. type: number;
  11996. /**
  11997. * Defines the related dom event
  11998. */
  11999. event: PointerEvent | MouseWheelEvent;
  12000. /**
  12001. * Instantiates the base class of pointers info.
  12002. * @param type Defines the type of event (PointerEventTypes)
  12003. * @param event Defines the related dom event
  12004. */
  12005. constructor(
  12006. /**
  12007. * Defines the type of event (PointerEventTypes)
  12008. */
  12009. type: number,
  12010. /**
  12011. * Defines the related dom event
  12012. */
  12013. event: PointerEvent | MouseWheelEvent);
  12014. }
  12015. /**
  12016. * This class is used to store pointer related info for the onPrePointerObservable event.
  12017. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12018. */
  12019. export class PointerInfoPre extends PointerInfoBase {
  12020. /**
  12021. * Ray from a pointer if availible (eg. 6dof controller)
  12022. */
  12023. ray: Nullable<Ray>;
  12024. /**
  12025. * Defines the local position of the pointer on the canvas.
  12026. */
  12027. localPosition: Vector2;
  12028. /**
  12029. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12030. */
  12031. skipOnPointerObservable: boolean;
  12032. /**
  12033. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12034. * @param type Defines the type of event (PointerEventTypes)
  12035. * @param event Defines the related dom event
  12036. * @param localX Defines the local x coordinates of the pointer when the event occured
  12037. * @param localY Defines the local y coordinates of the pointer when the event occured
  12038. */
  12039. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12040. }
  12041. /**
  12042. * This type contains all the data related to a pointer event in Babylon.js.
  12043. * 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.
  12044. */
  12045. export class PointerInfo extends PointerInfoBase {
  12046. /**
  12047. * Defines the picking info associated to the info (if any)\
  12048. */
  12049. pickInfo: Nullable<PickingInfo>;
  12050. /**
  12051. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12052. * @param type Defines the type of event (PointerEventTypes)
  12053. * @param event Defines the related dom event
  12054. * @param pickInfo Defines the picking info associated to the info (if any)\
  12055. */
  12056. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12057. /**
  12058. * Defines the picking info associated to the info (if any)\
  12059. */
  12060. pickInfo: Nullable<PickingInfo>);
  12061. }
  12062. /**
  12063. * Data relating to a touch event on the screen.
  12064. */
  12065. export interface PointerTouch {
  12066. /**
  12067. * X coordinate of touch.
  12068. */
  12069. x: number;
  12070. /**
  12071. * Y coordinate of touch.
  12072. */
  12073. y: number;
  12074. /**
  12075. * Id of touch. Unique for each finger.
  12076. */
  12077. pointerId: number;
  12078. /**
  12079. * Event type passed from DOM.
  12080. */
  12081. type: any;
  12082. }
  12083. }
  12084. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12085. import { Nullable } from "babylonjs/types";
  12086. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12087. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12088. /**
  12089. * Manage the mouse inputs to control the movement of a free camera.
  12090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12091. */
  12092. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12093. /**
  12094. * Define if touch is enabled in the mouse input
  12095. */
  12096. touchEnabled: boolean;
  12097. /**
  12098. * Defines the camera the input is attached to.
  12099. */
  12100. camera: FreeCamera;
  12101. /**
  12102. * Defines the buttons associated with the input to handle camera move.
  12103. */
  12104. buttons: number[];
  12105. /**
  12106. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12107. */
  12108. angularSensibility: number;
  12109. private _pointerInput;
  12110. private _onMouseMove;
  12111. private _observer;
  12112. private previousPosition;
  12113. /**
  12114. * Manage the mouse inputs to control the movement of a free camera.
  12115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12116. * @param touchEnabled Defines if touch is enabled or not
  12117. */
  12118. constructor(
  12119. /**
  12120. * Define if touch is enabled in the mouse input
  12121. */
  12122. touchEnabled?: boolean);
  12123. /**
  12124. * Attach the input controls to a specific dom element to get the input from.
  12125. * @param element Defines the element the controls should be listened from
  12126. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12127. */
  12128. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12129. /**
  12130. * Detach the current controls from the specified dom element.
  12131. * @param element Defines the element to stop listening the inputs from
  12132. */
  12133. detachControl(element: Nullable<HTMLElement>): void;
  12134. /**
  12135. * Gets the class name of the current intput.
  12136. * @returns the class name
  12137. */
  12138. getClassName(): string;
  12139. /**
  12140. * Get the friendly name associated with the input class.
  12141. * @returns the input friendly name
  12142. */
  12143. getSimpleName(): string;
  12144. }
  12145. }
  12146. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12147. import { Nullable } from "babylonjs/types";
  12148. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12149. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12150. /**
  12151. * Manage the touch inputs to control the movement of a free camera.
  12152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12153. */
  12154. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12155. /**
  12156. * Defines the camera the input is attached to.
  12157. */
  12158. camera: FreeCamera;
  12159. /**
  12160. * Defines the touch sensibility for rotation.
  12161. * The higher the faster.
  12162. */
  12163. touchAngularSensibility: number;
  12164. /**
  12165. * Defines the touch sensibility for move.
  12166. * The higher the faster.
  12167. */
  12168. touchMoveSensibility: number;
  12169. private _offsetX;
  12170. private _offsetY;
  12171. private _pointerPressed;
  12172. private _pointerInput;
  12173. private _observer;
  12174. private _onLostFocus;
  12175. /**
  12176. * Attach the input controls to a specific dom element to get the input from.
  12177. * @param element Defines the element the controls should be listened from
  12178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12179. */
  12180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12181. /**
  12182. * Detach the current controls from the specified dom element.
  12183. * @param element Defines the element to stop listening the inputs from
  12184. */
  12185. detachControl(element: Nullable<HTMLElement>): void;
  12186. /**
  12187. * Update the current camera state depending on the inputs that have been used this frame.
  12188. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12189. */
  12190. checkInputs(): void;
  12191. /**
  12192. * Gets the class name of the current intput.
  12193. * @returns the class name
  12194. */
  12195. getClassName(): string;
  12196. /**
  12197. * Get the friendly name associated with the input class.
  12198. * @returns the input friendly name
  12199. */
  12200. getSimpleName(): string;
  12201. }
  12202. }
  12203. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12204. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12205. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12206. /**
  12207. * Default Inputs manager for the FreeCamera.
  12208. * It groups all the default supported inputs for ease of use.
  12209. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12210. */
  12211. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12212. /**
  12213. * Instantiates a new FreeCameraInputsManager.
  12214. * @param camera Defines the camera the inputs belong to
  12215. */
  12216. constructor(camera: FreeCamera);
  12217. /**
  12218. * Add keyboard input support to the input manager.
  12219. * @returns the current input manager
  12220. */
  12221. addKeyboard(): FreeCameraInputsManager;
  12222. /**
  12223. * Add mouse input support to the input manager.
  12224. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12225. * @returns the current input manager
  12226. */
  12227. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12228. /**
  12229. * Add touch input support to the input manager.
  12230. * @returns the current input manager
  12231. */
  12232. addTouch(): FreeCameraInputsManager;
  12233. }
  12234. }
  12235. declare module "babylonjs/Cameras/freeCamera" {
  12236. import { Vector3 } from "babylonjs/Maths/math";
  12237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12238. import { Scene } from "babylonjs/scene";
  12239. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12240. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12241. /**
  12242. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12243. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12244. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12245. */
  12246. export class FreeCamera extends TargetCamera {
  12247. /**
  12248. * Define the collision ellipsoid of the camera.
  12249. * This is helpful to simulate a camera body like the player body around the camera
  12250. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12251. */
  12252. ellipsoid: Vector3;
  12253. /**
  12254. * Define an offset for the position of the ellipsoid around the camera.
  12255. * This can be helpful to determine the center of the body near the gravity center of the body
  12256. * instead of its head.
  12257. */
  12258. ellipsoidOffset: Vector3;
  12259. /**
  12260. * Enable or disable collisions of the camera with the rest of the scene objects.
  12261. */
  12262. checkCollisions: boolean;
  12263. /**
  12264. * Enable or disable gravity on the camera.
  12265. */
  12266. applyGravity: boolean;
  12267. /**
  12268. * Define the input manager associated to the camera.
  12269. */
  12270. inputs: FreeCameraInputsManager;
  12271. /**
  12272. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12273. * Higher values reduce sensitivity.
  12274. */
  12275. /**
  12276. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12277. * Higher values reduce sensitivity.
  12278. */
  12279. angularSensibility: number;
  12280. /**
  12281. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12282. */
  12283. keysUp: number[];
  12284. /**
  12285. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12286. */
  12287. keysDown: number[];
  12288. /**
  12289. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12290. */
  12291. keysLeft: number[];
  12292. /**
  12293. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12294. */
  12295. keysRight: number[];
  12296. /**
  12297. * Event raised when the camera collide with a mesh in the scene.
  12298. */
  12299. onCollide: (collidedMesh: AbstractMesh) => void;
  12300. private _collider;
  12301. private _needMoveForGravity;
  12302. private _oldPosition;
  12303. private _diffPosition;
  12304. private _newPosition;
  12305. /** @hidden */
  12306. _localDirection: Vector3;
  12307. /** @hidden */
  12308. _transformedDirection: Vector3;
  12309. /**
  12310. * Instantiates a Free Camera.
  12311. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12312. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12313. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12314. * @param name Define the name of the camera in the scene
  12315. * @param position Define the start position of the camera in the scene
  12316. * @param scene Define the scene the camera belongs to
  12317. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12318. */
  12319. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12320. /**
  12321. * Attached controls to the current camera.
  12322. * @param element Defines the element the controls should be listened from
  12323. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12324. */
  12325. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12326. /**
  12327. * Detach the current controls from the camera.
  12328. * The camera will stop reacting to inputs.
  12329. * @param element Defines the element to stop listening the inputs from
  12330. */
  12331. detachControl(element: HTMLElement): void;
  12332. private _collisionMask;
  12333. /**
  12334. * Define a collision mask to limit the list of object the camera can collide with
  12335. */
  12336. collisionMask: number;
  12337. /** @hidden */
  12338. _collideWithWorld(displacement: Vector3): void;
  12339. private _onCollisionPositionChange;
  12340. /** @hidden */
  12341. _checkInputs(): void;
  12342. /** @hidden */
  12343. _decideIfNeedsToMove(): boolean;
  12344. /** @hidden */
  12345. _updatePosition(): void;
  12346. /**
  12347. * Destroy the camera and release the current resources hold by it.
  12348. */
  12349. dispose(): void;
  12350. /**
  12351. * Gets the current object class name.
  12352. * @return the class name
  12353. */
  12354. getClassName(): string;
  12355. }
  12356. }
  12357. declare module "babylonjs/Gamepads/gamepad" {
  12358. import { Observable } from "babylonjs/Misc/observable";
  12359. /**
  12360. * Represents a gamepad control stick position
  12361. */
  12362. export class StickValues {
  12363. /**
  12364. * The x component of the control stick
  12365. */
  12366. x: number;
  12367. /**
  12368. * The y component of the control stick
  12369. */
  12370. y: number;
  12371. /**
  12372. * Initializes the gamepad x and y control stick values
  12373. * @param x The x component of the gamepad control stick value
  12374. * @param y The y component of the gamepad control stick value
  12375. */
  12376. constructor(
  12377. /**
  12378. * The x component of the control stick
  12379. */
  12380. x: number,
  12381. /**
  12382. * The y component of the control stick
  12383. */
  12384. y: number);
  12385. }
  12386. /**
  12387. * An interface which manages callbacks for gamepad button changes
  12388. */
  12389. export interface GamepadButtonChanges {
  12390. /**
  12391. * Called when a gamepad has been changed
  12392. */
  12393. changed: boolean;
  12394. /**
  12395. * Called when a gamepad press event has been triggered
  12396. */
  12397. pressChanged: boolean;
  12398. /**
  12399. * Called when a touch event has been triggered
  12400. */
  12401. touchChanged: boolean;
  12402. /**
  12403. * Called when a value has changed
  12404. */
  12405. valueChanged: boolean;
  12406. }
  12407. /**
  12408. * Represents a gamepad
  12409. */
  12410. export class Gamepad {
  12411. /**
  12412. * The id of the gamepad
  12413. */
  12414. id: string;
  12415. /**
  12416. * The index of the gamepad
  12417. */
  12418. index: number;
  12419. /**
  12420. * The browser gamepad
  12421. */
  12422. browserGamepad: any;
  12423. /**
  12424. * Specifies what type of gamepad this represents
  12425. */
  12426. type: number;
  12427. private _leftStick;
  12428. private _rightStick;
  12429. /** @hidden */
  12430. _isConnected: boolean;
  12431. private _leftStickAxisX;
  12432. private _leftStickAxisY;
  12433. private _rightStickAxisX;
  12434. private _rightStickAxisY;
  12435. /**
  12436. * Triggered when the left control stick has been changed
  12437. */
  12438. private _onleftstickchanged;
  12439. /**
  12440. * Triggered when the right control stick has been changed
  12441. */
  12442. private _onrightstickchanged;
  12443. /**
  12444. * Represents a gamepad controller
  12445. */
  12446. static GAMEPAD: number;
  12447. /**
  12448. * Represents a generic controller
  12449. */
  12450. static GENERIC: number;
  12451. /**
  12452. * Represents an XBox controller
  12453. */
  12454. static XBOX: number;
  12455. /**
  12456. * Represents a pose-enabled controller
  12457. */
  12458. static POSE_ENABLED: number;
  12459. /**
  12460. * Specifies whether the left control stick should be Y-inverted
  12461. */
  12462. protected _invertLeftStickY: boolean;
  12463. /**
  12464. * Specifies if the gamepad has been connected
  12465. */
  12466. readonly isConnected: boolean;
  12467. /**
  12468. * Initializes the gamepad
  12469. * @param id The id of the gamepad
  12470. * @param index The index of the gamepad
  12471. * @param browserGamepad The browser gamepad
  12472. * @param leftStickX The x component of the left joystick
  12473. * @param leftStickY The y component of the left joystick
  12474. * @param rightStickX The x component of the right joystick
  12475. * @param rightStickY The y component of the right joystick
  12476. */
  12477. constructor(
  12478. /**
  12479. * The id of the gamepad
  12480. */
  12481. id: string,
  12482. /**
  12483. * The index of the gamepad
  12484. */
  12485. index: number,
  12486. /**
  12487. * The browser gamepad
  12488. */
  12489. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12490. /**
  12491. * Callback triggered when the left joystick has changed
  12492. * @param callback
  12493. */
  12494. onleftstickchanged(callback: (values: StickValues) => void): void;
  12495. /**
  12496. * Callback triggered when the right joystick has changed
  12497. * @param callback
  12498. */
  12499. onrightstickchanged(callback: (values: StickValues) => void): void;
  12500. /**
  12501. * Gets the left joystick
  12502. */
  12503. /**
  12504. * Sets the left joystick values
  12505. */
  12506. leftStick: StickValues;
  12507. /**
  12508. * Gets the right joystick
  12509. */
  12510. /**
  12511. * Sets the right joystick value
  12512. */
  12513. rightStick: StickValues;
  12514. /**
  12515. * Updates the gamepad joystick positions
  12516. */
  12517. update(): void;
  12518. /**
  12519. * Disposes the gamepad
  12520. */
  12521. dispose(): void;
  12522. }
  12523. /**
  12524. * Represents a generic gamepad
  12525. */
  12526. export class GenericPad extends Gamepad {
  12527. private _buttons;
  12528. private _onbuttondown;
  12529. private _onbuttonup;
  12530. /**
  12531. * Observable triggered when a button has been pressed
  12532. */
  12533. onButtonDownObservable: Observable<number>;
  12534. /**
  12535. * Observable triggered when a button has been released
  12536. */
  12537. onButtonUpObservable: Observable<number>;
  12538. /**
  12539. * Callback triggered when a button has been pressed
  12540. * @param callback Called when a button has been pressed
  12541. */
  12542. onbuttondown(callback: (buttonPressed: number) => void): void;
  12543. /**
  12544. * Callback triggered when a button has been released
  12545. * @param callback Called when a button has been released
  12546. */
  12547. onbuttonup(callback: (buttonReleased: number) => void): void;
  12548. /**
  12549. * Initializes the generic gamepad
  12550. * @param id The id of the generic gamepad
  12551. * @param index The index of the generic gamepad
  12552. * @param browserGamepad The browser gamepad
  12553. */
  12554. constructor(id: string, index: number, browserGamepad: any);
  12555. private _setButtonValue;
  12556. /**
  12557. * Updates the generic gamepad
  12558. */
  12559. update(): void;
  12560. /**
  12561. * Disposes the generic gamepad
  12562. */
  12563. dispose(): void;
  12564. }
  12565. }
  12566. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12567. import { Observable } from "babylonjs/Misc/observable";
  12568. import { Nullable } from "babylonjs/types";
  12569. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12570. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12572. import { Ray } from "babylonjs/Culling/ray";
  12573. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12574. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12575. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12576. /**
  12577. * Defines the types of pose enabled controllers that are supported
  12578. */
  12579. export enum PoseEnabledControllerType {
  12580. /**
  12581. * HTC Vive
  12582. */
  12583. VIVE = 0,
  12584. /**
  12585. * Oculus Rift
  12586. */
  12587. OCULUS = 1,
  12588. /**
  12589. * Windows mixed reality
  12590. */
  12591. WINDOWS = 2,
  12592. /**
  12593. * Samsung gear VR
  12594. */
  12595. GEAR_VR = 3,
  12596. /**
  12597. * Google Daydream
  12598. */
  12599. DAYDREAM = 4,
  12600. /**
  12601. * Generic
  12602. */
  12603. GENERIC = 5
  12604. }
  12605. /**
  12606. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12607. */
  12608. export interface MutableGamepadButton {
  12609. /**
  12610. * Value of the button/trigger
  12611. */
  12612. value: number;
  12613. /**
  12614. * If the button/trigger is currently touched
  12615. */
  12616. touched: boolean;
  12617. /**
  12618. * If the button/trigger is currently pressed
  12619. */
  12620. pressed: boolean;
  12621. }
  12622. /**
  12623. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12624. * @hidden
  12625. */
  12626. export interface ExtendedGamepadButton extends GamepadButton {
  12627. /**
  12628. * If the button/trigger is currently pressed
  12629. */
  12630. readonly pressed: boolean;
  12631. /**
  12632. * If the button/trigger is currently touched
  12633. */
  12634. readonly touched: boolean;
  12635. /**
  12636. * Value of the button/trigger
  12637. */
  12638. readonly value: number;
  12639. }
  12640. /** @hidden */
  12641. export interface _GamePadFactory {
  12642. /**
  12643. * Returns wether or not the current gamepad can be created for this type of controller.
  12644. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12645. * @returns true if it can be created, otherwise false
  12646. */
  12647. canCreate(gamepadInfo: any): boolean;
  12648. /**
  12649. * Creates a new instance of the Gamepad.
  12650. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12651. * @returns the new gamepad instance
  12652. */
  12653. create(gamepadInfo: any): Gamepad;
  12654. }
  12655. /**
  12656. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12657. */
  12658. export class PoseEnabledControllerHelper {
  12659. /** @hidden */
  12660. static _ControllerFactories: _GamePadFactory[];
  12661. /** @hidden */
  12662. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12663. /**
  12664. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12665. * @param vrGamepad the gamepad to initialized
  12666. * @returns a vr controller of the type the gamepad identified as
  12667. */
  12668. static InitiateController(vrGamepad: any): Gamepad;
  12669. }
  12670. /**
  12671. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12672. */
  12673. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12674. private _deviceRoomPosition;
  12675. private _deviceRoomRotationQuaternion;
  12676. /**
  12677. * The device position in babylon space
  12678. */
  12679. devicePosition: Vector3;
  12680. /**
  12681. * The device rotation in babylon space
  12682. */
  12683. deviceRotationQuaternion: Quaternion;
  12684. /**
  12685. * The scale factor of the device in babylon space
  12686. */
  12687. deviceScaleFactor: number;
  12688. /**
  12689. * (Likely devicePosition should be used instead) The device position in its room space
  12690. */
  12691. position: Vector3;
  12692. /**
  12693. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12694. */
  12695. rotationQuaternion: Quaternion;
  12696. /**
  12697. * The type of controller (Eg. Windows mixed reality)
  12698. */
  12699. controllerType: PoseEnabledControllerType;
  12700. protected _calculatedPosition: Vector3;
  12701. private _calculatedRotation;
  12702. /**
  12703. * The raw pose from the device
  12704. */
  12705. rawPose: DevicePose;
  12706. private _trackPosition;
  12707. private _maxRotationDistFromHeadset;
  12708. private _draggedRoomRotation;
  12709. /**
  12710. * @hidden
  12711. */
  12712. _disableTrackPosition(fixedPosition: Vector3): void;
  12713. /**
  12714. * Internal, the mesh attached to the controller
  12715. * @hidden
  12716. */
  12717. _mesh: Nullable<AbstractMesh>;
  12718. private _poseControlledCamera;
  12719. private _leftHandSystemQuaternion;
  12720. /**
  12721. * Internal, matrix used to convert room space to babylon space
  12722. * @hidden
  12723. */
  12724. _deviceToWorld: Matrix;
  12725. /**
  12726. * Node to be used when casting a ray from the controller
  12727. * @hidden
  12728. */
  12729. _pointingPoseNode: Nullable<TransformNode>;
  12730. /**
  12731. * Name of the child mesh that can be used to cast a ray from the controller
  12732. */
  12733. static readonly POINTING_POSE: string;
  12734. /**
  12735. * Creates a new PoseEnabledController from a gamepad
  12736. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12737. */
  12738. constructor(browserGamepad: any);
  12739. private _workingMatrix;
  12740. /**
  12741. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12742. */
  12743. update(): void;
  12744. /**
  12745. * Updates only the pose device and mesh without doing any button event checking
  12746. */
  12747. protected _updatePoseAndMesh(): void;
  12748. /**
  12749. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12750. * @param poseData raw pose fromthe device
  12751. */
  12752. updateFromDevice(poseData: DevicePose): void;
  12753. /**
  12754. * @hidden
  12755. */
  12756. _meshAttachedObservable: Observable<AbstractMesh>;
  12757. /**
  12758. * Attaches a mesh to the controller
  12759. * @param mesh the mesh to be attached
  12760. */
  12761. attachToMesh(mesh: AbstractMesh): void;
  12762. /**
  12763. * Attaches the controllers mesh to a camera
  12764. * @param camera the camera the mesh should be attached to
  12765. */
  12766. attachToPoseControlledCamera(camera: TargetCamera): void;
  12767. /**
  12768. * Disposes of the controller
  12769. */
  12770. dispose(): void;
  12771. /**
  12772. * The mesh that is attached to the controller
  12773. */
  12774. readonly mesh: Nullable<AbstractMesh>;
  12775. /**
  12776. * Gets the ray of the controller in the direction the controller is pointing
  12777. * @param length the length the resulting ray should be
  12778. * @returns a ray in the direction the controller is pointing
  12779. */
  12780. getForwardRay(length?: number): Ray;
  12781. }
  12782. }
  12783. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12784. import { Observable } from "babylonjs/Misc/observable";
  12785. import { Scene } from "babylonjs/scene";
  12786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12787. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12788. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12789. /**
  12790. * Defines the WebVRController object that represents controllers tracked in 3D space
  12791. */
  12792. export abstract class WebVRController extends PoseEnabledController {
  12793. /**
  12794. * Internal, the default controller model for the controller
  12795. */
  12796. protected _defaultModel: AbstractMesh;
  12797. /**
  12798. * Fired when the trigger state has changed
  12799. */
  12800. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12801. /**
  12802. * Fired when the main button state has changed
  12803. */
  12804. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12805. /**
  12806. * Fired when the secondary button state has changed
  12807. */
  12808. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12809. /**
  12810. * Fired when the pad state has changed
  12811. */
  12812. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12813. /**
  12814. * Fired when controllers stick values have changed
  12815. */
  12816. onPadValuesChangedObservable: Observable<StickValues>;
  12817. /**
  12818. * Array of button availible on the controller
  12819. */
  12820. protected _buttons: Array<MutableGamepadButton>;
  12821. private _onButtonStateChange;
  12822. /**
  12823. * Fired when a controller button's state has changed
  12824. * @param callback the callback containing the button that was modified
  12825. */
  12826. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12827. /**
  12828. * X and Y axis corrisponding to the controllers joystick
  12829. */
  12830. pad: StickValues;
  12831. /**
  12832. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12833. */
  12834. hand: string;
  12835. /**
  12836. * The default controller model for the controller
  12837. */
  12838. readonly defaultModel: AbstractMesh;
  12839. /**
  12840. * Creates a new WebVRController from a gamepad
  12841. * @param vrGamepad the gamepad that the WebVRController should be created from
  12842. */
  12843. constructor(vrGamepad: any);
  12844. /**
  12845. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12846. */
  12847. update(): void;
  12848. /**
  12849. * Function to be called when a button is modified
  12850. */
  12851. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12852. /**
  12853. * Loads a mesh and attaches it to the controller
  12854. * @param scene the scene the mesh should be added to
  12855. * @param meshLoaded callback for when the mesh has been loaded
  12856. */
  12857. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12858. private _setButtonValue;
  12859. private _changes;
  12860. private _checkChanges;
  12861. /**
  12862. * Disposes of th webVRCOntroller
  12863. */
  12864. dispose(): void;
  12865. }
  12866. }
  12867. declare module "babylonjs/Lights/hemisphericLight" {
  12868. import { Nullable } from "babylonjs/types";
  12869. import { Scene } from "babylonjs/scene";
  12870. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  12871. import { Effect } from "babylonjs/Materials/effect";
  12872. import { Light } from "babylonjs/Lights/light";
  12873. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  12874. /**
  12875. * The HemisphericLight simulates the ambient environment light,
  12876. * so the passed direction is the light reflection direction, not the incoming direction.
  12877. */
  12878. export class HemisphericLight extends Light {
  12879. /**
  12880. * The groundColor is the light in the opposite direction to the one specified during creation.
  12881. * 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.
  12882. */
  12883. groundColor: Color3;
  12884. /**
  12885. * The light reflection direction, not the incoming direction.
  12886. */
  12887. direction: Vector3;
  12888. /**
  12889. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12890. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12891. * The HemisphericLight can't cast shadows.
  12892. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12893. * @param name The friendly name of the light
  12894. * @param direction The direction of the light reflection
  12895. * @param scene The scene the light belongs to
  12896. */
  12897. constructor(name: string, direction: Vector3, scene: Scene);
  12898. protected _buildUniformLayout(): void;
  12899. /**
  12900. * Returns the string "HemisphericLight".
  12901. * @return The class name
  12902. */
  12903. getClassName(): string;
  12904. /**
  12905. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12906. * Returns the updated direction.
  12907. * @param target The target the direction should point to
  12908. * @return The computed direction
  12909. */
  12910. setDirectionToTarget(target: Vector3): Vector3;
  12911. /**
  12912. * Returns the shadow generator associated to the light.
  12913. * @returns Always null for hemispheric lights because it does not support shadows.
  12914. */
  12915. getShadowGenerator(): Nullable<IShadowGenerator>;
  12916. /**
  12917. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12918. * @param effect The effect to update
  12919. * @param lightIndex The index of the light in the effect to update
  12920. * @returns The hemispheric light
  12921. */
  12922. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12923. /**
  12924. * Computes the world matrix of the node
  12925. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12926. * @param useWasUpdatedFlag defines a reserved property
  12927. * @returns the world matrix
  12928. */
  12929. computeWorldMatrix(): Matrix;
  12930. /**
  12931. * Returns the integer 3.
  12932. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12933. */
  12934. getTypeID(): number;
  12935. /**
  12936. * Prepares the list of defines specific to the light type.
  12937. * @param defines the list of defines
  12938. * @param lightIndex defines the index of the light for the effect
  12939. */
  12940. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12941. }
  12942. }
  12943. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  12944. declare module "babylonjs/Cameras/VR/webVRCamera" {
  12945. import { Nullable } from "babylonjs/types";
  12946. import { Observable } from "babylonjs/Misc/observable";
  12947. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12948. import { Scene } from "babylonjs/scene";
  12949. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12950. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  12951. import { Node } from "babylonjs/node";
  12952. import { Ray } from "babylonjs/Culling/ray";
  12953. import "babylonjs/Cameras/RigModes/webVRRigMode";
  12954. /**
  12955. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12956. * IMPORTANT!! The data is right-hand data.
  12957. * @export
  12958. * @interface DevicePose
  12959. */
  12960. export interface DevicePose {
  12961. /**
  12962. * The position of the device, values in array are [x,y,z].
  12963. */
  12964. readonly position: Nullable<Float32Array>;
  12965. /**
  12966. * The linearVelocity of the device, values in array are [x,y,z].
  12967. */
  12968. readonly linearVelocity: Nullable<Float32Array>;
  12969. /**
  12970. * The linearAcceleration of the device, values in array are [x,y,z].
  12971. */
  12972. readonly linearAcceleration: Nullable<Float32Array>;
  12973. /**
  12974. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  12975. */
  12976. readonly orientation: Nullable<Float32Array>;
  12977. /**
  12978. * The angularVelocity of the device, values in array are [x,y,z].
  12979. */
  12980. readonly angularVelocity: Nullable<Float32Array>;
  12981. /**
  12982. * The angularAcceleration of the device, values in array are [x,y,z].
  12983. */
  12984. readonly angularAcceleration: Nullable<Float32Array>;
  12985. }
  12986. /**
  12987. * Interface representing a pose controlled object in Babylon.
  12988. * A pose controlled object has both regular pose values as well as pose values
  12989. * from an external device such as a VR head mounted display
  12990. */
  12991. export interface PoseControlled {
  12992. /**
  12993. * The position of the object in babylon space.
  12994. */
  12995. position: Vector3;
  12996. /**
  12997. * The rotation quaternion of the object in babylon space.
  12998. */
  12999. rotationQuaternion: Quaternion;
  13000. /**
  13001. * The position of the device in babylon space.
  13002. */
  13003. devicePosition?: Vector3;
  13004. /**
  13005. * The rotation quaternion of the device in babylon space.
  13006. */
  13007. deviceRotationQuaternion: Quaternion;
  13008. /**
  13009. * The raw pose coming from the device.
  13010. */
  13011. rawPose: Nullable<DevicePose>;
  13012. /**
  13013. * The scale of the device to be used when translating from device space to babylon space.
  13014. */
  13015. deviceScaleFactor: number;
  13016. /**
  13017. * Updates the poseControlled values based on the input device pose.
  13018. * @param poseData the pose data to update the object with
  13019. */
  13020. updateFromDevice(poseData: DevicePose): void;
  13021. }
  13022. /**
  13023. * Set of options to customize the webVRCamera
  13024. */
  13025. export interface WebVROptions {
  13026. /**
  13027. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13028. */
  13029. trackPosition?: boolean;
  13030. /**
  13031. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13032. */
  13033. positionScale?: number;
  13034. /**
  13035. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13036. */
  13037. displayName?: string;
  13038. /**
  13039. * Should the native controller meshes be initialized. (default: true)
  13040. */
  13041. controllerMeshes?: boolean;
  13042. /**
  13043. * Creating a default HemiLight only on controllers. (default: true)
  13044. */
  13045. defaultLightingOnControllers?: boolean;
  13046. /**
  13047. * If you don't want to use the default VR button of the helper. (default: false)
  13048. */
  13049. useCustomVRButton?: boolean;
  13050. /**
  13051. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13052. */
  13053. customVRButton?: HTMLButtonElement;
  13054. /**
  13055. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13056. */
  13057. rayLength?: number;
  13058. /**
  13059. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13060. */
  13061. defaultHeight?: number;
  13062. }
  13063. /**
  13064. * This represents a WebVR camera.
  13065. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13066. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13067. */
  13068. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13069. private webVROptions;
  13070. /**
  13071. * @hidden
  13072. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13073. */
  13074. _vrDevice: any;
  13075. /**
  13076. * The rawPose of the vrDevice.
  13077. */
  13078. rawPose: Nullable<DevicePose>;
  13079. private _onVREnabled;
  13080. private _specsVersion;
  13081. private _attached;
  13082. private _frameData;
  13083. protected _descendants: Array<Node>;
  13084. private _deviceRoomPosition;
  13085. /** @hidden */
  13086. _deviceRoomRotationQuaternion: Quaternion;
  13087. private _standingMatrix;
  13088. /**
  13089. * Represents device position in babylon space.
  13090. */
  13091. devicePosition: Vector3;
  13092. /**
  13093. * Represents device rotation in babylon space.
  13094. */
  13095. deviceRotationQuaternion: Quaternion;
  13096. /**
  13097. * The scale of the device to be used when translating from device space to babylon space.
  13098. */
  13099. deviceScaleFactor: number;
  13100. private _deviceToWorld;
  13101. private _worldToDevice;
  13102. /**
  13103. * References to the webVR controllers for the vrDevice.
  13104. */
  13105. controllers: Array<WebVRController>;
  13106. /**
  13107. * Emits an event when a controller is attached.
  13108. */
  13109. onControllersAttachedObservable: Observable<WebVRController[]>;
  13110. /**
  13111. * Emits an event when a controller's mesh has been loaded;
  13112. */
  13113. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13114. /**
  13115. * Emits an event when the HMD's pose has been updated.
  13116. */
  13117. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13118. private _poseSet;
  13119. /**
  13120. * If the rig cameras be used as parent instead of this camera.
  13121. */
  13122. rigParenting: boolean;
  13123. private _lightOnControllers;
  13124. private _defaultHeight?;
  13125. /**
  13126. * Instantiates a WebVRFreeCamera.
  13127. * @param name The name of the WebVRFreeCamera
  13128. * @param position The starting anchor position for the camera
  13129. * @param scene The scene the camera belongs to
  13130. * @param webVROptions a set of customizable options for the webVRCamera
  13131. */
  13132. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13133. /**
  13134. * Gets the device distance from the ground in meters.
  13135. * @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.
  13136. */
  13137. deviceDistanceToRoomGround(): number;
  13138. /**
  13139. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13140. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13141. */
  13142. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13143. /**
  13144. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13145. * @returns A promise with a boolean set to if the standing matrix is supported.
  13146. */
  13147. useStandingMatrixAsync(): Promise<boolean>;
  13148. /**
  13149. * Disposes the camera
  13150. */
  13151. dispose(): void;
  13152. /**
  13153. * Gets a vrController by name.
  13154. * @param name The name of the controller to retreive
  13155. * @returns the controller matching the name specified or null if not found
  13156. */
  13157. getControllerByName(name: string): Nullable<WebVRController>;
  13158. private _leftController;
  13159. /**
  13160. * The controller corrisponding to the users left hand.
  13161. */
  13162. readonly leftController: Nullable<WebVRController>;
  13163. private _rightController;
  13164. /**
  13165. * The controller corrisponding to the users right hand.
  13166. */
  13167. readonly rightController: Nullable<WebVRController>;
  13168. /**
  13169. * Casts a ray forward from the vrCamera's gaze.
  13170. * @param length Length of the ray (default: 100)
  13171. * @returns the ray corrisponding to the gaze
  13172. */
  13173. getForwardRay(length?: number): Ray;
  13174. /**
  13175. * @hidden
  13176. * Updates the camera based on device's frame data
  13177. */
  13178. _checkInputs(): void;
  13179. /**
  13180. * Updates the poseControlled values based on the input device pose.
  13181. * @param poseData Pose coming from the device
  13182. */
  13183. updateFromDevice(poseData: DevicePose): void;
  13184. private _htmlElementAttached;
  13185. private _detachIfAttached;
  13186. /**
  13187. * WebVR's attach control will start broadcasting frames to the device.
  13188. * Note that in certain browsers (chrome for example) this function must be called
  13189. * within a user-interaction callback. Example:
  13190. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13191. *
  13192. * @param element html element to attach the vrDevice to
  13193. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13194. */
  13195. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13196. /**
  13197. * Detaches the camera from the html element and disables VR
  13198. *
  13199. * @param element html element to detach from
  13200. */
  13201. detachControl(element: HTMLElement): void;
  13202. /**
  13203. * @returns the name of this class
  13204. */
  13205. getClassName(): string;
  13206. /**
  13207. * Calls resetPose on the vrDisplay
  13208. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13209. */
  13210. resetToCurrentRotation(): void;
  13211. /**
  13212. * @hidden
  13213. * Updates the rig cameras (left and right eye)
  13214. */
  13215. _updateRigCameras(): void;
  13216. private _workingVector;
  13217. private _oneVector;
  13218. private _workingMatrix;
  13219. private updateCacheCalled;
  13220. private _correctPositionIfNotTrackPosition;
  13221. /**
  13222. * @hidden
  13223. * Updates the cached values of the camera
  13224. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13225. */
  13226. _updateCache(ignoreParentClass?: boolean): void;
  13227. /**
  13228. * @hidden
  13229. * Get current device position in babylon world
  13230. */
  13231. _computeDevicePosition(): void;
  13232. /**
  13233. * Updates the current device position and rotation in the babylon world
  13234. */
  13235. update(): void;
  13236. /**
  13237. * @hidden
  13238. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13239. * @returns an identity matrix
  13240. */
  13241. _getViewMatrix(): Matrix;
  13242. private _tmpMatrix;
  13243. /**
  13244. * This function is called by the two RIG cameras.
  13245. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13246. * @hidden
  13247. */
  13248. _getWebVRViewMatrix(): Matrix;
  13249. /** @hidden */
  13250. _getWebVRProjectionMatrix(): Matrix;
  13251. private _onGamepadConnectedObserver;
  13252. private _onGamepadDisconnectedObserver;
  13253. private _updateCacheWhenTrackingDisabledObserver;
  13254. /**
  13255. * Initializes the controllers and their meshes
  13256. */
  13257. initControllers(): void;
  13258. }
  13259. }
  13260. declare module "babylonjs/PostProcesses/postProcess" {
  13261. import { Nullable } from "babylonjs/types";
  13262. import { SmartArray } from "babylonjs/Misc/smartArray";
  13263. import { Observable } from "babylonjs/Misc/observable";
  13264. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13265. import { Camera } from "babylonjs/Cameras/camera";
  13266. import { Effect } from "babylonjs/Materials/effect";
  13267. import "babylonjs/Shaders/postprocess.vertex";
  13268. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13269. import { Engine } from "babylonjs/Engines/engine";
  13270. /**
  13271. * Size options for a post process
  13272. */
  13273. export type PostProcessOptions = {
  13274. width: number;
  13275. height: number;
  13276. };
  13277. /**
  13278. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13279. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13280. */
  13281. export class PostProcess {
  13282. /** Name of the PostProcess. */
  13283. name: string;
  13284. /**
  13285. * Gets or sets the unique id of the post process
  13286. */
  13287. uniqueId: number;
  13288. /**
  13289. * Width of the texture to apply the post process on
  13290. */
  13291. width: number;
  13292. /**
  13293. * Height of the texture to apply the post process on
  13294. */
  13295. height: number;
  13296. /**
  13297. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13298. * @hidden
  13299. */
  13300. _outputTexture: Nullable<InternalTexture>;
  13301. /**
  13302. * Sampling mode used by the shader
  13303. * See https://doc.babylonjs.com/classes/3.1/texture
  13304. */
  13305. renderTargetSamplingMode: number;
  13306. /**
  13307. * Clear color to use when screen clearing
  13308. */
  13309. clearColor: Color4;
  13310. /**
  13311. * If the buffer needs to be cleared before applying the post process. (default: true)
  13312. * Should be set to false if shader will overwrite all previous pixels.
  13313. */
  13314. autoClear: boolean;
  13315. /**
  13316. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13317. */
  13318. alphaMode: number;
  13319. /**
  13320. * Sets the setAlphaBlendConstants of the babylon engine
  13321. */
  13322. alphaConstants: Color4;
  13323. /**
  13324. * Animations to be used for the post processing
  13325. */
  13326. animations: import("babylonjs/Animations/animation").Animation[];
  13327. /**
  13328. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13329. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13330. */
  13331. enablePixelPerfectMode: boolean;
  13332. /**
  13333. * Force the postprocess to be applied without taking in account viewport
  13334. */
  13335. forceFullscreenViewport: boolean;
  13336. /**
  13337. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13338. *
  13339. * | Value | Type | Description |
  13340. * | ----- | ----------------------------------- | ----------- |
  13341. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13342. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13343. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13344. *
  13345. */
  13346. scaleMode: number;
  13347. /**
  13348. * Force textures to be a power of two (default: false)
  13349. */
  13350. alwaysForcePOT: boolean;
  13351. private _samples;
  13352. /**
  13353. * Number of sample textures (default: 1)
  13354. */
  13355. samples: number;
  13356. /**
  13357. * Modify the scale of the post process to be the same as the viewport (default: false)
  13358. */
  13359. adaptScaleToCurrentViewport: boolean;
  13360. private _camera;
  13361. private _scene;
  13362. private _engine;
  13363. private _options;
  13364. private _reusable;
  13365. private _textureType;
  13366. /**
  13367. * Smart array of input and output textures for the post process.
  13368. * @hidden
  13369. */
  13370. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13371. /**
  13372. * The index in _textures that corresponds to the output texture.
  13373. * @hidden
  13374. */
  13375. _currentRenderTextureInd: number;
  13376. private _effect;
  13377. private _samplers;
  13378. private _fragmentUrl;
  13379. private _vertexUrl;
  13380. private _parameters;
  13381. private _scaleRatio;
  13382. protected _indexParameters: any;
  13383. private _shareOutputWithPostProcess;
  13384. private _texelSize;
  13385. private _forcedOutputTexture;
  13386. /**
  13387. * Returns the fragment url or shader name used in the post process.
  13388. * @returns the fragment url or name in the shader store.
  13389. */
  13390. getEffectName(): string;
  13391. /**
  13392. * An event triggered when the postprocess is activated.
  13393. */
  13394. onActivateObservable: Observable<Camera>;
  13395. private _onActivateObserver;
  13396. /**
  13397. * A function that is added to the onActivateObservable
  13398. */
  13399. onActivate: Nullable<(camera: Camera) => void>;
  13400. /**
  13401. * An event triggered when the postprocess changes its size.
  13402. */
  13403. onSizeChangedObservable: Observable<PostProcess>;
  13404. private _onSizeChangedObserver;
  13405. /**
  13406. * A function that is added to the onSizeChangedObservable
  13407. */
  13408. onSizeChanged: (postProcess: PostProcess) => void;
  13409. /**
  13410. * An event triggered when the postprocess applies its effect.
  13411. */
  13412. onApplyObservable: Observable<Effect>;
  13413. private _onApplyObserver;
  13414. /**
  13415. * A function that is added to the onApplyObservable
  13416. */
  13417. onApply: (effect: Effect) => void;
  13418. /**
  13419. * An event triggered before rendering the postprocess
  13420. */
  13421. onBeforeRenderObservable: Observable<Effect>;
  13422. private _onBeforeRenderObserver;
  13423. /**
  13424. * A function that is added to the onBeforeRenderObservable
  13425. */
  13426. onBeforeRender: (effect: Effect) => void;
  13427. /**
  13428. * An event triggered after rendering the postprocess
  13429. */
  13430. onAfterRenderObservable: Observable<Effect>;
  13431. private _onAfterRenderObserver;
  13432. /**
  13433. * A function that is added to the onAfterRenderObservable
  13434. */
  13435. onAfterRender: (efect: Effect) => void;
  13436. /**
  13437. * 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
  13438. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13439. */
  13440. inputTexture: InternalTexture;
  13441. /**
  13442. * Gets the camera which post process is applied to.
  13443. * @returns The camera the post process is applied to.
  13444. */
  13445. getCamera(): Camera;
  13446. /**
  13447. * Gets the texel size of the postprocess.
  13448. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13449. */
  13450. readonly texelSize: Vector2;
  13451. /**
  13452. * Creates a new instance PostProcess
  13453. * @param name The name of the PostProcess.
  13454. * @param fragmentUrl The url of the fragment shader to be used.
  13455. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13456. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13457. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13458. * @param camera The camera to apply the render pass to.
  13459. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13460. * @param engine The engine which the post process will be applied. (default: current engine)
  13461. * @param reusable If the post process can be reused on the same frame. (default: false)
  13462. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13463. * @param textureType Type of textures used when performing the post process. (default: 0)
  13464. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13465. * @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
  13466. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13467. */
  13468. constructor(
  13469. /** Name of the PostProcess. */
  13470. 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);
  13471. /**
  13472. * Gets a string idenfifying the name of the class
  13473. * @returns "PostProcess" string
  13474. */
  13475. getClassName(): string;
  13476. /**
  13477. * Gets the engine which this post process belongs to.
  13478. * @returns The engine the post process was enabled with.
  13479. */
  13480. getEngine(): Engine;
  13481. /**
  13482. * The effect that is created when initializing the post process.
  13483. * @returns The created effect corrisponding the the postprocess.
  13484. */
  13485. getEffect(): Effect;
  13486. /**
  13487. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13488. * @param postProcess The post process to share the output with.
  13489. * @returns This post process.
  13490. */
  13491. shareOutputWith(postProcess: PostProcess): PostProcess;
  13492. /**
  13493. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13494. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13495. */
  13496. useOwnOutput(): void;
  13497. /**
  13498. * Updates the effect with the current post process compile time values and recompiles the shader.
  13499. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13500. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13501. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13502. * @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
  13503. * @param onCompiled Called when the shader has been compiled.
  13504. * @param onError Called if there is an error when compiling a shader.
  13505. */
  13506. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13507. /**
  13508. * The post process is reusable if it can be used multiple times within one frame.
  13509. * @returns If the post process is reusable
  13510. */
  13511. isReusable(): boolean;
  13512. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13513. markTextureDirty(): void;
  13514. /**
  13515. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13516. * 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.
  13517. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13518. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13519. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13520. * @returns The target texture that was bound to be written to.
  13521. */
  13522. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13523. /**
  13524. * If the post process is supported.
  13525. */
  13526. readonly isSupported: boolean;
  13527. /**
  13528. * The aspect ratio of the output texture.
  13529. */
  13530. readonly aspectRatio: number;
  13531. /**
  13532. * Get a value indicating if the post-process is ready to be used
  13533. * @returns true if the post-process is ready (shader is compiled)
  13534. */
  13535. isReady(): boolean;
  13536. /**
  13537. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13538. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13539. */
  13540. apply(): Nullable<Effect>;
  13541. private _disposeTextures;
  13542. /**
  13543. * Disposes the post process.
  13544. * @param camera The camera to dispose the post process on.
  13545. */
  13546. dispose(camera?: Camera): void;
  13547. }
  13548. }
  13549. declare module "babylonjs/PostProcesses/postProcessManager" {
  13550. import { Nullable } from "babylonjs/types";
  13551. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13552. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13553. import { Scene } from "babylonjs/scene";
  13554. /**
  13555. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13556. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13557. */
  13558. export class PostProcessManager {
  13559. private _scene;
  13560. private _indexBuffer;
  13561. private _vertexBuffers;
  13562. /**
  13563. * Creates a new instance PostProcess
  13564. * @param scene The scene that the post process is associated with.
  13565. */
  13566. constructor(scene: Scene);
  13567. private _prepareBuffers;
  13568. private _buildIndexBuffer;
  13569. /**
  13570. * Rebuilds the vertex buffers of the manager.
  13571. * @hidden
  13572. */
  13573. _rebuild(): void;
  13574. /**
  13575. * Prepares a frame to be run through a post process.
  13576. * @param sourceTexture The input texture to the post procesess. (default: null)
  13577. * @param postProcesses An array of post processes to be run. (default: null)
  13578. * @returns True if the post processes were able to be run.
  13579. * @hidden
  13580. */
  13581. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13582. /**
  13583. * Manually render a set of post processes to a texture.
  13584. * @param postProcesses An array of post processes to be run.
  13585. * @param targetTexture The target texture to render to.
  13586. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13587. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13588. * @param lodLevel defines which lod of the texture to render to
  13589. */
  13590. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13591. /**
  13592. * Finalize the result of the output of the postprocesses.
  13593. * @param doNotPresent If true the result will not be displayed to the screen.
  13594. * @param targetTexture The target texture to render to.
  13595. * @param faceIndex The index of the face to bind the target texture to.
  13596. * @param postProcesses The array of post processes to render.
  13597. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13598. * @hidden
  13599. */
  13600. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13601. /**
  13602. * Disposes of the post process manager.
  13603. */
  13604. dispose(): void;
  13605. }
  13606. }
  13607. declare module "babylonjs/Layers/layerSceneComponent" {
  13608. import { Scene } from "babylonjs/scene";
  13609. import { ISceneComponent } from "babylonjs/sceneComponent";
  13610. import { Layer } from "babylonjs/Layers/layer";
  13611. module "babylonjs/abstractScene" {
  13612. interface AbstractScene {
  13613. /**
  13614. * The list of layers (background and foreground) of the scene
  13615. */
  13616. layers: Array<Layer>;
  13617. }
  13618. }
  13619. /**
  13620. * Defines the layer scene component responsible to manage any layers
  13621. * in a given scene.
  13622. */
  13623. export class LayerSceneComponent implements ISceneComponent {
  13624. /**
  13625. * The component name helpfull to identify the component in the list of scene components.
  13626. */
  13627. readonly name: string;
  13628. /**
  13629. * The scene the component belongs to.
  13630. */
  13631. scene: Scene;
  13632. private _engine;
  13633. /**
  13634. * Creates a new instance of the component for the given scene
  13635. * @param scene Defines the scene to register the component in
  13636. */
  13637. constructor(scene: Scene);
  13638. /**
  13639. * Registers the component in a given scene
  13640. */
  13641. register(): void;
  13642. /**
  13643. * Rebuilds the elements related to this component in case of
  13644. * context lost for instance.
  13645. */
  13646. rebuild(): void;
  13647. /**
  13648. * Disposes the component and the associated ressources.
  13649. */
  13650. dispose(): void;
  13651. private _draw;
  13652. private _drawCameraPredicate;
  13653. private _drawCameraBackground;
  13654. private _drawCameraForeground;
  13655. private _drawRenderTargetPredicate;
  13656. private _drawRenderTargetBackground;
  13657. private _drawRenderTargetForeground;
  13658. }
  13659. }
  13660. declare module "babylonjs/Shaders/layer.fragment" {
  13661. /** @hidden */
  13662. export var layerPixelShader: {
  13663. name: string;
  13664. shader: string;
  13665. };
  13666. }
  13667. declare module "babylonjs/Shaders/layer.vertex" {
  13668. /** @hidden */
  13669. export var layerVertexShader: {
  13670. name: string;
  13671. shader: string;
  13672. };
  13673. }
  13674. declare module "babylonjs/Layers/layer" {
  13675. import { Observable } from "babylonjs/Misc/observable";
  13676. import { Nullable } from "babylonjs/types";
  13677. import { Scene } from "babylonjs/scene";
  13678. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13679. import { Texture } from "babylonjs/Materials/Textures/texture";
  13680. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13681. import "babylonjs/Shaders/layer.fragment";
  13682. import "babylonjs/Shaders/layer.vertex";
  13683. /**
  13684. * This represents a full screen 2d layer.
  13685. * This can be useful to display a picture in the background of your scene for instance.
  13686. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13687. */
  13688. export class Layer {
  13689. /**
  13690. * Define the name of the layer.
  13691. */
  13692. name: string;
  13693. /**
  13694. * Define the texture the layer should display.
  13695. */
  13696. texture: Nullable<Texture>;
  13697. /**
  13698. * Is the layer in background or foreground.
  13699. */
  13700. isBackground: boolean;
  13701. /**
  13702. * Define the color of the layer (instead of texture).
  13703. */
  13704. color: Color4;
  13705. /**
  13706. * Define the scale of the layer in order to zoom in out of the texture.
  13707. */
  13708. scale: Vector2;
  13709. /**
  13710. * Define an offset for the layer in order to shift the texture.
  13711. */
  13712. offset: Vector2;
  13713. /**
  13714. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13715. */
  13716. alphaBlendingMode: number;
  13717. /**
  13718. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13719. * Alpha test will not mix with the background color in case of transparency.
  13720. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13721. */
  13722. alphaTest: boolean;
  13723. /**
  13724. * Define a mask to restrict the layer to only some of the scene cameras.
  13725. */
  13726. layerMask: number;
  13727. /**
  13728. * Define the list of render target the layer is visible into.
  13729. */
  13730. renderTargetTextures: RenderTargetTexture[];
  13731. /**
  13732. * Define if the layer is only used in renderTarget or if it also
  13733. * renders in the main frame buffer of the canvas.
  13734. */
  13735. renderOnlyInRenderTargetTextures: boolean;
  13736. private _scene;
  13737. private _vertexBuffers;
  13738. private _indexBuffer;
  13739. private _effect;
  13740. private _alphaTestEffect;
  13741. /**
  13742. * An event triggered when the layer is disposed.
  13743. */
  13744. onDisposeObservable: Observable<Layer>;
  13745. private _onDisposeObserver;
  13746. /**
  13747. * Back compatibility with callback before the onDisposeObservable existed.
  13748. * The set callback will be triggered when the layer has been disposed.
  13749. */
  13750. onDispose: () => void;
  13751. /**
  13752. * An event triggered before rendering the scene
  13753. */
  13754. onBeforeRenderObservable: Observable<Layer>;
  13755. private _onBeforeRenderObserver;
  13756. /**
  13757. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13758. * The set callback will be triggered just before rendering the layer.
  13759. */
  13760. onBeforeRender: () => void;
  13761. /**
  13762. * An event triggered after rendering the scene
  13763. */
  13764. onAfterRenderObservable: Observable<Layer>;
  13765. private _onAfterRenderObserver;
  13766. /**
  13767. * Back compatibility with callback before the onAfterRenderObservable existed.
  13768. * The set callback will be triggered just after rendering the layer.
  13769. */
  13770. onAfterRender: () => void;
  13771. /**
  13772. * Instantiates a new layer.
  13773. * This represents a full screen 2d layer.
  13774. * This can be useful to display a picture in the background of your scene for instance.
  13775. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13776. * @param name Define the name of the layer in the scene
  13777. * @param imgUrl Define the url of the texture to display in the layer
  13778. * @param scene Define the scene the layer belongs to
  13779. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13780. * @param color Defines a color for the layer
  13781. */
  13782. constructor(
  13783. /**
  13784. * Define the name of the layer.
  13785. */
  13786. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13787. private _createIndexBuffer;
  13788. /** @hidden */
  13789. _rebuild(): void;
  13790. /**
  13791. * Renders the layer in the scene.
  13792. */
  13793. render(): void;
  13794. /**
  13795. * Disposes and releases the associated ressources.
  13796. */
  13797. dispose(): void;
  13798. }
  13799. }
  13800. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13801. import { Scene } from "babylonjs/scene";
  13802. import { ISceneComponent } from "babylonjs/sceneComponent";
  13803. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13804. module "babylonjs/abstractScene" {
  13805. interface AbstractScene {
  13806. /**
  13807. * The list of procedural textures added to the scene
  13808. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13809. */
  13810. proceduralTextures: Array<ProceduralTexture>;
  13811. }
  13812. }
  13813. /**
  13814. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13815. * in a given scene.
  13816. */
  13817. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13818. /**
  13819. * The component name helpfull to identify the component in the list of scene components.
  13820. */
  13821. readonly name: string;
  13822. /**
  13823. * The scene the component belongs to.
  13824. */
  13825. scene: Scene;
  13826. /**
  13827. * Creates a new instance of the component for the given scene
  13828. * @param scene Defines the scene to register the component in
  13829. */
  13830. constructor(scene: Scene);
  13831. /**
  13832. * Registers the component in a given scene
  13833. */
  13834. register(): void;
  13835. /**
  13836. * Rebuilds the elements related to this component in case of
  13837. * context lost for instance.
  13838. */
  13839. rebuild(): void;
  13840. /**
  13841. * Disposes the component and the associated ressources.
  13842. */
  13843. dispose(): void;
  13844. private _beforeClear;
  13845. }
  13846. }
  13847. declare module "babylonjs/Shaders/procedural.vertex" {
  13848. /** @hidden */
  13849. export var proceduralVertexShader: {
  13850. name: string;
  13851. shader: string;
  13852. };
  13853. }
  13854. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13855. import { Observable } from "babylonjs/Misc/observable";
  13856. import { Nullable } from "babylonjs/types";
  13857. import { Scene } from "babylonjs/scene";
  13858. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13859. import { Effect } from "babylonjs/Materials/effect";
  13860. import { Texture } from "babylonjs/Materials/Textures/texture";
  13861. import "babylonjs/Shaders/procedural.vertex";
  13862. /**
  13863. * 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.
  13864. * This is the base class of any Procedural texture and contains most of the shareable code.
  13865. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13866. */
  13867. export class ProceduralTexture extends Texture {
  13868. isCube: boolean;
  13869. /**
  13870. * Define if the texture is enabled or not (disabled texture will not render)
  13871. */
  13872. isEnabled: boolean;
  13873. /**
  13874. * Define if the texture must be cleared before rendering (default is true)
  13875. */
  13876. autoClear: boolean;
  13877. /**
  13878. * Callback called when the texture is generated
  13879. */
  13880. onGenerated: () => void;
  13881. /**
  13882. * Event raised when the texture is generated
  13883. */
  13884. onGeneratedObservable: Observable<ProceduralTexture>;
  13885. /** @hidden */
  13886. _generateMipMaps: boolean;
  13887. /** @hidden **/
  13888. _effect: Effect;
  13889. /** @hidden */
  13890. _textures: {
  13891. [key: string]: Texture;
  13892. };
  13893. private _size;
  13894. private _currentRefreshId;
  13895. private _refreshRate;
  13896. private _vertexBuffers;
  13897. private _indexBuffer;
  13898. private _uniforms;
  13899. private _samplers;
  13900. private _fragment;
  13901. private _floats;
  13902. private _ints;
  13903. private _floatsArrays;
  13904. private _colors3;
  13905. private _colors4;
  13906. private _vectors2;
  13907. private _vectors3;
  13908. private _matrices;
  13909. private _fallbackTexture;
  13910. private _fallbackTextureUsed;
  13911. private _engine;
  13912. private _cachedDefines;
  13913. private _contentUpdateId;
  13914. private _contentData;
  13915. /**
  13916. * Instantiates a new procedural texture.
  13917. * 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.
  13918. * This is the base class of any Procedural texture and contains most of the shareable code.
  13919. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13920. * @param name Define the name of the texture
  13921. * @param size Define the size of the texture to create
  13922. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13923. * @param scene Define the scene the texture belongs to
  13924. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13925. * @param generateMipMaps Define if the texture should creates mip maps or not
  13926. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13927. */
  13928. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13929. /**
  13930. * The effect that is created when initializing the post process.
  13931. * @returns The created effect corrisponding the the postprocess.
  13932. */
  13933. getEffect(): Effect;
  13934. /**
  13935. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13936. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13937. */
  13938. getContent(): Nullable<ArrayBufferView>;
  13939. private _createIndexBuffer;
  13940. /** @hidden */
  13941. _rebuild(): void;
  13942. /**
  13943. * Resets the texture in order to recreate its associated resources.
  13944. * This can be called in case of context loss
  13945. */
  13946. reset(): void;
  13947. protected _getDefines(): string;
  13948. /**
  13949. * Is the texture ready to be used ? (rendered at least once)
  13950. * @returns true if ready, otherwise, false.
  13951. */
  13952. isReady(): boolean;
  13953. /**
  13954. * Resets the refresh counter of the texture and start bak from scratch.
  13955. * Could be useful to regenerate the texture if it is setup to render only once.
  13956. */
  13957. resetRefreshCounter(): void;
  13958. /**
  13959. * Set the fragment shader to use in order to render the texture.
  13960. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13961. */
  13962. setFragment(fragment: any): void;
  13963. /**
  13964. * Define the refresh rate of the texture or the rendering frequency.
  13965. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13966. */
  13967. refreshRate: number;
  13968. /** @hidden */
  13969. _shouldRender(): boolean;
  13970. /**
  13971. * Get the size the texture is rendering at.
  13972. * @returns the size (texture is always squared)
  13973. */
  13974. getRenderSize(): number;
  13975. /**
  13976. * Resize the texture to new value.
  13977. * @param size Define the new size the texture should have
  13978. * @param generateMipMaps Define whether the new texture should create mip maps
  13979. */
  13980. resize(size: number, generateMipMaps: boolean): void;
  13981. private _checkUniform;
  13982. /**
  13983. * Set a texture in the shader program used to render.
  13984. * @param name Define the name of the uniform samplers as defined in the shader
  13985. * @param texture Define the texture to bind to this sampler
  13986. * @return the texture itself allowing "fluent" like uniform updates
  13987. */
  13988. setTexture(name: string, texture: Texture): ProceduralTexture;
  13989. /**
  13990. * Set a float in the shader.
  13991. * @param name Define the name of the uniform as defined in the shader
  13992. * @param value Define the value to give to the uniform
  13993. * @return the texture itself allowing "fluent" like uniform updates
  13994. */
  13995. setFloat(name: string, value: number): ProceduralTexture;
  13996. /**
  13997. * Set a int in the shader.
  13998. * @param name Define the name of the uniform as defined in the shader
  13999. * @param value Define the value to give to the uniform
  14000. * @return the texture itself allowing "fluent" like uniform updates
  14001. */
  14002. setInt(name: string, value: number): ProceduralTexture;
  14003. /**
  14004. * Set an array of floats in the shader.
  14005. * @param name Define the name of the uniform as defined in the shader
  14006. * @param value Define the value to give to the uniform
  14007. * @return the texture itself allowing "fluent" like uniform updates
  14008. */
  14009. setFloats(name: string, value: number[]): ProceduralTexture;
  14010. /**
  14011. * Set a vec3 in the shader from a Color3.
  14012. * @param name Define the name of the uniform as defined in the shader
  14013. * @param value Define the value to give to the uniform
  14014. * @return the texture itself allowing "fluent" like uniform updates
  14015. */
  14016. setColor3(name: string, value: Color3): ProceduralTexture;
  14017. /**
  14018. * Set a vec4 in the shader from a Color4.
  14019. * @param name Define the name of the uniform as defined in the shader
  14020. * @param value Define the value to give to the uniform
  14021. * @return the texture itself allowing "fluent" like uniform updates
  14022. */
  14023. setColor4(name: string, value: Color4): ProceduralTexture;
  14024. /**
  14025. * Set a vec2 in the shader from a Vector2.
  14026. * @param name Define the name of the uniform as defined in the shader
  14027. * @param value Define the value to give to the uniform
  14028. * @return the texture itself allowing "fluent" like uniform updates
  14029. */
  14030. setVector2(name: string, value: Vector2): ProceduralTexture;
  14031. /**
  14032. * Set a vec3 in the shader from a Vector3.
  14033. * @param name Define the name of the uniform as defined in the shader
  14034. * @param value Define the value to give to the uniform
  14035. * @return the texture itself allowing "fluent" like uniform updates
  14036. */
  14037. setVector3(name: string, value: Vector3): ProceduralTexture;
  14038. /**
  14039. * Set a mat4 in the shader from a MAtrix.
  14040. * @param name Define the name of the uniform as defined in the shader
  14041. * @param value Define the value to give to the uniform
  14042. * @return the texture itself allowing "fluent" like uniform updates
  14043. */
  14044. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14045. /**
  14046. * Render the texture to its associated render target.
  14047. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14048. */
  14049. render(useCameraPostProcess?: boolean): void;
  14050. /**
  14051. * Clone the texture.
  14052. * @returns the cloned texture
  14053. */
  14054. clone(): ProceduralTexture;
  14055. /**
  14056. * Dispose the texture and release its asoociated resources.
  14057. */
  14058. dispose(): void;
  14059. }
  14060. }
  14061. declare module "babylonjs/Particles/baseParticleSystem" {
  14062. import { Nullable } from "babylonjs/types";
  14063. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14065. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14066. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14067. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14068. import { Scene } from "babylonjs/scene";
  14069. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14070. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14071. import { Texture } from "babylonjs/Materials/Textures/texture";
  14072. import { Animation } from "babylonjs/Animations/animation";
  14073. /**
  14074. * This represents the base class for particle system in Babylon.
  14075. * 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.
  14076. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14077. * @example https://doc.babylonjs.com/babylon101/particles
  14078. */
  14079. export class BaseParticleSystem {
  14080. /**
  14081. * Source color is added to the destination color without alpha affecting the result
  14082. */
  14083. static BLENDMODE_ONEONE: number;
  14084. /**
  14085. * Blend current color and particle color using particle’s alpha
  14086. */
  14087. static BLENDMODE_STANDARD: number;
  14088. /**
  14089. * Add current color and particle color multiplied by particle’s alpha
  14090. */
  14091. static BLENDMODE_ADD: number;
  14092. /**
  14093. * Multiply current color with particle color
  14094. */
  14095. static BLENDMODE_MULTIPLY: number;
  14096. /**
  14097. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14098. */
  14099. static BLENDMODE_MULTIPLYADD: number;
  14100. /**
  14101. * List of animations used by the particle system.
  14102. */
  14103. animations: Animation[];
  14104. /**
  14105. * The id of the Particle system.
  14106. */
  14107. id: string;
  14108. /**
  14109. * The friendly name of the Particle system.
  14110. */
  14111. name: string;
  14112. /**
  14113. * The rendering group used by the Particle system to chose when to render.
  14114. */
  14115. renderingGroupId: number;
  14116. /**
  14117. * The emitter represents the Mesh or position we are attaching the particle system to.
  14118. */
  14119. emitter: Nullable<AbstractMesh | Vector3>;
  14120. /**
  14121. * The maximum number of particles to emit per frame
  14122. */
  14123. emitRate: number;
  14124. /**
  14125. * If you want to launch only a few particles at once, that can be done, as well.
  14126. */
  14127. manualEmitCount: number;
  14128. /**
  14129. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14130. */
  14131. updateSpeed: number;
  14132. /**
  14133. * The amount of time the particle system is running (depends of the overall update speed).
  14134. */
  14135. targetStopDuration: number;
  14136. /**
  14137. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14138. */
  14139. disposeOnStop: boolean;
  14140. /**
  14141. * Minimum power of emitting particles.
  14142. */
  14143. minEmitPower: number;
  14144. /**
  14145. * Maximum power of emitting particles.
  14146. */
  14147. maxEmitPower: number;
  14148. /**
  14149. * Minimum life time of emitting particles.
  14150. */
  14151. minLifeTime: number;
  14152. /**
  14153. * Maximum life time of emitting particles.
  14154. */
  14155. maxLifeTime: number;
  14156. /**
  14157. * Minimum Size of emitting particles.
  14158. */
  14159. minSize: number;
  14160. /**
  14161. * Maximum Size of emitting particles.
  14162. */
  14163. maxSize: number;
  14164. /**
  14165. * Minimum scale of emitting particles on X axis.
  14166. */
  14167. minScaleX: number;
  14168. /**
  14169. * Maximum scale of emitting particles on X axis.
  14170. */
  14171. maxScaleX: number;
  14172. /**
  14173. * Minimum scale of emitting particles on Y axis.
  14174. */
  14175. minScaleY: number;
  14176. /**
  14177. * Maximum scale of emitting particles on Y axis.
  14178. */
  14179. maxScaleY: number;
  14180. /**
  14181. * Gets or sets the minimal initial rotation in radians.
  14182. */
  14183. minInitialRotation: number;
  14184. /**
  14185. * Gets or sets the maximal initial rotation in radians.
  14186. */
  14187. maxInitialRotation: number;
  14188. /**
  14189. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14190. */
  14191. minAngularSpeed: number;
  14192. /**
  14193. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14194. */
  14195. maxAngularSpeed: number;
  14196. /**
  14197. * The texture used to render each particle. (this can be a spritesheet)
  14198. */
  14199. particleTexture: Nullable<Texture>;
  14200. /**
  14201. * The layer mask we are rendering the particles through.
  14202. */
  14203. layerMask: number;
  14204. /**
  14205. * This can help using your own shader to render the particle system.
  14206. * The according effect will be created
  14207. */
  14208. customShader: any;
  14209. /**
  14210. * By default particle system starts as soon as they are created. This prevents the
  14211. * automatic start to happen and let you decide when to start emitting particles.
  14212. */
  14213. preventAutoStart: boolean;
  14214. private _noiseTexture;
  14215. /**
  14216. * Gets or sets a texture used to add random noise to particle positions
  14217. */
  14218. noiseTexture: Nullable<ProceduralTexture>;
  14219. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14220. noiseStrength: Vector3;
  14221. /**
  14222. * Callback triggered when the particle animation is ending.
  14223. */
  14224. onAnimationEnd: Nullable<() => void>;
  14225. /**
  14226. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14227. */
  14228. blendMode: number;
  14229. /**
  14230. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14231. * to override the particles.
  14232. */
  14233. forceDepthWrite: boolean;
  14234. /** 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 */
  14235. preWarmCycles: number;
  14236. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14237. preWarmStepOffset: number;
  14238. /**
  14239. * 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)
  14240. */
  14241. spriteCellChangeSpeed: number;
  14242. /**
  14243. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14244. */
  14245. startSpriteCellID: number;
  14246. /**
  14247. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14248. */
  14249. endSpriteCellID: number;
  14250. /**
  14251. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14252. */
  14253. spriteCellWidth: number;
  14254. /**
  14255. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14256. */
  14257. spriteCellHeight: number;
  14258. /**
  14259. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14260. */
  14261. spriteRandomStartCell: boolean;
  14262. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14263. translationPivot: Vector2;
  14264. /** @hidden */
  14265. protected _isAnimationSheetEnabled: boolean;
  14266. /**
  14267. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14268. */
  14269. beginAnimationOnStart: boolean;
  14270. /**
  14271. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14272. */
  14273. beginAnimationFrom: number;
  14274. /**
  14275. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14276. */
  14277. beginAnimationTo: number;
  14278. /**
  14279. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14280. */
  14281. beginAnimationLoop: boolean;
  14282. /**
  14283. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14284. */
  14285. isAnimationSheetEnabled: boolean;
  14286. /**
  14287. * Get hosting scene
  14288. * @returns the scene
  14289. */
  14290. getScene(): Scene;
  14291. /**
  14292. * You can use gravity if you want to give an orientation to your particles.
  14293. */
  14294. gravity: Vector3;
  14295. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14296. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14297. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14298. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14299. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14300. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14301. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14302. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14303. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14304. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14305. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14306. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14307. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14308. /**
  14309. * Defines the delay in milliseconds before starting the system (0 by default)
  14310. */
  14311. startDelay: number;
  14312. /**
  14313. * Gets the current list of drag gradients.
  14314. * You must use addDragGradient and removeDragGradient to udpate this list
  14315. * @returns the list of drag gradients
  14316. */
  14317. getDragGradients(): Nullable<Array<FactorGradient>>;
  14318. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14319. limitVelocityDamping: number;
  14320. /**
  14321. * Gets the current list of limit velocity gradients.
  14322. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14323. * @returns the list of limit velocity gradients
  14324. */
  14325. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14326. /**
  14327. * Gets the current list of color gradients.
  14328. * You must use addColorGradient and removeColorGradient to udpate this list
  14329. * @returns the list of color gradients
  14330. */
  14331. getColorGradients(): Nullable<Array<ColorGradient>>;
  14332. /**
  14333. * Gets the current list of size gradients.
  14334. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14335. * @returns the list of size gradients
  14336. */
  14337. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14338. /**
  14339. * Gets the current list of color remap gradients.
  14340. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14341. * @returns the list of color remap gradients
  14342. */
  14343. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14344. /**
  14345. * Gets the current list of alpha remap gradients.
  14346. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14347. * @returns the list of alpha remap gradients
  14348. */
  14349. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14350. /**
  14351. * Gets the current list of life time gradients.
  14352. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14353. * @returns the list of life time gradients
  14354. */
  14355. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14356. /**
  14357. * Gets the current list of angular speed gradients.
  14358. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14359. * @returns the list of angular speed gradients
  14360. */
  14361. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14362. /**
  14363. * Gets the current list of velocity gradients.
  14364. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14365. * @returns the list of velocity gradients
  14366. */
  14367. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14368. /**
  14369. * Gets the current list of start size gradients.
  14370. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14371. * @returns the list of start size gradients
  14372. */
  14373. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14374. /**
  14375. * Gets the current list of emit rate gradients.
  14376. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14377. * @returns the list of emit rate gradients
  14378. */
  14379. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14380. /**
  14381. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14382. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14383. */
  14384. direction1: Vector3;
  14385. /**
  14386. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14387. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14388. */
  14389. direction2: Vector3;
  14390. /**
  14391. * 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.
  14392. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14393. */
  14394. minEmitBox: Vector3;
  14395. /**
  14396. * 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.
  14397. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14398. */
  14399. maxEmitBox: Vector3;
  14400. /**
  14401. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14402. */
  14403. color1: Color4;
  14404. /**
  14405. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14406. */
  14407. color2: Color4;
  14408. /**
  14409. * Color the particle will have at the end of its lifetime
  14410. */
  14411. colorDead: Color4;
  14412. /**
  14413. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14414. */
  14415. textureMask: Color4;
  14416. /**
  14417. * The particle emitter type defines the emitter used by the particle system.
  14418. * It can be for example box, sphere, or cone...
  14419. */
  14420. particleEmitterType: IParticleEmitterType;
  14421. /** @hidden */
  14422. _isSubEmitter: boolean;
  14423. /**
  14424. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14425. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14426. */
  14427. billboardMode: number;
  14428. protected _isBillboardBased: boolean;
  14429. /**
  14430. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14431. */
  14432. isBillboardBased: boolean;
  14433. /**
  14434. * The scene the particle system belongs to.
  14435. */
  14436. protected _scene: Scene;
  14437. /**
  14438. * Local cache of defines for image processing.
  14439. */
  14440. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14441. /**
  14442. * Default configuration related to image processing available in the standard Material.
  14443. */
  14444. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14445. /**
  14446. * Gets the image processing configuration used either in this material.
  14447. */
  14448. /**
  14449. * Sets the Default image processing configuration used either in the this material.
  14450. *
  14451. * If sets to null, the scene one is in use.
  14452. */
  14453. imageProcessingConfiguration: ImageProcessingConfiguration;
  14454. /**
  14455. * Attaches a new image processing configuration to the Standard Material.
  14456. * @param configuration
  14457. */
  14458. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14459. /** @hidden */
  14460. protected _reset(): void;
  14461. /** @hidden */
  14462. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14463. /**
  14464. * Instantiates a particle system.
  14465. * 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.
  14466. * @param name The name of the particle system
  14467. */
  14468. constructor(name: string);
  14469. /**
  14470. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14471. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14472. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14473. * @returns the emitter
  14474. */
  14475. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14476. /**
  14477. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14478. * @param radius The radius of the hemisphere to emit from
  14479. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14480. * @returns the emitter
  14481. */
  14482. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14483. /**
  14484. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14485. * @param radius The radius of the sphere to emit from
  14486. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14487. * @returns the emitter
  14488. */
  14489. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14490. /**
  14491. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14492. * @param radius The radius of the sphere to emit from
  14493. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14494. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14495. * @returns the emitter
  14496. */
  14497. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14498. /**
  14499. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14500. * @param radius The radius of the emission cylinder
  14501. * @param height The height of the emission cylinder
  14502. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14503. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14504. * @returns the emitter
  14505. */
  14506. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14507. /**
  14508. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14509. * @param radius The radius of the cylinder to emit from
  14510. * @param height The height of the emission cylinder
  14511. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14512. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14513. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14514. * @returns the emitter
  14515. */
  14516. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14517. /**
  14518. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14519. * @param radius The radius of the cone to emit from
  14520. * @param angle The base angle of the cone
  14521. * @returns the emitter
  14522. */
  14523. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14524. /**
  14525. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14526. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14527. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14528. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14529. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14530. * @returns the emitter
  14531. */
  14532. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14533. }
  14534. }
  14535. declare module "babylonjs/Particles/subEmitter" {
  14536. import { Scene } from "babylonjs/scene";
  14537. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14538. /**
  14539. * Type of sub emitter
  14540. */
  14541. export enum SubEmitterType {
  14542. /**
  14543. * Attached to the particle over it's lifetime
  14544. */
  14545. ATTACHED = 0,
  14546. /**
  14547. * Created when the particle dies
  14548. */
  14549. END = 1
  14550. }
  14551. /**
  14552. * Sub emitter class used to emit particles from an existing particle
  14553. */
  14554. export class SubEmitter {
  14555. /**
  14556. * the particle system to be used by the sub emitter
  14557. */
  14558. particleSystem: ParticleSystem;
  14559. /**
  14560. * Type of the submitter (Default: END)
  14561. */
  14562. type: SubEmitterType;
  14563. /**
  14564. * 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)
  14565. * Note: This only is supported when using an emitter of type Mesh
  14566. */
  14567. inheritDirection: boolean;
  14568. /**
  14569. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14570. */
  14571. inheritedVelocityAmount: number;
  14572. /**
  14573. * Creates a sub emitter
  14574. * @param particleSystem the particle system to be used by the sub emitter
  14575. */
  14576. constructor(
  14577. /**
  14578. * the particle system to be used by the sub emitter
  14579. */
  14580. particleSystem: ParticleSystem);
  14581. /**
  14582. * Clones the sub emitter
  14583. * @returns the cloned sub emitter
  14584. */
  14585. clone(): SubEmitter;
  14586. /**
  14587. * Serialize current object to a JSON object
  14588. * @returns the serialized object
  14589. */
  14590. serialize(): any;
  14591. /** @hidden */
  14592. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14593. /**
  14594. * Creates a new SubEmitter from a serialized JSON version
  14595. * @param serializationObject defines the JSON object to read from
  14596. * @param scene defines the hosting scene
  14597. * @param rootUrl defines the rootUrl for data loading
  14598. * @returns a new SubEmitter
  14599. */
  14600. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14601. /** Release associated resources */
  14602. dispose(): void;
  14603. }
  14604. }
  14605. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14606. /** @hidden */
  14607. export var clipPlaneFragmentDeclaration: {
  14608. name: string;
  14609. shader: string;
  14610. };
  14611. }
  14612. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14613. /** @hidden */
  14614. export var imageProcessingDeclaration: {
  14615. name: string;
  14616. shader: string;
  14617. };
  14618. }
  14619. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14620. /** @hidden */
  14621. export var imageProcessingFunctions: {
  14622. name: string;
  14623. shader: string;
  14624. };
  14625. }
  14626. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14627. /** @hidden */
  14628. export var clipPlaneFragment: {
  14629. name: string;
  14630. shader: string;
  14631. };
  14632. }
  14633. declare module "babylonjs/Shaders/particles.fragment" {
  14634. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14635. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14636. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14637. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14638. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14639. /** @hidden */
  14640. export var particlesPixelShader: {
  14641. name: string;
  14642. shader: string;
  14643. };
  14644. }
  14645. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14646. /** @hidden */
  14647. export var clipPlaneVertexDeclaration: {
  14648. name: string;
  14649. shader: string;
  14650. };
  14651. }
  14652. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14653. /** @hidden */
  14654. export var clipPlaneVertex: {
  14655. name: string;
  14656. shader: string;
  14657. };
  14658. }
  14659. declare module "babylonjs/Shaders/particles.vertex" {
  14660. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14661. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14662. /** @hidden */
  14663. export var particlesVertexShader: {
  14664. name: string;
  14665. shader: string;
  14666. };
  14667. }
  14668. declare module "babylonjs/Particles/particleSystem" {
  14669. import { Nullable } from "babylonjs/types";
  14670. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14671. import { Observable } from "babylonjs/Misc/observable";
  14672. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14673. import { Effect } from "babylonjs/Materials/effect";
  14674. import { Scene, IDisposable } from "babylonjs/scene";
  14675. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14676. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14677. import { Particle } from "babylonjs/Particles/particle";
  14678. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14679. import "babylonjs/Shaders/particles.fragment";
  14680. import "babylonjs/Shaders/particles.vertex";
  14681. /**
  14682. * This represents a particle system in Babylon.
  14683. * 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.
  14684. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14685. * @example https://doc.babylonjs.com/babylon101/particles
  14686. */
  14687. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14688. /**
  14689. * Billboard mode will only apply to Y axis
  14690. */
  14691. static readonly BILLBOARDMODE_Y: number;
  14692. /**
  14693. * Billboard mode will apply to all axes
  14694. */
  14695. static readonly BILLBOARDMODE_ALL: number;
  14696. /**
  14697. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14698. */
  14699. static readonly BILLBOARDMODE_STRETCHED: number;
  14700. /**
  14701. * This function can be defined to provide custom update for active particles.
  14702. * This function will be called instead of regular update (age, position, color, etc.).
  14703. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14704. */
  14705. updateFunction: (particles: Particle[]) => void;
  14706. private _emitterWorldMatrix;
  14707. /**
  14708. * This function can be defined to specify initial direction for every new particle.
  14709. * It by default use the emitterType defined function
  14710. */
  14711. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14712. /**
  14713. * This function can be defined to specify initial position for every new particle.
  14714. * It by default use the emitterType defined function
  14715. */
  14716. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14717. /**
  14718. * @hidden
  14719. */
  14720. _inheritedVelocityOffset: Vector3;
  14721. /**
  14722. * An event triggered when the system is disposed
  14723. */
  14724. onDisposeObservable: Observable<ParticleSystem>;
  14725. private _onDisposeObserver;
  14726. /**
  14727. * Sets a callback that will be triggered when the system is disposed
  14728. */
  14729. onDispose: () => void;
  14730. private _particles;
  14731. private _epsilon;
  14732. private _capacity;
  14733. private _stockParticles;
  14734. private _newPartsExcess;
  14735. private _vertexData;
  14736. private _vertexBuffer;
  14737. private _vertexBuffers;
  14738. private _spriteBuffer;
  14739. private _indexBuffer;
  14740. private _effect;
  14741. private _customEffect;
  14742. private _cachedDefines;
  14743. private _scaledColorStep;
  14744. private _colorDiff;
  14745. private _scaledDirection;
  14746. private _scaledGravity;
  14747. private _currentRenderId;
  14748. private _alive;
  14749. private _useInstancing;
  14750. private _started;
  14751. private _stopped;
  14752. private _actualFrame;
  14753. private _scaledUpdateSpeed;
  14754. private _vertexBufferSize;
  14755. /** @hidden */
  14756. _currentEmitRateGradient: Nullable<FactorGradient>;
  14757. /** @hidden */
  14758. _currentEmitRate1: number;
  14759. /** @hidden */
  14760. _currentEmitRate2: number;
  14761. /** @hidden */
  14762. _currentStartSizeGradient: Nullable<FactorGradient>;
  14763. /** @hidden */
  14764. _currentStartSize1: number;
  14765. /** @hidden */
  14766. _currentStartSize2: number;
  14767. private readonly _rawTextureWidth;
  14768. private _rampGradientsTexture;
  14769. private _useRampGradients;
  14770. /** Gets or sets a boolean indicating that ramp gradients must be used
  14771. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14772. */
  14773. useRampGradients: boolean;
  14774. /**
  14775. * 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.
  14776. * 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: [])
  14777. */
  14778. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14779. private _subEmitters;
  14780. /**
  14781. * @hidden
  14782. * If the particle systems emitter should be disposed when the particle system is disposed
  14783. */
  14784. _disposeEmitterOnDispose: boolean;
  14785. /**
  14786. * The current active Sub-systems, this property is used by the root particle system only.
  14787. */
  14788. activeSubSystems: Array<ParticleSystem>;
  14789. private _rootParticleSystem;
  14790. /**
  14791. * Gets the current list of active particles
  14792. */
  14793. readonly particles: Particle[];
  14794. /**
  14795. * Returns the string "ParticleSystem"
  14796. * @returns a string containing the class name
  14797. */
  14798. getClassName(): string;
  14799. /**
  14800. * Instantiates a particle system.
  14801. * 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.
  14802. * @param name The name of the particle system
  14803. * @param capacity The max number of particles alive at the same time
  14804. * @param scene The scene the particle system belongs to
  14805. * @param customEffect a custom effect used to change the way particles are rendered by default
  14806. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14807. * @param epsilon Offset used to render the particles
  14808. */
  14809. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14810. private _addFactorGradient;
  14811. private _removeFactorGradient;
  14812. /**
  14813. * Adds a new life time gradient
  14814. * @param gradient defines the gradient to use (between 0 and 1)
  14815. * @param factor defines the life time factor to affect to the specified gradient
  14816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14817. * @returns the current particle system
  14818. */
  14819. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14820. /**
  14821. * Remove a specific life time gradient
  14822. * @param gradient defines the gradient to remove
  14823. * @returns the current particle system
  14824. */
  14825. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14826. /**
  14827. * Adds a new size gradient
  14828. * @param gradient defines the gradient to use (between 0 and 1)
  14829. * @param factor defines the size factor to affect to the specified gradient
  14830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14831. * @returns the current particle system
  14832. */
  14833. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14834. /**
  14835. * Remove a specific size gradient
  14836. * @param gradient defines the gradient to remove
  14837. * @returns the current particle system
  14838. */
  14839. removeSizeGradient(gradient: number): IParticleSystem;
  14840. /**
  14841. * Adds a new color remap gradient
  14842. * @param gradient defines the gradient to use (between 0 and 1)
  14843. * @param min defines the color remap minimal range
  14844. * @param max defines the color remap maximal range
  14845. * @returns the current particle system
  14846. */
  14847. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14848. /**
  14849. * Remove a specific color remap gradient
  14850. * @param gradient defines the gradient to remove
  14851. * @returns the current particle system
  14852. */
  14853. removeColorRemapGradient(gradient: number): IParticleSystem;
  14854. /**
  14855. * Adds a new alpha remap gradient
  14856. * @param gradient defines the gradient to use (between 0 and 1)
  14857. * @param min defines the alpha remap minimal range
  14858. * @param max defines the alpha remap maximal range
  14859. * @returns the current particle system
  14860. */
  14861. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14862. /**
  14863. * Remove a specific alpha remap gradient
  14864. * @param gradient defines the gradient to remove
  14865. * @returns the current particle system
  14866. */
  14867. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14868. /**
  14869. * Adds a new angular speed gradient
  14870. * @param gradient defines the gradient to use (between 0 and 1)
  14871. * @param factor defines the angular speed to affect to the specified gradient
  14872. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14873. * @returns the current particle system
  14874. */
  14875. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14876. /**
  14877. * Remove a specific angular speed gradient
  14878. * @param gradient defines the gradient to remove
  14879. * @returns the current particle system
  14880. */
  14881. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14882. /**
  14883. * Adds a new velocity gradient
  14884. * @param gradient defines the gradient to use (between 0 and 1)
  14885. * @param factor defines the velocity to affect to the specified gradient
  14886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14887. * @returns the current particle system
  14888. */
  14889. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14890. /**
  14891. * Remove a specific velocity gradient
  14892. * @param gradient defines the gradient to remove
  14893. * @returns the current particle system
  14894. */
  14895. removeVelocityGradient(gradient: number): IParticleSystem;
  14896. /**
  14897. * Adds a new limit velocity gradient
  14898. * @param gradient defines the gradient to use (between 0 and 1)
  14899. * @param factor defines the limit velocity value to affect to the specified gradient
  14900. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14901. * @returns the current particle system
  14902. */
  14903. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14904. /**
  14905. * Remove a specific limit velocity gradient
  14906. * @param gradient defines the gradient to remove
  14907. * @returns the current particle system
  14908. */
  14909. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14910. /**
  14911. * Adds a new drag gradient
  14912. * @param gradient defines the gradient to use (between 0 and 1)
  14913. * @param factor defines the drag value to affect to the specified gradient
  14914. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14915. * @returns the current particle system
  14916. */
  14917. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14918. /**
  14919. * Remove a specific drag gradient
  14920. * @param gradient defines the gradient to remove
  14921. * @returns the current particle system
  14922. */
  14923. removeDragGradient(gradient: number): IParticleSystem;
  14924. /**
  14925. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14926. * @param gradient defines the gradient to use (between 0 and 1)
  14927. * @param factor defines the emit rate value to affect to the specified gradient
  14928. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14929. * @returns the current particle system
  14930. */
  14931. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14932. /**
  14933. * Remove a specific emit rate gradient
  14934. * @param gradient defines the gradient to remove
  14935. * @returns the current particle system
  14936. */
  14937. removeEmitRateGradient(gradient: number): IParticleSystem;
  14938. /**
  14939. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14940. * @param gradient defines the gradient to use (between 0 and 1)
  14941. * @param factor defines the start size value to affect to the specified gradient
  14942. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14943. * @returns the current particle system
  14944. */
  14945. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14946. /**
  14947. * Remove a specific start size gradient
  14948. * @param gradient defines the gradient to remove
  14949. * @returns the current particle system
  14950. */
  14951. removeStartSizeGradient(gradient: number): IParticleSystem;
  14952. private _createRampGradientTexture;
  14953. /**
  14954. * Gets the current list of ramp gradients.
  14955. * You must use addRampGradient and removeRampGradient to udpate this list
  14956. * @returns the list of ramp gradients
  14957. */
  14958. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14959. /**
  14960. * Adds a new ramp gradient used to remap particle colors
  14961. * @param gradient defines the gradient to use (between 0 and 1)
  14962. * @param color defines the color to affect to the specified gradient
  14963. * @returns the current particle system
  14964. */
  14965. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14966. /**
  14967. * Remove a specific ramp gradient
  14968. * @param gradient defines the gradient to remove
  14969. * @returns the current particle system
  14970. */
  14971. removeRampGradient(gradient: number): ParticleSystem;
  14972. /**
  14973. * Adds a new color gradient
  14974. * @param gradient defines the gradient to use (between 0 and 1)
  14975. * @param color1 defines the color to affect to the specified gradient
  14976. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14977. * @returns this particle system
  14978. */
  14979. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14980. /**
  14981. * Remove a specific color gradient
  14982. * @param gradient defines the gradient to remove
  14983. * @returns this particle system
  14984. */
  14985. removeColorGradient(gradient: number): IParticleSystem;
  14986. private _fetchR;
  14987. protected _reset(): void;
  14988. private _resetEffect;
  14989. private _createVertexBuffers;
  14990. private _createIndexBuffer;
  14991. /**
  14992. * Gets the maximum number of particles active at the same time.
  14993. * @returns The max number of active particles.
  14994. */
  14995. getCapacity(): number;
  14996. /**
  14997. * Gets whether there are still active particles in the system.
  14998. * @returns True if it is alive, otherwise false.
  14999. */
  15000. isAlive(): boolean;
  15001. /**
  15002. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15003. * @returns True if it has been started, otherwise false.
  15004. */
  15005. isStarted(): boolean;
  15006. private _prepareSubEmitterInternalArray;
  15007. /**
  15008. * Starts the particle system and begins to emit
  15009. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15010. */
  15011. start(delay?: number): void;
  15012. /**
  15013. * Stops the particle system.
  15014. * @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.
  15015. */
  15016. stop(stopSubEmitters?: boolean): void;
  15017. /**
  15018. * Remove all active particles
  15019. */
  15020. reset(): void;
  15021. /**
  15022. * @hidden (for internal use only)
  15023. */
  15024. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15025. /**
  15026. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15027. * Its lifetime will start back at 0.
  15028. */
  15029. recycleParticle: (particle: Particle) => void;
  15030. private _stopSubEmitters;
  15031. private _createParticle;
  15032. private _removeFromRoot;
  15033. private _emitFromParticle;
  15034. private _update;
  15035. /** @hidden */
  15036. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15037. /** @hidden */
  15038. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15039. /** @hidden */
  15040. private _getEffect;
  15041. /**
  15042. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15043. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15044. */
  15045. animate(preWarmOnly?: boolean): void;
  15046. private _appendParticleVertices;
  15047. /**
  15048. * Rebuilds the particle system.
  15049. */
  15050. rebuild(): void;
  15051. /**
  15052. * Is this system ready to be used/rendered
  15053. * @return true if the system is ready
  15054. */
  15055. isReady(): boolean;
  15056. private _render;
  15057. /**
  15058. * Renders the particle system in its current state.
  15059. * @returns the current number of particles
  15060. */
  15061. render(): number;
  15062. /**
  15063. * Disposes the particle system and free the associated resources
  15064. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15065. */
  15066. dispose(disposeTexture?: boolean): void;
  15067. /**
  15068. * Clones the particle system.
  15069. * @param name The name of the cloned object
  15070. * @param newEmitter The new emitter to use
  15071. * @returns the cloned particle system
  15072. */
  15073. clone(name: string, newEmitter: any): ParticleSystem;
  15074. /**
  15075. * Serializes the particle system to a JSON object.
  15076. * @returns the JSON object
  15077. */
  15078. serialize(): any;
  15079. /** @hidden */
  15080. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15081. /** @hidden */
  15082. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15083. /**
  15084. * Parses a JSON object to create a particle system.
  15085. * @param parsedParticleSystem The JSON object to parse
  15086. * @param scene The scene to create the particle system in
  15087. * @param rootUrl The root url to use to load external dependencies like texture
  15088. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15089. * @returns the Parsed particle system
  15090. */
  15091. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15092. }
  15093. }
  15094. declare module "babylonjs/Particles/particle" {
  15095. import { Nullable } from "babylonjs/types";
  15096. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15097. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15098. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15099. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15100. /**
  15101. * A particle represents one of the element emitted by a particle system.
  15102. * This is mainly define by its coordinates, direction, velocity and age.
  15103. */
  15104. export class Particle {
  15105. /**
  15106. * The particle system the particle belongs to.
  15107. */
  15108. particleSystem: ParticleSystem;
  15109. private static _Count;
  15110. /**
  15111. * Unique ID of the particle
  15112. */
  15113. id: number;
  15114. /**
  15115. * The world position of the particle in the scene.
  15116. */
  15117. position: Vector3;
  15118. /**
  15119. * The world direction of the particle in the scene.
  15120. */
  15121. direction: Vector3;
  15122. /**
  15123. * The color of the particle.
  15124. */
  15125. color: Color4;
  15126. /**
  15127. * The color change of the particle per step.
  15128. */
  15129. colorStep: Color4;
  15130. /**
  15131. * Defines how long will the life of the particle be.
  15132. */
  15133. lifeTime: number;
  15134. /**
  15135. * The current age of the particle.
  15136. */
  15137. age: number;
  15138. /**
  15139. * The current size of the particle.
  15140. */
  15141. size: number;
  15142. /**
  15143. * The current scale of the particle.
  15144. */
  15145. scale: Vector2;
  15146. /**
  15147. * The current angle of the particle.
  15148. */
  15149. angle: number;
  15150. /**
  15151. * Defines how fast is the angle changing.
  15152. */
  15153. angularSpeed: number;
  15154. /**
  15155. * Defines the cell index used by the particle to be rendered from a sprite.
  15156. */
  15157. cellIndex: number;
  15158. /**
  15159. * The information required to support color remapping
  15160. */
  15161. remapData: Vector4;
  15162. /** @hidden */
  15163. _randomCellOffset?: number;
  15164. /** @hidden */
  15165. _initialDirection: Nullable<Vector3>;
  15166. /** @hidden */
  15167. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15168. /** @hidden */
  15169. _initialStartSpriteCellID: number;
  15170. /** @hidden */
  15171. _initialEndSpriteCellID: number;
  15172. /** @hidden */
  15173. _currentColorGradient: Nullable<ColorGradient>;
  15174. /** @hidden */
  15175. _currentColor1: Color4;
  15176. /** @hidden */
  15177. _currentColor2: Color4;
  15178. /** @hidden */
  15179. _currentSizeGradient: Nullable<FactorGradient>;
  15180. /** @hidden */
  15181. _currentSize1: number;
  15182. /** @hidden */
  15183. _currentSize2: number;
  15184. /** @hidden */
  15185. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15186. /** @hidden */
  15187. _currentAngularSpeed1: number;
  15188. /** @hidden */
  15189. _currentAngularSpeed2: number;
  15190. /** @hidden */
  15191. _currentVelocityGradient: Nullable<FactorGradient>;
  15192. /** @hidden */
  15193. _currentVelocity1: number;
  15194. /** @hidden */
  15195. _currentVelocity2: number;
  15196. /** @hidden */
  15197. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15198. /** @hidden */
  15199. _currentLimitVelocity1: number;
  15200. /** @hidden */
  15201. _currentLimitVelocity2: number;
  15202. /** @hidden */
  15203. _currentDragGradient: Nullable<FactorGradient>;
  15204. /** @hidden */
  15205. _currentDrag1: number;
  15206. /** @hidden */
  15207. _currentDrag2: number;
  15208. /** @hidden */
  15209. _randomNoiseCoordinates1: Vector3;
  15210. /** @hidden */
  15211. _randomNoiseCoordinates2: Vector3;
  15212. /**
  15213. * Creates a new instance Particle
  15214. * @param particleSystem the particle system the particle belongs to
  15215. */
  15216. constructor(
  15217. /**
  15218. * The particle system the particle belongs to.
  15219. */
  15220. particleSystem: ParticleSystem);
  15221. private updateCellInfoFromSystem;
  15222. /**
  15223. * Defines how the sprite cell index is updated for the particle
  15224. */
  15225. updateCellIndex(): void;
  15226. /** @hidden */
  15227. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15228. /** @hidden */
  15229. _inheritParticleInfoToSubEmitters(): void;
  15230. /** @hidden */
  15231. _reset(): void;
  15232. /**
  15233. * Copy the properties of particle to another one.
  15234. * @param other the particle to copy the information to.
  15235. */
  15236. copyTo(other: Particle): void;
  15237. }
  15238. }
  15239. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15240. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15241. import { Effect } from "babylonjs/Materials/effect";
  15242. import { Particle } from "babylonjs/Particles/particle";
  15243. /**
  15244. * Particle emitter represents a volume emitting particles.
  15245. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15246. */
  15247. export interface IParticleEmitterType {
  15248. /**
  15249. * Called by the particle System when the direction is computed for the created particle.
  15250. * @param worldMatrix is the world matrix of the particle system
  15251. * @param directionToUpdate is the direction vector to update with the result
  15252. * @param particle is the particle we are computed the direction for
  15253. */
  15254. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15255. /**
  15256. * Called by the particle System when the position is computed for the created particle.
  15257. * @param worldMatrix is the world matrix of the particle system
  15258. * @param positionToUpdate is the position vector to update with the result
  15259. * @param particle is the particle we are computed the position for
  15260. */
  15261. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15262. /**
  15263. * Clones the current emitter and returns a copy of it
  15264. * @returns the new emitter
  15265. */
  15266. clone(): IParticleEmitterType;
  15267. /**
  15268. * Called by the GPUParticleSystem to setup the update shader
  15269. * @param effect defines the update shader
  15270. */
  15271. applyToShader(effect: Effect): void;
  15272. /**
  15273. * Returns a string to use to update the GPU particles update shader
  15274. * @returns the effect defines string
  15275. */
  15276. getEffectDefines(): string;
  15277. /**
  15278. * Returns a string representing the class name
  15279. * @returns a string containing the class name
  15280. */
  15281. getClassName(): string;
  15282. /**
  15283. * Serializes the particle system to a JSON object.
  15284. * @returns the JSON object
  15285. */
  15286. serialize(): any;
  15287. /**
  15288. * Parse properties from a JSON object
  15289. * @param serializationObject defines the JSON object
  15290. */
  15291. parse(serializationObject: any): void;
  15292. }
  15293. }
  15294. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15295. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15296. import { Effect } from "babylonjs/Materials/effect";
  15297. import { Particle } from "babylonjs/Particles/particle";
  15298. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15299. /**
  15300. * Particle emitter emitting particles from the inside of a box.
  15301. * It emits the particles randomly between 2 given directions.
  15302. */
  15303. export class BoxParticleEmitter implements IParticleEmitterType {
  15304. /**
  15305. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15306. */
  15307. direction1: Vector3;
  15308. /**
  15309. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15310. */
  15311. direction2: Vector3;
  15312. /**
  15313. * 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.
  15314. */
  15315. minEmitBox: Vector3;
  15316. /**
  15317. * 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.
  15318. */
  15319. maxEmitBox: Vector3;
  15320. /**
  15321. * Creates a new instance BoxParticleEmitter
  15322. */
  15323. constructor();
  15324. /**
  15325. * Called by the particle System when the direction is computed for the created particle.
  15326. * @param worldMatrix is the world matrix of the particle system
  15327. * @param directionToUpdate is the direction vector to update with the result
  15328. * @param particle is the particle we are computed the direction for
  15329. */
  15330. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15331. /**
  15332. * Called by the particle System when the position is computed for the created particle.
  15333. * @param worldMatrix is the world matrix of the particle system
  15334. * @param positionToUpdate is the position vector to update with the result
  15335. * @param particle is the particle we are computed the position for
  15336. */
  15337. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15338. /**
  15339. * Clones the current emitter and returns a copy of it
  15340. * @returns the new emitter
  15341. */
  15342. clone(): BoxParticleEmitter;
  15343. /**
  15344. * Called by the GPUParticleSystem to setup the update shader
  15345. * @param effect defines the update shader
  15346. */
  15347. applyToShader(effect: Effect): void;
  15348. /**
  15349. * Returns a string to use to update the GPU particles update shader
  15350. * @returns a string containng the defines string
  15351. */
  15352. getEffectDefines(): string;
  15353. /**
  15354. * Returns the string "BoxParticleEmitter"
  15355. * @returns a string containing the class name
  15356. */
  15357. getClassName(): string;
  15358. /**
  15359. * Serializes the particle system to a JSON object.
  15360. * @returns the JSON object
  15361. */
  15362. serialize(): any;
  15363. /**
  15364. * Parse properties from a JSON object
  15365. * @param serializationObject defines the JSON object
  15366. */
  15367. parse(serializationObject: any): void;
  15368. }
  15369. }
  15370. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15371. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15372. import { Effect } from "babylonjs/Materials/effect";
  15373. import { Particle } from "babylonjs/Particles/particle";
  15374. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15375. /**
  15376. * Particle emitter emitting particles from the inside of a cone.
  15377. * It emits the particles alongside the cone volume from the base to the particle.
  15378. * The emission direction might be randomized.
  15379. */
  15380. export class ConeParticleEmitter implements IParticleEmitterType {
  15381. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15382. directionRandomizer: number;
  15383. private _radius;
  15384. private _angle;
  15385. private _height;
  15386. /**
  15387. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15388. */
  15389. radiusRange: number;
  15390. /**
  15391. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15392. */
  15393. heightRange: number;
  15394. /**
  15395. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15396. */
  15397. emitFromSpawnPointOnly: boolean;
  15398. /**
  15399. * Gets or sets the radius of the emission cone
  15400. */
  15401. radius: number;
  15402. /**
  15403. * Gets or sets the angle of the emission cone
  15404. */
  15405. angle: number;
  15406. private _buildHeight;
  15407. /**
  15408. * Creates a new instance ConeParticleEmitter
  15409. * @param radius the radius of the emission cone (1 by default)
  15410. * @param angle the cone base angle (PI by default)
  15411. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15412. */
  15413. constructor(radius?: number, angle?: number,
  15414. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15415. directionRandomizer?: number);
  15416. /**
  15417. * Called by the particle System when the direction is computed for the created particle.
  15418. * @param worldMatrix is the world matrix of the particle system
  15419. * @param directionToUpdate is the direction vector to update with the result
  15420. * @param particle is the particle we are computed the direction for
  15421. */
  15422. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15423. /**
  15424. * Called by the particle System when the position is computed for the created particle.
  15425. * @param worldMatrix is the world matrix of the particle system
  15426. * @param positionToUpdate is the position vector to update with the result
  15427. * @param particle is the particle we are computed the position for
  15428. */
  15429. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15430. /**
  15431. * Clones the current emitter and returns a copy of it
  15432. * @returns the new emitter
  15433. */
  15434. clone(): ConeParticleEmitter;
  15435. /**
  15436. * Called by the GPUParticleSystem to setup the update shader
  15437. * @param effect defines the update shader
  15438. */
  15439. applyToShader(effect: Effect): void;
  15440. /**
  15441. * Returns a string to use to update the GPU particles update shader
  15442. * @returns a string containng the defines string
  15443. */
  15444. getEffectDefines(): string;
  15445. /**
  15446. * Returns the string "ConeParticleEmitter"
  15447. * @returns a string containing the class name
  15448. */
  15449. getClassName(): string;
  15450. /**
  15451. * Serializes the particle system to a JSON object.
  15452. * @returns the JSON object
  15453. */
  15454. serialize(): any;
  15455. /**
  15456. * Parse properties from a JSON object
  15457. * @param serializationObject defines the JSON object
  15458. */
  15459. parse(serializationObject: any): void;
  15460. }
  15461. }
  15462. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15463. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15464. import { Effect } from "babylonjs/Materials/effect";
  15465. import { Particle } from "babylonjs/Particles/particle";
  15466. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15467. /**
  15468. * Particle emitter emitting particles from the inside of a cylinder.
  15469. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15470. */
  15471. export class CylinderParticleEmitter implements IParticleEmitterType {
  15472. /**
  15473. * The radius of the emission cylinder.
  15474. */
  15475. radius: number;
  15476. /**
  15477. * The height of the emission cylinder.
  15478. */
  15479. height: number;
  15480. /**
  15481. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15482. */
  15483. radiusRange: number;
  15484. /**
  15485. * How much to randomize the particle direction [0-1].
  15486. */
  15487. directionRandomizer: number;
  15488. /**
  15489. * Creates a new instance CylinderParticleEmitter
  15490. * @param radius the radius of the emission cylinder (1 by default)
  15491. * @param height the height of the emission cylinder (1 by default)
  15492. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15493. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15494. */
  15495. constructor(
  15496. /**
  15497. * The radius of the emission cylinder.
  15498. */
  15499. radius?: number,
  15500. /**
  15501. * The height of the emission cylinder.
  15502. */
  15503. height?: number,
  15504. /**
  15505. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15506. */
  15507. radiusRange?: number,
  15508. /**
  15509. * How much to randomize the particle direction [0-1].
  15510. */
  15511. directionRandomizer?: number);
  15512. /**
  15513. * Called by the particle System when the direction is computed for the created particle.
  15514. * @param worldMatrix is the world matrix of the particle system
  15515. * @param directionToUpdate is the direction vector to update with the result
  15516. * @param particle is the particle we are computed the direction for
  15517. */
  15518. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15519. /**
  15520. * Called by the particle System when the position is computed for the created particle.
  15521. * @param worldMatrix is the world matrix of the particle system
  15522. * @param positionToUpdate is the position vector to update with the result
  15523. * @param particle is the particle we are computed the position for
  15524. */
  15525. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15526. /**
  15527. * Clones the current emitter and returns a copy of it
  15528. * @returns the new emitter
  15529. */
  15530. clone(): CylinderParticleEmitter;
  15531. /**
  15532. * Called by the GPUParticleSystem to setup the update shader
  15533. * @param effect defines the update shader
  15534. */
  15535. applyToShader(effect: Effect): void;
  15536. /**
  15537. * Returns a string to use to update the GPU particles update shader
  15538. * @returns a string containng the defines string
  15539. */
  15540. getEffectDefines(): string;
  15541. /**
  15542. * Returns the string "CylinderParticleEmitter"
  15543. * @returns a string containing the class name
  15544. */
  15545. getClassName(): string;
  15546. /**
  15547. * Serializes the particle system to a JSON object.
  15548. * @returns the JSON object
  15549. */
  15550. serialize(): any;
  15551. /**
  15552. * Parse properties from a JSON object
  15553. * @param serializationObject defines the JSON object
  15554. */
  15555. parse(serializationObject: any): void;
  15556. }
  15557. /**
  15558. * Particle emitter emitting particles from the inside of a cylinder.
  15559. * It emits the particles randomly between two vectors.
  15560. */
  15561. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15562. /**
  15563. * The min limit of the emission direction.
  15564. */
  15565. direction1: Vector3;
  15566. /**
  15567. * The max limit of the emission direction.
  15568. */
  15569. direction2: Vector3;
  15570. /**
  15571. * Creates a new instance CylinderDirectedParticleEmitter
  15572. * @param radius the radius of the emission cylinder (1 by default)
  15573. * @param height the height of the emission cylinder (1 by default)
  15574. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15575. * @param direction1 the min limit of the emission direction (up vector by default)
  15576. * @param direction2 the max limit of the emission direction (up vector by default)
  15577. */
  15578. constructor(radius?: number, height?: number, radiusRange?: number,
  15579. /**
  15580. * The min limit of the emission direction.
  15581. */
  15582. direction1?: Vector3,
  15583. /**
  15584. * The max limit of the emission direction.
  15585. */
  15586. direction2?: Vector3);
  15587. /**
  15588. * Called by the particle System when the direction is computed for the created particle.
  15589. * @param worldMatrix is the world matrix of the particle system
  15590. * @param directionToUpdate is the direction vector to update with the result
  15591. * @param particle is the particle we are computed the direction for
  15592. */
  15593. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15594. /**
  15595. * Clones the current emitter and returns a copy of it
  15596. * @returns the new emitter
  15597. */
  15598. clone(): CylinderDirectedParticleEmitter;
  15599. /**
  15600. * Called by the GPUParticleSystem to setup the update shader
  15601. * @param effect defines the update shader
  15602. */
  15603. applyToShader(effect: Effect): void;
  15604. /**
  15605. * Returns a string to use to update the GPU particles update shader
  15606. * @returns a string containng the defines string
  15607. */
  15608. getEffectDefines(): string;
  15609. /**
  15610. * Returns the string "CylinderDirectedParticleEmitter"
  15611. * @returns a string containing the class name
  15612. */
  15613. getClassName(): string;
  15614. /**
  15615. * Serializes the particle system to a JSON object.
  15616. * @returns the JSON object
  15617. */
  15618. serialize(): any;
  15619. /**
  15620. * Parse properties from a JSON object
  15621. * @param serializationObject defines the JSON object
  15622. */
  15623. parse(serializationObject: any): void;
  15624. }
  15625. }
  15626. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15627. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15628. import { Effect } from "babylonjs/Materials/effect";
  15629. import { Particle } from "babylonjs/Particles/particle";
  15630. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15631. /**
  15632. * Particle emitter emitting particles from the inside of a hemisphere.
  15633. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15634. */
  15635. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15636. /**
  15637. * The radius of the emission hemisphere.
  15638. */
  15639. radius: number;
  15640. /**
  15641. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15642. */
  15643. radiusRange: number;
  15644. /**
  15645. * How much to randomize the particle direction [0-1].
  15646. */
  15647. directionRandomizer: number;
  15648. /**
  15649. * Creates a new instance HemisphericParticleEmitter
  15650. * @param radius the radius of the emission hemisphere (1 by default)
  15651. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15652. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15653. */
  15654. constructor(
  15655. /**
  15656. * The radius of the emission hemisphere.
  15657. */
  15658. radius?: number,
  15659. /**
  15660. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15661. */
  15662. radiusRange?: number,
  15663. /**
  15664. * How much to randomize the particle direction [0-1].
  15665. */
  15666. directionRandomizer?: number);
  15667. /**
  15668. * Called by the particle System when the direction is computed for the created particle.
  15669. * @param worldMatrix is the world matrix of the particle system
  15670. * @param directionToUpdate is the direction vector to update with the result
  15671. * @param particle is the particle we are computed the direction for
  15672. */
  15673. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15674. /**
  15675. * Called by the particle System when the position is computed for the created particle.
  15676. * @param worldMatrix is the world matrix of the particle system
  15677. * @param positionToUpdate is the position vector to update with the result
  15678. * @param particle is the particle we are computed the position for
  15679. */
  15680. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15681. /**
  15682. * Clones the current emitter and returns a copy of it
  15683. * @returns the new emitter
  15684. */
  15685. clone(): HemisphericParticleEmitter;
  15686. /**
  15687. * Called by the GPUParticleSystem to setup the update shader
  15688. * @param effect defines the update shader
  15689. */
  15690. applyToShader(effect: Effect): void;
  15691. /**
  15692. * Returns a string to use to update the GPU particles update shader
  15693. * @returns a string containng the defines string
  15694. */
  15695. getEffectDefines(): string;
  15696. /**
  15697. * Returns the string "HemisphericParticleEmitter"
  15698. * @returns a string containing the class name
  15699. */
  15700. getClassName(): string;
  15701. /**
  15702. * Serializes the particle system to a JSON object.
  15703. * @returns the JSON object
  15704. */
  15705. serialize(): any;
  15706. /**
  15707. * Parse properties from a JSON object
  15708. * @param serializationObject defines the JSON object
  15709. */
  15710. parse(serializationObject: any): void;
  15711. }
  15712. }
  15713. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15714. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15715. import { Effect } from "babylonjs/Materials/effect";
  15716. import { Particle } from "babylonjs/Particles/particle";
  15717. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15718. /**
  15719. * Particle emitter emitting particles from a point.
  15720. * It emits the particles randomly between 2 given directions.
  15721. */
  15722. export class PointParticleEmitter implements IParticleEmitterType {
  15723. /**
  15724. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15725. */
  15726. direction1: Vector3;
  15727. /**
  15728. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15729. */
  15730. direction2: Vector3;
  15731. /**
  15732. * Creates a new instance PointParticleEmitter
  15733. */
  15734. constructor();
  15735. /**
  15736. * Called by the particle System when the direction is computed for the created particle.
  15737. * @param worldMatrix is the world matrix of the particle system
  15738. * @param directionToUpdate is the direction vector to update with the result
  15739. * @param particle is the particle we are computed the direction for
  15740. */
  15741. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15742. /**
  15743. * Called by the particle System when the position is computed for the created particle.
  15744. * @param worldMatrix is the world matrix of the particle system
  15745. * @param positionToUpdate is the position vector to update with the result
  15746. * @param particle is the particle we are computed the position for
  15747. */
  15748. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15749. /**
  15750. * Clones the current emitter and returns a copy of it
  15751. * @returns the new emitter
  15752. */
  15753. clone(): PointParticleEmitter;
  15754. /**
  15755. * Called by the GPUParticleSystem to setup the update shader
  15756. * @param effect defines the update shader
  15757. */
  15758. applyToShader(effect: Effect): void;
  15759. /**
  15760. * Returns a string to use to update the GPU particles update shader
  15761. * @returns a string containng the defines string
  15762. */
  15763. getEffectDefines(): string;
  15764. /**
  15765. * Returns the string "PointParticleEmitter"
  15766. * @returns a string containing the class name
  15767. */
  15768. getClassName(): string;
  15769. /**
  15770. * Serializes the particle system to a JSON object.
  15771. * @returns the JSON object
  15772. */
  15773. serialize(): any;
  15774. /**
  15775. * Parse properties from a JSON object
  15776. * @param serializationObject defines the JSON object
  15777. */
  15778. parse(serializationObject: any): void;
  15779. }
  15780. }
  15781. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15782. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15783. import { Effect } from "babylonjs/Materials/effect";
  15784. import { Particle } from "babylonjs/Particles/particle";
  15785. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15786. /**
  15787. * Particle emitter emitting particles from the inside of a sphere.
  15788. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15789. */
  15790. export class SphereParticleEmitter implements IParticleEmitterType {
  15791. /**
  15792. * The radius of the emission sphere.
  15793. */
  15794. radius: number;
  15795. /**
  15796. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15797. */
  15798. radiusRange: number;
  15799. /**
  15800. * How much to randomize the particle direction [0-1].
  15801. */
  15802. directionRandomizer: number;
  15803. /**
  15804. * Creates a new instance SphereParticleEmitter
  15805. * @param radius the radius of the emission sphere (1 by default)
  15806. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15807. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15808. */
  15809. constructor(
  15810. /**
  15811. * The radius of the emission sphere.
  15812. */
  15813. radius?: number,
  15814. /**
  15815. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15816. */
  15817. radiusRange?: number,
  15818. /**
  15819. * How much to randomize the particle direction [0-1].
  15820. */
  15821. directionRandomizer?: number);
  15822. /**
  15823. * Called by the particle System when the direction is computed for the created particle.
  15824. * @param worldMatrix is the world matrix of the particle system
  15825. * @param directionToUpdate is the direction vector to update with the result
  15826. * @param particle is the particle we are computed the direction for
  15827. */
  15828. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15829. /**
  15830. * Called by the particle System when the position is computed for the created particle.
  15831. * @param worldMatrix is the world matrix of the particle system
  15832. * @param positionToUpdate is the position vector to update with the result
  15833. * @param particle is the particle we are computed the position for
  15834. */
  15835. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15836. /**
  15837. * Clones the current emitter and returns a copy of it
  15838. * @returns the new emitter
  15839. */
  15840. clone(): SphereParticleEmitter;
  15841. /**
  15842. * Called by the GPUParticleSystem to setup the update shader
  15843. * @param effect defines the update shader
  15844. */
  15845. applyToShader(effect: Effect): void;
  15846. /**
  15847. * Returns a string to use to update the GPU particles update shader
  15848. * @returns a string containng the defines string
  15849. */
  15850. getEffectDefines(): string;
  15851. /**
  15852. * Returns the string "SphereParticleEmitter"
  15853. * @returns a string containing the class name
  15854. */
  15855. getClassName(): string;
  15856. /**
  15857. * Serializes the particle system to a JSON object.
  15858. * @returns the JSON object
  15859. */
  15860. serialize(): any;
  15861. /**
  15862. * Parse properties from a JSON object
  15863. * @param serializationObject defines the JSON object
  15864. */
  15865. parse(serializationObject: any): void;
  15866. }
  15867. /**
  15868. * Particle emitter emitting particles from the inside of a sphere.
  15869. * It emits the particles randomly between two vectors.
  15870. */
  15871. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15872. /**
  15873. * The min limit of the emission direction.
  15874. */
  15875. direction1: Vector3;
  15876. /**
  15877. * The max limit of the emission direction.
  15878. */
  15879. direction2: Vector3;
  15880. /**
  15881. * Creates a new instance SphereDirectedParticleEmitter
  15882. * @param radius the radius of the emission sphere (1 by default)
  15883. * @param direction1 the min limit of the emission direction (up vector by default)
  15884. * @param direction2 the max limit of the emission direction (up vector by default)
  15885. */
  15886. constructor(radius?: number,
  15887. /**
  15888. * The min limit of the emission direction.
  15889. */
  15890. direction1?: Vector3,
  15891. /**
  15892. * The max limit of the emission direction.
  15893. */
  15894. direction2?: Vector3);
  15895. /**
  15896. * Called by the particle System when the direction is computed for the created particle.
  15897. * @param worldMatrix is the world matrix of the particle system
  15898. * @param directionToUpdate is the direction vector to update with the result
  15899. * @param particle is the particle we are computed the direction for
  15900. */
  15901. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15902. /**
  15903. * Clones the current emitter and returns a copy of it
  15904. * @returns the new emitter
  15905. */
  15906. clone(): SphereDirectedParticleEmitter;
  15907. /**
  15908. * Called by the GPUParticleSystem to setup the update shader
  15909. * @param effect defines the update shader
  15910. */
  15911. applyToShader(effect: Effect): void;
  15912. /**
  15913. * Returns a string to use to update the GPU particles update shader
  15914. * @returns a string containng the defines string
  15915. */
  15916. getEffectDefines(): string;
  15917. /**
  15918. * Returns the string "SphereDirectedParticleEmitter"
  15919. * @returns a string containing the class name
  15920. */
  15921. getClassName(): string;
  15922. /**
  15923. * Serializes the particle system to a JSON object.
  15924. * @returns the JSON object
  15925. */
  15926. serialize(): any;
  15927. /**
  15928. * Parse properties from a JSON object
  15929. * @param serializationObject defines the JSON object
  15930. */
  15931. parse(serializationObject: any): void;
  15932. }
  15933. }
  15934. declare module "babylonjs/Particles/EmitterTypes/index" {
  15935. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  15936. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  15937. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  15938. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  15939. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15940. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  15941. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  15942. }
  15943. declare module "babylonjs/Particles/IParticleSystem" {
  15944. import { Nullable } from "babylonjs/types";
  15945. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  15946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15947. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15948. import { Texture } from "babylonjs/Materials/Textures/texture";
  15949. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15950. import { Scene } from "babylonjs/scene";
  15951. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15952. import { Animation } from "babylonjs/Animations/animation";
  15953. /**
  15954. * Interface representing a particle system in Babylon.js.
  15955. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15956. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15957. */
  15958. export interface IParticleSystem {
  15959. /**
  15960. * List of animations used by the particle system.
  15961. */
  15962. animations: Animation[];
  15963. /**
  15964. * The id of the Particle system.
  15965. */
  15966. id: string;
  15967. /**
  15968. * The name of the Particle system.
  15969. */
  15970. name: string;
  15971. /**
  15972. * The emitter represents the Mesh or position we are attaching the particle system to.
  15973. */
  15974. emitter: Nullable<AbstractMesh | Vector3>;
  15975. /**
  15976. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15977. */
  15978. isBillboardBased: boolean;
  15979. /**
  15980. * The rendering group used by the Particle system to chose when to render.
  15981. */
  15982. renderingGroupId: number;
  15983. /**
  15984. * The layer mask we are rendering the particles through.
  15985. */
  15986. layerMask: number;
  15987. /**
  15988. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15989. */
  15990. updateSpeed: number;
  15991. /**
  15992. * The amount of time the particle system is running (depends of the overall update speed).
  15993. */
  15994. targetStopDuration: number;
  15995. /**
  15996. * The texture used to render each particle. (this can be a spritesheet)
  15997. */
  15998. particleTexture: Nullable<Texture>;
  15999. /**
  16000. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16001. */
  16002. blendMode: number;
  16003. /**
  16004. * Minimum life time of emitting particles.
  16005. */
  16006. minLifeTime: number;
  16007. /**
  16008. * Maximum life time of emitting particles.
  16009. */
  16010. maxLifeTime: number;
  16011. /**
  16012. * Minimum Size of emitting particles.
  16013. */
  16014. minSize: number;
  16015. /**
  16016. * Maximum Size of emitting particles.
  16017. */
  16018. maxSize: number;
  16019. /**
  16020. * Minimum scale of emitting particles on X axis.
  16021. */
  16022. minScaleX: number;
  16023. /**
  16024. * Maximum scale of emitting particles on X axis.
  16025. */
  16026. maxScaleX: number;
  16027. /**
  16028. * Minimum scale of emitting particles on Y axis.
  16029. */
  16030. minScaleY: number;
  16031. /**
  16032. * Maximum scale of emitting particles on Y axis.
  16033. */
  16034. maxScaleY: number;
  16035. /**
  16036. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16037. */
  16038. color1: Color4;
  16039. /**
  16040. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16041. */
  16042. color2: Color4;
  16043. /**
  16044. * Color the particle will have at the end of its lifetime.
  16045. */
  16046. colorDead: Color4;
  16047. /**
  16048. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16049. */
  16050. emitRate: number;
  16051. /**
  16052. * You can use gravity if you want to give an orientation to your particles.
  16053. */
  16054. gravity: Vector3;
  16055. /**
  16056. * Minimum power of emitting particles.
  16057. */
  16058. minEmitPower: number;
  16059. /**
  16060. * Maximum power of emitting particles.
  16061. */
  16062. maxEmitPower: number;
  16063. /**
  16064. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16065. */
  16066. minAngularSpeed: number;
  16067. /**
  16068. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16069. */
  16070. maxAngularSpeed: number;
  16071. /**
  16072. * Gets or sets the minimal initial rotation in radians.
  16073. */
  16074. minInitialRotation: number;
  16075. /**
  16076. * Gets or sets the maximal initial rotation in radians.
  16077. */
  16078. maxInitialRotation: number;
  16079. /**
  16080. * The particle emitter type defines the emitter used by the particle system.
  16081. * It can be for example box, sphere, or cone...
  16082. */
  16083. particleEmitterType: Nullable<IParticleEmitterType>;
  16084. /**
  16085. * Defines the delay in milliseconds before starting the system (0 by default)
  16086. */
  16087. startDelay: number;
  16088. /**
  16089. * 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
  16090. */
  16091. preWarmCycles: number;
  16092. /**
  16093. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16094. */
  16095. preWarmStepOffset: number;
  16096. /**
  16097. * 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)
  16098. */
  16099. spriteCellChangeSpeed: number;
  16100. /**
  16101. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16102. */
  16103. startSpriteCellID: number;
  16104. /**
  16105. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16106. */
  16107. endSpriteCellID: number;
  16108. /**
  16109. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16110. */
  16111. spriteCellWidth: number;
  16112. /**
  16113. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16114. */
  16115. spriteCellHeight: number;
  16116. /**
  16117. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16118. */
  16119. spriteRandomStartCell: boolean;
  16120. /**
  16121. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16122. */
  16123. isAnimationSheetEnabled: boolean;
  16124. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16125. translationPivot: Vector2;
  16126. /**
  16127. * Gets or sets a texture used to add random noise to particle positions
  16128. */
  16129. noiseTexture: Nullable<BaseTexture>;
  16130. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16131. noiseStrength: Vector3;
  16132. /**
  16133. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16134. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16135. */
  16136. billboardMode: number;
  16137. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16138. limitVelocityDamping: number;
  16139. /**
  16140. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16141. */
  16142. beginAnimationOnStart: boolean;
  16143. /**
  16144. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16145. */
  16146. beginAnimationFrom: number;
  16147. /**
  16148. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16149. */
  16150. beginAnimationTo: number;
  16151. /**
  16152. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16153. */
  16154. beginAnimationLoop: boolean;
  16155. /**
  16156. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16157. */
  16158. disposeOnStop: boolean;
  16159. /**
  16160. * Gets the maximum number of particles active at the same time.
  16161. * @returns The max number of active particles.
  16162. */
  16163. getCapacity(): number;
  16164. /**
  16165. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16166. * @returns True if it has been started, otherwise false.
  16167. */
  16168. isStarted(): boolean;
  16169. /**
  16170. * Animates the particle system for this frame.
  16171. */
  16172. animate(): void;
  16173. /**
  16174. * Renders the particle system in its current state.
  16175. * @returns the current number of particles
  16176. */
  16177. render(): number;
  16178. /**
  16179. * Dispose the particle system and frees its associated resources.
  16180. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16181. */
  16182. dispose(disposeTexture?: boolean): void;
  16183. /**
  16184. * Clones the particle system.
  16185. * @param name The name of the cloned object
  16186. * @param newEmitter The new emitter to use
  16187. * @returns the cloned particle system
  16188. */
  16189. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16190. /**
  16191. * Serializes the particle system to a JSON object.
  16192. * @returns the JSON object
  16193. */
  16194. serialize(): any;
  16195. /**
  16196. * Rebuild the particle system
  16197. */
  16198. rebuild(): void;
  16199. /**
  16200. * Starts the particle system and begins to emit
  16201. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16202. */
  16203. start(delay?: number): void;
  16204. /**
  16205. * Stops the particle system.
  16206. */
  16207. stop(): void;
  16208. /**
  16209. * Remove all active particles
  16210. */
  16211. reset(): void;
  16212. /**
  16213. * Is this system ready to be used/rendered
  16214. * @return true if the system is ready
  16215. */
  16216. isReady(): boolean;
  16217. /**
  16218. * Adds a new color gradient
  16219. * @param gradient defines the gradient to use (between 0 and 1)
  16220. * @param color1 defines the color to affect to the specified gradient
  16221. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16222. * @returns the current particle system
  16223. */
  16224. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16225. /**
  16226. * Remove a specific color gradient
  16227. * @param gradient defines the gradient to remove
  16228. * @returns the current particle system
  16229. */
  16230. removeColorGradient(gradient: number): IParticleSystem;
  16231. /**
  16232. * Adds a new size gradient
  16233. * @param gradient defines the gradient to use (between 0 and 1)
  16234. * @param factor defines the size factor to affect to the specified gradient
  16235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16236. * @returns the current particle system
  16237. */
  16238. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16239. /**
  16240. * Remove a specific size gradient
  16241. * @param gradient defines the gradient to remove
  16242. * @returns the current particle system
  16243. */
  16244. removeSizeGradient(gradient: number): IParticleSystem;
  16245. /**
  16246. * Gets the current list of color gradients.
  16247. * You must use addColorGradient and removeColorGradient to udpate this list
  16248. * @returns the list of color gradients
  16249. */
  16250. getColorGradients(): Nullable<Array<ColorGradient>>;
  16251. /**
  16252. * Gets the current list of size gradients.
  16253. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16254. * @returns the list of size gradients
  16255. */
  16256. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16257. /**
  16258. * Gets the current list of angular speed gradients.
  16259. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16260. * @returns the list of angular speed gradients
  16261. */
  16262. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16263. /**
  16264. * Adds a new angular speed gradient
  16265. * @param gradient defines the gradient to use (between 0 and 1)
  16266. * @param factor defines the angular speed to affect to the specified gradient
  16267. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16268. * @returns the current particle system
  16269. */
  16270. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16271. /**
  16272. * Remove a specific angular speed gradient
  16273. * @param gradient defines the gradient to remove
  16274. * @returns the current particle system
  16275. */
  16276. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16277. /**
  16278. * Gets the current list of velocity gradients.
  16279. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16280. * @returns the list of velocity gradients
  16281. */
  16282. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16283. /**
  16284. * Adds a new velocity gradient
  16285. * @param gradient defines the gradient to use (between 0 and 1)
  16286. * @param factor defines the velocity to affect to the specified gradient
  16287. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16288. * @returns the current particle system
  16289. */
  16290. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16291. /**
  16292. * Remove a specific velocity gradient
  16293. * @param gradient defines the gradient to remove
  16294. * @returns the current particle system
  16295. */
  16296. removeVelocityGradient(gradient: number): IParticleSystem;
  16297. /**
  16298. * Gets the current list of limit velocity gradients.
  16299. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16300. * @returns the list of limit velocity gradients
  16301. */
  16302. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16303. /**
  16304. * Adds a new limit velocity gradient
  16305. * @param gradient defines the gradient to use (between 0 and 1)
  16306. * @param factor defines the limit velocity to affect to the specified gradient
  16307. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16308. * @returns the current particle system
  16309. */
  16310. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16311. /**
  16312. * Remove a specific limit velocity gradient
  16313. * @param gradient defines the gradient to remove
  16314. * @returns the current particle system
  16315. */
  16316. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16317. /**
  16318. * Adds a new drag gradient
  16319. * @param gradient defines the gradient to use (between 0 and 1)
  16320. * @param factor defines the drag to affect to the specified gradient
  16321. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16322. * @returns the current particle system
  16323. */
  16324. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16325. /**
  16326. * Remove a specific drag gradient
  16327. * @param gradient defines the gradient to remove
  16328. * @returns the current particle system
  16329. */
  16330. removeDragGradient(gradient: number): IParticleSystem;
  16331. /**
  16332. * Gets the current list of drag gradients.
  16333. * You must use addDragGradient and removeDragGradient to udpate this list
  16334. * @returns the list of drag gradients
  16335. */
  16336. getDragGradients(): Nullable<Array<FactorGradient>>;
  16337. /**
  16338. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16339. * @param gradient defines the gradient to use (between 0 and 1)
  16340. * @param factor defines the emit rate to affect to the specified gradient
  16341. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16342. * @returns the current particle system
  16343. */
  16344. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16345. /**
  16346. * Remove a specific emit rate gradient
  16347. * @param gradient defines the gradient to remove
  16348. * @returns the current particle system
  16349. */
  16350. removeEmitRateGradient(gradient: number): IParticleSystem;
  16351. /**
  16352. * Gets the current list of emit rate gradients.
  16353. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16354. * @returns the list of emit rate gradients
  16355. */
  16356. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16357. /**
  16358. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16359. * @param gradient defines the gradient to use (between 0 and 1)
  16360. * @param factor defines the start size to affect to the specified gradient
  16361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16362. * @returns the current particle system
  16363. */
  16364. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16365. /**
  16366. * Remove a specific start size gradient
  16367. * @param gradient defines the gradient to remove
  16368. * @returns the current particle system
  16369. */
  16370. removeStartSizeGradient(gradient: number): IParticleSystem;
  16371. /**
  16372. * Gets the current list of start size gradients.
  16373. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16374. * @returns the list of start size gradients
  16375. */
  16376. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16377. /**
  16378. * Adds a new life time gradient
  16379. * @param gradient defines the gradient to use (between 0 and 1)
  16380. * @param factor defines the life time factor to affect to the specified gradient
  16381. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16382. * @returns the current particle system
  16383. */
  16384. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16385. /**
  16386. * Remove a specific life time gradient
  16387. * @param gradient defines the gradient to remove
  16388. * @returns the current particle system
  16389. */
  16390. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16391. /**
  16392. * Gets the current list of life time gradients.
  16393. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16394. * @returns the list of life time gradients
  16395. */
  16396. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16397. /**
  16398. * Gets the current list of color gradients.
  16399. * You must use addColorGradient and removeColorGradient to udpate this list
  16400. * @returns the list of color gradients
  16401. */
  16402. getColorGradients(): Nullable<Array<ColorGradient>>;
  16403. /**
  16404. * Adds a new ramp gradient used to remap particle colors
  16405. * @param gradient defines the gradient to use (between 0 and 1)
  16406. * @param color defines the color to affect to the specified gradient
  16407. * @returns the current particle system
  16408. */
  16409. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16410. /**
  16411. * Gets the current list of ramp gradients.
  16412. * You must use addRampGradient and removeRampGradient to udpate this list
  16413. * @returns the list of ramp gradients
  16414. */
  16415. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16416. /** Gets or sets a boolean indicating that ramp gradients must be used
  16417. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16418. */
  16419. useRampGradients: boolean;
  16420. /**
  16421. * Adds a new color remap gradient
  16422. * @param gradient defines the gradient to use (between 0 and 1)
  16423. * @param min defines the color remap minimal range
  16424. * @param max defines the color remap maximal range
  16425. * @returns the current particle system
  16426. */
  16427. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16428. /**
  16429. * Gets the current list of color remap gradients.
  16430. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16431. * @returns the list of color remap gradients
  16432. */
  16433. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16434. /**
  16435. * Adds a new alpha remap gradient
  16436. * @param gradient defines the gradient to use (between 0 and 1)
  16437. * @param min defines the alpha remap minimal range
  16438. * @param max defines the alpha remap maximal range
  16439. * @returns the current particle system
  16440. */
  16441. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16442. /**
  16443. * Gets the current list of alpha remap gradients.
  16444. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16445. * @returns the list of alpha remap gradients
  16446. */
  16447. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16448. /**
  16449. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16450. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16451. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16452. * @returns the emitter
  16453. */
  16454. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16455. /**
  16456. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16457. * @param radius The radius of the hemisphere to emit from
  16458. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16459. * @returns the emitter
  16460. */
  16461. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16462. /**
  16463. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16464. * @param radius The radius of the sphere to emit from
  16465. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16466. * @returns the emitter
  16467. */
  16468. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16469. /**
  16470. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16471. * @param radius The radius of the sphere to emit from
  16472. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16473. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16474. * @returns the emitter
  16475. */
  16476. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16477. /**
  16478. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16479. * @param radius The radius of the emission cylinder
  16480. * @param height The height of the emission cylinder
  16481. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16482. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16483. * @returns the emitter
  16484. */
  16485. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16486. /**
  16487. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16488. * @param radius The radius of the cylinder to emit from
  16489. * @param height The height of the emission cylinder
  16490. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16491. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16492. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16493. * @returns the emitter
  16494. */
  16495. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16496. /**
  16497. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16498. * @param radius The radius of the cone to emit from
  16499. * @param angle The base angle of the cone
  16500. * @returns the emitter
  16501. */
  16502. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16503. /**
  16504. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16505. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16506. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16507. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16508. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16509. * @returns the emitter
  16510. */
  16511. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16512. /**
  16513. * Get hosting scene
  16514. * @returns the scene
  16515. */
  16516. getScene(): Scene;
  16517. }
  16518. }
  16519. declare module "babylonjs/Meshes/instancedMesh" {
  16520. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16521. import { Vector3 } from "babylonjs/Maths/math";
  16522. import { Camera } from "babylonjs/Cameras/camera";
  16523. import { Node } from "babylonjs/node";
  16524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16525. import { Mesh } from "babylonjs/Meshes/mesh";
  16526. import { Material } from "babylonjs/Materials/material";
  16527. import { Skeleton } from "babylonjs/Bones/skeleton";
  16528. /**
  16529. * Creates an instance based on a source mesh.
  16530. */
  16531. export class InstancedMesh extends AbstractMesh {
  16532. private _sourceMesh;
  16533. private _currentLOD;
  16534. /** @hidden */
  16535. _indexInSourceMeshInstanceArray: number;
  16536. constructor(name: string, source: Mesh);
  16537. /**
  16538. * Returns the string "InstancedMesh".
  16539. */
  16540. getClassName(): string;
  16541. /**
  16542. * If the source mesh receives shadows
  16543. */
  16544. readonly receiveShadows: boolean;
  16545. /**
  16546. * The material of the source mesh
  16547. */
  16548. readonly material: Nullable<Material>;
  16549. /**
  16550. * Visibility of the source mesh
  16551. */
  16552. readonly visibility: number;
  16553. /**
  16554. * Skeleton of the source mesh
  16555. */
  16556. readonly skeleton: Nullable<Skeleton>;
  16557. /**
  16558. * Rendering ground id of the source mesh
  16559. */
  16560. renderingGroupId: number;
  16561. /**
  16562. * Returns the total number of vertices (integer).
  16563. */
  16564. getTotalVertices(): number;
  16565. /**
  16566. * Returns a positive integer : the total number of indices in this mesh geometry.
  16567. * @returns the numner of indices or zero if the mesh has no geometry.
  16568. */
  16569. getTotalIndices(): number;
  16570. /**
  16571. * The source mesh of the instance
  16572. */
  16573. readonly sourceMesh: Mesh;
  16574. /**
  16575. * Is this node ready to be used/rendered
  16576. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16577. * @return {boolean} is it ready
  16578. */
  16579. isReady(completeCheck?: boolean): boolean;
  16580. /**
  16581. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16582. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16583. * @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.
  16584. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16585. */
  16586. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16587. /**
  16588. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16589. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16590. * The `data` are either a numeric array either a Float32Array.
  16591. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16592. * 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).
  16593. * Note that a new underlying VertexBuffer object is created each call.
  16594. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16595. *
  16596. * Possible `kind` values :
  16597. * - VertexBuffer.PositionKind
  16598. * - VertexBuffer.UVKind
  16599. * - VertexBuffer.UV2Kind
  16600. * - VertexBuffer.UV3Kind
  16601. * - VertexBuffer.UV4Kind
  16602. * - VertexBuffer.UV5Kind
  16603. * - VertexBuffer.UV6Kind
  16604. * - VertexBuffer.ColorKind
  16605. * - VertexBuffer.MatricesIndicesKind
  16606. * - VertexBuffer.MatricesIndicesExtraKind
  16607. * - VertexBuffer.MatricesWeightsKind
  16608. * - VertexBuffer.MatricesWeightsExtraKind
  16609. *
  16610. * Returns the Mesh.
  16611. */
  16612. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16613. /**
  16614. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16615. * If the mesh has no geometry, it is simply returned as it is.
  16616. * The `data` are either a numeric array either a Float32Array.
  16617. * No new underlying VertexBuffer object is created.
  16618. * 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.
  16619. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16620. *
  16621. * Possible `kind` values :
  16622. * - VertexBuffer.PositionKind
  16623. * - VertexBuffer.UVKind
  16624. * - VertexBuffer.UV2Kind
  16625. * - VertexBuffer.UV3Kind
  16626. * - VertexBuffer.UV4Kind
  16627. * - VertexBuffer.UV5Kind
  16628. * - VertexBuffer.UV6Kind
  16629. * - VertexBuffer.ColorKind
  16630. * - VertexBuffer.MatricesIndicesKind
  16631. * - VertexBuffer.MatricesIndicesExtraKind
  16632. * - VertexBuffer.MatricesWeightsKind
  16633. * - VertexBuffer.MatricesWeightsExtraKind
  16634. *
  16635. * Returns the Mesh.
  16636. */
  16637. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16638. /**
  16639. * Sets the mesh indices.
  16640. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16641. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16642. * This method creates a new index buffer each call.
  16643. * Returns the Mesh.
  16644. */
  16645. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16646. /**
  16647. * Boolean : True if the mesh owns the requested kind of data.
  16648. */
  16649. isVerticesDataPresent(kind: string): boolean;
  16650. /**
  16651. * Returns an array of indices (IndicesArray).
  16652. */
  16653. getIndices(): Nullable<IndicesArray>;
  16654. readonly _positions: Nullable<Vector3[]>;
  16655. /**
  16656. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16657. * This means the mesh underlying bounding box and sphere are recomputed.
  16658. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16659. * @returns the current mesh
  16660. */
  16661. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16662. /** @hidden */
  16663. _preActivate(): InstancedMesh;
  16664. /** @hidden */
  16665. _activate(renderId: number): InstancedMesh;
  16666. /**
  16667. * Returns the current associated LOD AbstractMesh.
  16668. */
  16669. getLOD(camera: Camera): AbstractMesh;
  16670. /** @hidden */
  16671. _syncSubMeshes(): InstancedMesh;
  16672. /** @hidden */
  16673. _generatePointsArray(): boolean;
  16674. /**
  16675. * Creates a new InstancedMesh from the current mesh.
  16676. * - name (string) : the cloned mesh name
  16677. * - newParent (optional Node) : the optional Node to parent the clone to.
  16678. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16679. *
  16680. * Returns the clone.
  16681. */
  16682. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16683. /**
  16684. * Disposes the InstancedMesh.
  16685. * Returns nothing.
  16686. */
  16687. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16688. }
  16689. }
  16690. declare module "babylonjs/Materials/shaderMaterial" {
  16691. import { Scene } from "babylonjs/scene";
  16692. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16694. import { Mesh } from "babylonjs/Meshes/mesh";
  16695. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16696. import { Texture } from "babylonjs/Materials/Textures/texture";
  16697. import { Material } from "babylonjs/Materials/material";
  16698. /**
  16699. * Defines the options associated with the creation of a shader material.
  16700. */
  16701. export interface IShaderMaterialOptions {
  16702. /**
  16703. * Does the material work in alpha blend mode
  16704. */
  16705. needAlphaBlending: boolean;
  16706. /**
  16707. * Does the material work in alpha test mode
  16708. */
  16709. needAlphaTesting: boolean;
  16710. /**
  16711. * The list of attribute names used in the shader
  16712. */
  16713. attributes: string[];
  16714. /**
  16715. * The list of unifrom names used in the shader
  16716. */
  16717. uniforms: string[];
  16718. /**
  16719. * The list of UBO names used in the shader
  16720. */
  16721. uniformBuffers: string[];
  16722. /**
  16723. * The list of sampler names used in the shader
  16724. */
  16725. samplers: string[];
  16726. /**
  16727. * The list of defines used in the shader
  16728. */
  16729. defines: string[];
  16730. }
  16731. /**
  16732. * 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.
  16733. *
  16734. * This returned material effects how the mesh will look based on the code in the shaders.
  16735. *
  16736. * @see http://doc.babylonjs.com/how_to/shader_material
  16737. */
  16738. export class ShaderMaterial extends Material {
  16739. private _shaderPath;
  16740. private _options;
  16741. private _textures;
  16742. private _textureArrays;
  16743. private _floats;
  16744. private _ints;
  16745. private _floatsArrays;
  16746. private _colors3;
  16747. private _colors3Arrays;
  16748. private _colors4;
  16749. private _vectors2;
  16750. private _vectors3;
  16751. private _vectors4;
  16752. private _matrices;
  16753. private _matrices3x3;
  16754. private _matrices2x2;
  16755. private _vectors2Arrays;
  16756. private _vectors3Arrays;
  16757. private _cachedWorldViewMatrix;
  16758. private _renderId;
  16759. /**
  16760. * Instantiate a new shader material.
  16761. * 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.
  16762. * This returned material effects how the mesh will look based on the code in the shaders.
  16763. * @see http://doc.babylonjs.com/how_to/shader_material
  16764. * @param name Define the name of the material in the scene
  16765. * @param scene Define the scene the material belongs to
  16766. * @param shaderPath Defines the route to the shader code in one of three ways:
  16767. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16768. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16769. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16770. * @param options Define the options used to create the shader
  16771. */
  16772. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16773. /**
  16774. * Gets the current class name of the material e.g. "ShaderMaterial"
  16775. * Mainly use in serialization.
  16776. * @returns the class name
  16777. */
  16778. getClassName(): string;
  16779. /**
  16780. * Specifies if the material will require alpha blending
  16781. * @returns a boolean specifying if alpha blending is needed
  16782. */
  16783. needAlphaBlending(): boolean;
  16784. /**
  16785. * Specifies if this material should be rendered in alpha test mode
  16786. * @returns a boolean specifying if an alpha test is needed.
  16787. */
  16788. needAlphaTesting(): boolean;
  16789. private _checkUniform;
  16790. /**
  16791. * Set a texture in the shader.
  16792. * @param name Define the name of the uniform samplers as defined in the shader
  16793. * @param texture Define the texture to bind to this sampler
  16794. * @return the material itself allowing "fluent" like uniform updates
  16795. */
  16796. setTexture(name: string, texture: Texture): ShaderMaterial;
  16797. /**
  16798. * Set a texture array in the shader.
  16799. * @param name Define the name of the uniform sampler array as defined in the shader
  16800. * @param textures Define the list of textures to bind to this sampler
  16801. * @return the material itself allowing "fluent" like uniform updates
  16802. */
  16803. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16804. /**
  16805. * Set a float in the shader.
  16806. * @param name Define the name of the uniform as defined in the shader
  16807. * @param value Define the value to give to the uniform
  16808. * @return the material itself allowing "fluent" like uniform updates
  16809. */
  16810. setFloat(name: string, value: number): ShaderMaterial;
  16811. /**
  16812. * Set a int in the shader.
  16813. * @param name Define the name of the uniform as defined in the shader
  16814. * @param value Define the value to give to the uniform
  16815. * @return the material itself allowing "fluent" like uniform updates
  16816. */
  16817. setInt(name: string, value: number): ShaderMaterial;
  16818. /**
  16819. * Set an array of floats in the shader.
  16820. * @param name Define the name of the uniform as defined in the shader
  16821. * @param value Define the value to give to the uniform
  16822. * @return the material itself allowing "fluent" like uniform updates
  16823. */
  16824. setFloats(name: string, value: number[]): ShaderMaterial;
  16825. /**
  16826. * Set a vec3 in the shader from a Color3.
  16827. * @param name Define the name of the uniform as defined in the shader
  16828. * @param value Define the value to give to the uniform
  16829. * @return the material itself allowing "fluent" like uniform updates
  16830. */
  16831. setColor3(name: string, value: Color3): ShaderMaterial;
  16832. /**
  16833. * Set a vec3 array in the shader from a Color3 array.
  16834. * @param name Define the name of the uniform as defined in the shader
  16835. * @param value Define the value to give to the uniform
  16836. * @return the material itself allowing "fluent" like uniform updates
  16837. */
  16838. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16839. /**
  16840. * Set a vec4 in the shader from a Color4.
  16841. * @param name Define the name of the uniform as defined in the shader
  16842. * @param value Define the value to give to the uniform
  16843. * @return the material itself allowing "fluent" like uniform updates
  16844. */
  16845. setColor4(name: string, value: Color4): ShaderMaterial;
  16846. /**
  16847. * Set a vec2 in the shader from a Vector2.
  16848. * @param name Define the name of the uniform as defined in the shader
  16849. * @param value Define the value to give to the uniform
  16850. * @return the material itself allowing "fluent" like uniform updates
  16851. */
  16852. setVector2(name: string, value: Vector2): ShaderMaterial;
  16853. /**
  16854. * Set a vec3 in the shader from a Vector3.
  16855. * @param name Define the name of the uniform as defined in the shader
  16856. * @param value Define the value to give to the uniform
  16857. * @return the material itself allowing "fluent" like uniform updates
  16858. */
  16859. setVector3(name: string, value: Vector3): ShaderMaterial;
  16860. /**
  16861. * Set a vec4 in the shader from a Vector4.
  16862. * @param name Define the name of the uniform as defined in the shader
  16863. * @param value Define the value to give to the uniform
  16864. * @return the material itself allowing "fluent" like uniform updates
  16865. */
  16866. setVector4(name: string, value: Vector4): ShaderMaterial;
  16867. /**
  16868. * Set a mat4 in the shader from a Matrix.
  16869. * @param name Define the name of the uniform as defined in the shader
  16870. * @param value Define the value to give to the uniform
  16871. * @return the material itself allowing "fluent" like uniform updates
  16872. */
  16873. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16874. /**
  16875. * Set a mat3 in the shader from a Float32Array.
  16876. * @param name Define the name of the uniform as defined in the shader
  16877. * @param value Define the value to give to the uniform
  16878. * @return the material itself allowing "fluent" like uniform updates
  16879. */
  16880. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16881. /**
  16882. * Set a mat2 in the shader from a Float32Array.
  16883. * @param name Define the name of the uniform as defined in the shader
  16884. * @param value Define the value to give to the uniform
  16885. * @return the material itself allowing "fluent" like uniform updates
  16886. */
  16887. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16888. /**
  16889. * Set a vec2 array in the shader from a number array.
  16890. * @param name Define the name of the uniform as defined in the shader
  16891. * @param value Define the value to give to the uniform
  16892. * @return the material itself allowing "fluent" like uniform updates
  16893. */
  16894. setArray2(name: string, value: number[]): ShaderMaterial;
  16895. /**
  16896. * Set a vec3 array in the shader from a number array.
  16897. * @param name Define the name of the uniform as defined in the shader
  16898. * @param value Define the value to give to the uniform
  16899. * @return the material itself allowing "fluent" like uniform updates
  16900. */
  16901. setArray3(name: string, value: number[]): ShaderMaterial;
  16902. private _checkCache;
  16903. /**
  16904. * Checks if the material is ready to render the requested mesh
  16905. * @param mesh Define the mesh to render
  16906. * @param useInstances Define whether or not the material is used with instances
  16907. * @returns true if ready, otherwise false
  16908. */
  16909. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16910. /**
  16911. * Binds the world matrix to the material
  16912. * @param world defines the world transformation matrix
  16913. */
  16914. bindOnlyWorldMatrix(world: Matrix): void;
  16915. /**
  16916. * Binds the material to the mesh
  16917. * @param world defines the world transformation matrix
  16918. * @param mesh defines the mesh to bind the material to
  16919. */
  16920. bind(world: Matrix, mesh?: Mesh): void;
  16921. /**
  16922. * Gets the active textures from the material
  16923. * @returns an array of textures
  16924. */
  16925. getActiveTextures(): BaseTexture[];
  16926. /**
  16927. * Specifies if the material uses a texture
  16928. * @param texture defines the texture to check against the material
  16929. * @returns a boolean specifying if the material uses the texture
  16930. */
  16931. hasTexture(texture: BaseTexture): boolean;
  16932. /**
  16933. * Makes a duplicate of the material, and gives it a new name
  16934. * @param name defines the new name for the duplicated material
  16935. * @returns the cloned material
  16936. */
  16937. clone(name: string): ShaderMaterial;
  16938. /**
  16939. * Disposes the material
  16940. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16941. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16942. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16943. */
  16944. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16945. /**
  16946. * Serializes this material in a JSON representation
  16947. * @returns the serialized material object
  16948. */
  16949. serialize(): any;
  16950. /**
  16951. * Creates a shader material from parsed shader material data
  16952. * @param source defines the JSON represnetation of the material
  16953. * @param scene defines the hosting scene
  16954. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16955. * @returns a new material
  16956. */
  16957. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16958. }
  16959. }
  16960. declare module "babylonjs/Shaders/color.fragment" {
  16961. /** @hidden */
  16962. export var colorPixelShader: {
  16963. name: string;
  16964. shader: string;
  16965. };
  16966. }
  16967. declare module "babylonjs/Shaders/color.vertex" {
  16968. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16969. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16970. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16971. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16972. /** @hidden */
  16973. export var colorVertexShader: {
  16974. name: string;
  16975. shader: string;
  16976. };
  16977. }
  16978. declare module "babylonjs/Meshes/linesMesh" {
  16979. import { Nullable } from "babylonjs/types";
  16980. import { Scene } from "babylonjs/scene";
  16981. import { Color3 } from "babylonjs/Maths/math";
  16982. import { Node } from "babylonjs/node";
  16983. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16984. import { Mesh } from "babylonjs/Meshes/mesh";
  16985. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16986. import { Effect } from "babylonjs/Materials/effect";
  16987. import { Material } from "babylonjs/Materials/material";
  16988. import "babylonjs/Shaders/color.fragment";
  16989. import "babylonjs/Shaders/color.vertex";
  16990. /**
  16991. * Line mesh
  16992. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16993. */
  16994. export class LinesMesh extends Mesh {
  16995. /**
  16996. * If vertex color should be applied to the mesh
  16997. */
  16998. useVertexColor?: boolean | undefined;
  16999. /**
  17000. * If vertex alpha should be applied to the mesh
  17001. */
  17002. useVertexAlpha?: boolean | undefined;
  17003. /**
  17004. * Color of the line (Default: White)
  17005. */
  17006. color: Color3;
  17007. /**
  17008. * Alpha of the line (Default: 1)
  17009. */
  17010. alpha: number;
  17011. /**
  17012. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17013. * This margin is expressed in world space coordinates, so its value may vary.
  17014. * Default value is 0.1
  17015. */
  17016. intersectionThreshold: number;
  17017. private _colorShader;
  17018. /**
  17019. * Creates a new LinesMesh
  17020. * @param name defines the name
  17021. * @param scene defines the hosting scene
  17022. * @param parent defines the parent mesh if any
  17023. * @param source defines the optional source LinesMesh used to clone data from
  17024. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17025. * When false, achieved by calling a clone(), also passing False.
  17026. * This will make creation of children, recursive.
  17027. * @param useVertexColor defines if this LinesMesh supports vertex color
  17028. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17029. */
  17030. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17031. /**
  17032. * If vertex color should be applied to the mesh
  17033. */
  17034. useVertexColor?: boolean | undefined,
  17035. /**
  17036. * If vertex alpha should be applied to the mesh
  17037. */
  17038. useVertexAlpha?: boolean | undefined);
  17039. /**
  17040. * Returns the string "LineMesh"
  17041. */
  17042. getClassName(): string;
  17043. /**
  17044. * @hidden
  17045. */
  17046. /**
  17047. * @hidden
  17048. */
  17049. material: Material;
  17050. /**
  17051. * @hidden
  17052. */
  17053. readonly checkCollisions: boolean;
  17054. /** @hidden */
  17055. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17056. /** @hidden */
  17057. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17058. /**
  17059. * Disposes of the line mesh
  17060. * @param doNotRecurse If children should be disposed
  17061. */
  17062. dispose(doNotRecurse?: boolean): void;
  17063. /**
  17064. * Returns a new LineMesh object cloned from the current one.
  17065. */
  17066. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17067. /**
  17068. * Creates a new InstancedLinesMesh object from the mesh model.
  17069. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17070. * @param name defines the name of the new instance
  17071. * @returns a new InstancedLinesMesh
  17072. */
  17073. createInstance(name: string): InstancedLinesMesh;
  17074. }
  17075. /**
  17076. * Creates an instance based on a source LinesMesh
  17077. */
  17078. export class InstancedLinesMesh extends InstancedMesh {
  17079. /**
  17080. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17081. * This margin is expressed in world space coordinates, so its value may vary.
  17082. * Initilized with the intersectionThreshold value of the source LinesMesh
  17083. */
  17084. intersectionThreshold: number;
  17085. constructor(name: string, source: LinesMesh);
  17086. /**
  17087. * Returns the string "InstancedLinesMesh".
  17088. */
  17089. getClassName(): string;
  17090. }
  17091. }
  17092. declare module "babylonjs/Shaders/line.fragment" {
  17093. /** @hidden */
  17094. export var linePixelShader: {
  17095. name: string;
  17096. shader: string;
  17097. };
  17098. }
  17099. declare module "babylonjs/Shaders/line.vertex" {
  17100. /** @hidden */
  17101. export var lineVertexShader: {
  17102. name: string;
  17103. shader: string;
  17104. };
  17105. }
  17106. declare module "babylonjs/Rendering/edgesRenderer" {
  17107. import { Nullable } from "babylonjs/types";
  17108. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17110. import { Vector3 } from "babylonjs/Maths/math";
  17111. import { IDisposable } from "babylonjs/scene";
  17112. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17113. import "babylonjs/Shaders/line.fragment";
  17114. import "babylonjs/Shaders/line.vertex";
  17115. module "babylonjs/Meshes/abstractMesh" {
  17116. interface AbstractMesh {
  17117. /**
  17118. * Disables the mesh edge rendering mode
  17119. * @returns the currentAbstractMesh
  17120. */
  17121. disableEdgesRendering(): AbstractMesh;
  17122. /**
  17123. * Enables the edge rendering mode on the mesh.
  17124. * This mode makes the mesh edges visible
  17125. * @param epsilon defines the maximal distance between two angles to detect a face
  17126. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17127. * @returns the currentAbstractMesh
  17128. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17129. */
  17130. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17131. /**
  17132. * Gets the edgesRenderer associated with the mesh
  17133. */
  17134. edgesRenderer: Nullable<EdgesRenderer>;
  17135. }
  17136. }
  17137. module "babylonjs/Meshes/linesMesh" {
  17138. interface LinesMesh {
  17139. /**
  17140. * Enables the edge rendering mode on the mesh.
  17141. * This mode makes the mesh edges visible
  17142. * @param epsilon defines the maximal distance between two angles to detect a face
  17143. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17144. * @returns the currentAbstractMesh
  17145. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17146. */
  17147. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17148. }
  17149. }
  17150. module "babylonjs/Meshes/linesMesh" {
  17151. interface InstancedLinesMesh {
  17152. /**
  17153. * Enables the edge rendering mode on the mesh.
  17154. * This mode makes the mesh edges visible
  17155. * @param epsilon defines the maximal distance between two angles to detect a face
  17156. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17157. * @returns the current InstancedLinesMesh
  17158. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17159. */
  17160. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17161. }
  17162. }
  17163. /**
  17164. * Defines the minimum contract an Edges renderer should follow.
  17165. */
  17166. export interface IEdgesRenderer extends IDisposable {
  17167. /**
  17168. * Gets or sets a boolean indicating if the edgesRenderer is active
  17169. */
  17170. isEnabled: boolean;
  17171. /**
  17172. * Renders the edges of the attached mesh,
  17173. */
  17174. render(): void;
  17175. /**
  17176. * Checks wether or not the edges renderer is ready to render.
  17177. * @return true if ready, otherwise false.
  17178. */
  17179. isReady(): boolean;
  17180. }
  17181. /**
  17182. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17183. */
  17184. export class EdgesRenderer implements IEdgesRenderer {
  17185. /**
  17186. * Define the size of the edges with an orthographic camera
  17187. */
  17188. edgesWidthScalerForOrthographic: number;
  17189. /**
  17190. * Define the size of the edges with a perspective camera
  17191. */
  17192. edgesWidthScalerForPerspective: number;
  17193. protected _source: AbstractMesh;
  17194. protected _linesPositions: number[];
  17195. protected _linesNormals: number[];
  17196. protected _linesIndices: number[];
  17197. protected _epsilon: number;
  17198. protected _indicesCount: number;
  17199. protected _lineShader: ShaderMaterial;
  17200. protected _ib: WebGLBuffer;
  17201. protected _buffers: {
  17202. [key: string]: Nullable<VertexBuffer>;
  17203. };
  17204. protected _checkVerticesInsteadOfIndices: boolean;
  17205. private _meshRebuildObserver;
  17206. private _meshDisposeObserver;
  17207. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17208. isEnabled: boolean;
  17209. /**
  17210. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17211. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17212. * @param source Mesh used to create edges
  17213. * @param epsilon sum of angles in adjacency to check for edge
  17214. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17215. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17216. */
  17217. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17218. protected _prepareRessources(): void;
  17219. /** @hidden */
  17220. _rebuild(): void;
  17221. /**
  17222. * Releases the required resources for the edges renderer
  17223. */
  17224. dispose(): void;
  17225. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17226. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17227. /**
  17228. * Checks if the pair of p0 and p1 is en edge
  17229. * @param faceIndex
  17230. * @param edge
  17231. * @param faceNormals
  17232. * @param p0
  17233. * @param p1
  17234. * @private
  17235. */
  17236. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17237. /**
  17238. * push line into the position, normal and index buffer
  17239. * @protected
  17240. */
  17241. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17242. /**
  17243. * Generates lines edges from adjacencjes
  17244. * @private
  17245. */
  17246. _generateEdgesLines(): void;
  17247. /**
  17248. * Checks wether or not the edges renderer is ready to render.
  17249. * @return true if ready, otherwise false.
  17250. */
  17251. isReady(): boolean;
  17252. /**
  17253. * Renders the edges of the attached mesh,
  17254. */
  17255. render(): void;
  17256. }
  17257. /**
  17258. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17259. */
  17260. export class LineEdgesRenderer extends EdgesRenderer {
  17261. /**
  17262. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17263. * @param source LineMesh used to generate edges
  17264. * @param epsilon not important (specified angle for edge detection)
  17265. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17266. */
  17267. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17268. /**
  17269. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17270. */
  17271. _generateEdgesLines(): void;
  17272. }
  17273. }
  17274. declare module "babylonjs/Rendering/renderingGroup" {
  17275. import { SmartArray } from "babylonjs/Misc/smartArray";
  17276. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17278. import { Nullable } from "babylonjs/types";
  17279. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17280. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17281. import { Material } from "babylonjs/Materials/material";
  17282. import { Scene } from "babylonjs/scene";
  17283. /**
  17284. * This represents the object necessary to create a rendering group.
  17285. * This is exclusively used and created by the rendering manager.
  17286. * To modify the behavior, you use the available helpers in your scene or meshes.
  17287. * @hidden
  17288. */
  17289. export class RenderingGroup {
  17290. index: number;
  17291. private _scene;
  17292. private _opaqueSubMeshes;
  17293. private _transparentSubMeshes;
  17294. private _alphaTestSubMeshes;
  17295. private _depthOnlySubMeshes;
  17296. private _particleSystems;
  17297. private _spriteManagers;
  17298. private _opaqueSortCompareFn;
  17299. private _alphaTestSortCompareFn;
  17300. private _transparentSortCompareFn;
  17301. private _renderOpaque;
  17302. private _renderAlphaTest;
  17303. private _renderTransparent;
  17304. private _edgesRenderers;
  17305. onBeforeTransparentRendering: () => void;
  17306. /**
  17307. * Set the opaque sort comparison function.
  17308. * If null the sub meshes will be render in the order they were created
  17309. */
  17310. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17311. /**
  17312. * Set the alpha test sort comparison function.
  17313. * If null the sub meshes will be render in the order they were created
  17314. */
  17315. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17316. /**
  17317. * Set the transparent sort comparison function.
  17318. * If null the sub meshes will be render in the order they were created
  17319. */
  17320. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17321. /**
  17322. * Creates a new rendering group.
  17323. * @param index The rendering group index
  17324. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17325. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17326. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17327. */
  17328. 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>);
  17329. /**
  17330. * Render all the sub meshes contained in the group.
  17331. * @param customRenderFunction Used to override the default render behaviour of the group.
  17332. * @returns true if rendered some submeshes.
  17333. */
  17334. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17335. /**
  17336. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17337. * @param subMeshes The submeshes to render
  17338. */
  17339. private renderOpaqueSorted;
  17340. /**
  17341. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17342. * @param subMeshes The submeshes to render
  17343. */
  17344. private renderAlphaTestSorted;
  17345. /**
  17346. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17347. * @param subMeshes The submeshes to render
  17348. */
  17349. private renderTransparentSorted;
  17350. /**
  17351. * Renders the submeshes in a specified order.
  17352. * @param subMeshes The submeshes to sort before render
  17353. * @param sortCompareFn The comparison function use to sort
  17354. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17355. * @param transparent Specifies to activate blending if true
  17356. */
  17357. private static renderSorted;
  17358. /**
  17359. * Renders the submeshes in the order they were dispatched (no sort applied).
  17360. * @param subMeshes The submeshes to render
  17361. */
  17362. private static renderUnsorted;
  17363. /**
  17364. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17365. * are rendered back to front if in the same alpha index.
  17366. *
  17367. * @param a The first submesh
  17368. * @param b The second submesh
  17369. * @returns The result of the comparison
  17370. */
  17371. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17372. /**
  17373. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17374. * are rendered back to front.
  17375. *
  17376. * @param a The first submesh
  17377. * @param b The second submesh
  17378. * @returns The result of the comparison
  17379. */
  17380. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17381. /**
  17382. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17383. * are rendered front to back (prevent overdraw).
  17384. *
  17385. * @param a The first submesh
  17386. * @param b The second submesh
  17387. * @returns The result of the comparison
  17388. */
  17389. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17390. /**
  17391. * Resets the different lists of submeshes to prepare a new frame.
  17392. */
  17393. prepare(): void;
  17394. dispose(): void;
  17395. /**
  17396. * Inserts the submesh in its correct queue depending on its material.
  17397. * @param subMesh The submesh to dispatch
  17398. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17399. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17400. */
  17401. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17402. dispatchSprites(spriteManager: ISpriteManager): void;
  17403. dispatchParticles(particleSystem: IParticleSystem): void;
  17404. private _renderParticles;
  17405. private _renderSprites;
  17406. }
  17407. }
  17408. declare module "babylonjs/Rendering/renderingManager" {
  17409. import { Nullable } from "babylonjs/types";
  17410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17411. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17412. import { SmartArray } from "babylonjs/Misc/smartArray";
  17413. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17414. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17415. import { Material } from "babylonjs/Materials/material";
  17416. import { Scene } from "babylonjs/scene";
  17417. import { Camera } from "babylonjs/Cameras/camera";
  17418. /**
  17419. * Interface describing the different options available in the rendering manager
  17420. * regarding Auto Clear between groups.
  17421. */
  17422. export interface IRenderingManagerAutoClearSetup {
  17423. /**
  17424. * Defines whether or not autoclear is enable.
  17425. */
  17426. autoClear: boolean;
  17427. /**
  17428. * Defines whether or not to autoclear the depth buffer.
  17429. */
  17430. depth: boolean;
  17431. /**
  17432. * Defines whether or not to autoclear the stencil buffer.
  17433. */
  17434. stencil: boolean;
  17435. }
  17436. /**
  17437. * This class is used by the onRenderingGroupObservable
  17438. */
  17439. export class RenderingGroupInfo {
  17440. /**
  17441. * The Scene that being rendered
  17442. */
  17443. scene: Scene;
  17444. /**
  17445. * The camera currently used for the rendering pass
  17446. */
  17447. camera: Nullable<Camera>;
  17448. /**
  17449. * The ID of the renderingGroup being processed
  17450. */
  17451. renderingGroupId: number;
  17452. }
  17453. /**
  17454. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17455. * It is enable to manage the different groups as well as the different necessary sort functions.
  17456. * This should not be used directly aside of the few static configurations
  17457. */
  17458. export class RenderingManager {
  17459. /**
  17460. * The max id used for rendering groups (not included)
  17461. */
  17462. static MAX_RENDERINGGROUPS: number;
  17463. /**
  17464. * The min id used for rendering groups (included)
  17465. */
  17466. static MIN_RENDERINGGROUPS: number;
  17467. /**
  17468. * Used to globally prevent autoclearing scenes.
  17469. */
  17470. static AUTOCLEAR: boolean;
  17471. /**
  17472. * @hidden
  17473. */
  17474. _useSceneAutoClearSetup: boolean;
  17475. private _scene;
  17476. private _renderingGroups;
  17477. private _depthStencilBufferAlreadyCleaned;
  17478. private _autoClearDepthStencil;
  17479. private _customOpaqueSortCompareFn;
  17480. private _customAlphaTestSortCompareFn;
  17481. private _customTransparentSortCompareFn;
  17482. private _renderingGroupInfo;
  17483. /**
  17484. * Instantiates a new rendering group for a particular scene
  17485. * @param scene Defines the scene the groups belongs to
  17486. */
  17487. constructor(scene: Scene);
  17488. private _clearDepthStencilBuffer;
  17489. /**
  17490. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17491. * @hidden
  17492. */
  17493. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17494. /**
  17495. * Resets the different information of the group to prepare a new frame
  17496. * @hidden
  17497. */
  17498. reset(): void;
  17499. /**
  17500. * Dispose and release the group and its associated resources.
  17501. * @hidden
  17502. */
  17503. dispose(): void;
  17504. /**
  17505. * Clear the info related to rendering groups preventing retention points during dispose.
  17506. */
  17507. freeRenderingGroups(): void;
  17508. private _prepareRenderingGroup;
  17509. /**
  17510. * Add a sprite manager to the rendering manager in order to render it this frame.
  17511. * @param spriteManager Define the sprite manager to render
  17512. */
  17513. dispatchSprites(spriteManager: ISpriteManager): void;
  17514. /**
  17515. * Add a particle system to the rendering manager in order to render it this frame.
  17516. * @param particleSystem Define the particle system to render
  17517. */
  17518. dispatchParticles(particleSystem: IParticleSystem): void;
  17519. /**
  17520. * Add a submesh to the manager in order to render it this frame
  17521. * @param subMesh The submesh to dispatch
  17522. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17523. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17524. */
  17525. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17526. /**
  17527. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17528. * This allowed control for front to back rendering or reversly depending of the special needs.
  17529. *
  17530. * @param renderingGroupId The rendering group id corresponding to its index
  17531. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17532. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17533. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17534. */
  17535. 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;
  17536. /**
  17537. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17538. *
  17539. * @param renderingGroupId The rendering group id corresponding to its index
  17540. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17541. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17542. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17543. */
  17544. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17545. /**
  17546. * Gets the current auto clear configuration for one rendering group of the rendering
  17547. * manager.
  17548. * @param index the rendering group index to get the information for
  17549. * @returns The auto clear setup for the requested rendering group
  17550. */
  17551. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17552. }
  17553. }
  17554. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17555. import { Observable } from "babylonjs/Misc/observable";
  17556. import { SmartArray } from "babylonjs/Misc/smartArray";
  17557. import { Nullable } from "babylonjs/types";
  17558. import { Camera } from "babylonjs/Cameras/camera";
  17559. import { Scene } from "babylonjs/scene";
  17560. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17561. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17563. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17564. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17565. import { Texture } from "babylonjs/Materials/Textures/texture";
  17566. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17567. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17568. import { Engine } from "babylonjs/Engines/engine";
  17569. /**
  17570. * This Helps creating a texture that will be created from a camera in your scene.
  17571. * It is basically a dynamic texture that could be used to create special effects for instance.
  17572. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17573. */
  17574. export class RenderTargetTexture extends Texture {
  17575. isCube: boolean;
  17576. /**
  17577. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17578. */
  17579. static readonly REFRESHRATE_RENDER_ONCE: number;
  17580. /**
  17581. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17582. */
  17583. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17584. /**
  17585. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17586. * the central point of your effect and can save a lot of performances.
  17587. */
  17588. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17589. /**
  17590. * Use this predicate to dynamically define the list of mesh you want to render.
  17591. * If set, the renderList property will be overwritten.
  17592. */
  17593. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17594. private _renderList;
  17595. /**
  17596. * Use this list to define the list of mesh you want to render.
  17597. */
  17598. renderList: Nullable<Array<AbstractMesh>>;
  17599. private _hookArray;
  17600. /**
  17601. * Define if particles should be rendered in your texture.
  17602. */
  17603. renderParticles: boolean;
  17604. /**
  17605. * Define if sprites should be rendered in your texture.
  17606. */
  17607. renderSprites: boolean;
  17608. /**
  17609. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17610. */
  17611. coordinatesMode: number;
  17612. /**
  17613. * Define the camera used to render the texture.
  17614. */
  17615. activeCamera: Nullable<Camera>;
  17616. /**
  17617. * Override the render function of the texture with your own one.
  17618. */
  17619. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17620. /**
  17621. * Define if camera post processes should be use while rendering the texture.
  17622. */
  17623. useCameraPostProcesses: boolean;
  17624. /**
  17625. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17626. */
  17627. ignoreCameraViewport: boolean;
  17628. private _postProcessManager;
  17629. private _postProcesses;
  17630. private _resizeObserver;
  17631. /**
  17632. * An event triggered when the texture is unbind.
  17633. */
  17634. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17635. /**
  17636. * An event triggered when the texture is unbind.
  17637. */
  17638. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17639. private _onAfterUnbindObserver;
  17640. /**
  17641. * Set a after unbind callback in the texture.
  17642. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17643. */
  17644. onAfterUnbind: () => void;
  17645. /**
  17646. * An event triggered before rendering the texture
  17647. */
  17648. onBeforeRenderObservable: Observable<number>;
  17649. private _onBeforeRenderObserver;
  17650. /**
  17651. * Set a before render callback in the texture.
  17652. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17653. */
  17654. onBeforeRender: (faceIndex: number) => void;
  17655. /**
  17656. * An event triggered after rendering the texture
  17657. */
  17658. onAfterRenderObservable: Observable<number>;
  17659. private _onAfterRenderObserver;
  17660. /**
  17661. * Set a after render callback in the texture.
  17662. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17663. */
  17664. onAfterRender: (faceIndex: number) => void;
  17665. /**
  17666. * An event triggered after the texture clear
  17667. */
  17668. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17669. private _onClearObserver;
  17670. /**
  17671. * Set a clear callback in the texture.
  17672. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17673. */
  17674. onClear: (Engine: Engine) => void;
  17675. /**
  17676. * Define the clear color of the Render Target if it should be different from the scene.
  17677. */
  17678. clearColor: Color4;
  17679. protected _size: number | {
  17680. width: number;
  17681. height: number;
  17682. };
  17683. protected _initialSizeParameter: number | {
  17684. width: number;
  17685. height: number;
  17686. } | {
  17687. ratio: number;
  17688. };
  17689. protected _sizeRatio: Nullable<number>;
  17690. /** @hidden */
  17691. _generateMipMaps: boolean;
  17692. protected _renderingManager: RenderingManager;
  17693. /** @hidden */
  17694. _waitingRenderList: string[];
  17695. protected _doNotChangeAspectRatio: boolean;
  17696. protected _currentRefreshId: number;
  17697. protected _refreshRate: number;
  17698. protected _textureMatrix: Matrix;
  17699. protected _samples: number;
  17700. protected _renderTargetOptions: RenderTargetCreationOptions;
  17701. /**
  17702. * Gets render target creation options that were used.
  17703. */
  17704. readonly renderTargetOptions: RenderTargetCreationOptions;
  17705. protected _engine: Engine;
  17706. protected _onRatioRescale(): void;
  17707. /**
  17708. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17709. * It must define where the camera used to render the texture is set
  17710. */
  17711. boundingBoxPosition: Vector3;
  17712. private _boundingBoxSize;
  17713. /**
  17714. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17715. * When defined, the cubemap will switch to local mode
  17716. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17717. * @example https://www.babylonjs-playground.com/#RNASML
  17718. */
  17719. boundingBoxSize: Vector3;
  17720. /**
  17721. * In case the RTT has been created with a depth texture, get the associated
  17722. * depth texture.
  17723. * Otherwise, return null.
  17724. */
  17725. depthStencilTexture: Nullable<InternalTexture>;
  17726. /**
  17727. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17728. * or used a shadow, depth texture...
  17729. * @param name The friendly name of the texture
  17730. * @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)
  17731. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17732. * @param generateMipMaps True if mip maps need to be generated after render.
  17733. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17734. * @param type The type of the buffer in the RTT (int, half float, float...)
  17735. * @param isCube True if a cube texture needs to be created
  17736. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17737. * @param generateDepthBuffer True to generate a depth buffer
  17738. * @param generateStencilBuffer True to generate a stencil buffer
  17739. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17740. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17741. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17742. */
  17743. constructor(name: string, size: number | {
  17744. width: number;
  17745. height: number;
  17746. } | {
  17747. ratio: number;
  17748. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17749. /**
  17750. * Creates a depth stencil texture.
  17751. * This is only available in WebGL 2 or with the depth texture extension available.
  17752. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17753. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17754. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17755. */
  17756. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17757. private _processSizeParameter;
  17758. /**
  17759. * Define the number of samples to use in case of MSAA.
  17760. * It defaults to one meaning no MSAA has been enabled.
  17761. */
  17762. samples: number;
  17763. /**
  17764. * Resets the refresh counter of the texture and start bak from scratch.
  17765. * Could be useful to regenerate the texture if it is setup to render only once.
  17766. */
  17767. resetRefreshCounter(): void;
  17768. /**
  17769. * Define the refresh rate of the texture or the rendering frequency.
  17770. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17771. */
  17772. refreshRate: number;
  17773. /**
  17774. * Adds a post process to the render target rendering passes.
  17775. * @param postProcess define the post process to add
  17776. */
  17777. addPostProcess(postProcess: PostProcess): void;
  17778. /**
  17779. * Clear all the post processes attached to the render target
  17780. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17781. */
  17782. clearPostProcesses(dispose?: boolean): void;
  17783. /**
  17784. * Remove one of the post process from the list of attached post processes to the texture
  17785. * @param postProcess define the post process to remove from the list
  17786. */
  17787. removePostProcess(postProcess: PostProcess): void;
  17788. /** @hidden */
  17789. _shouldRender(): boolean;
  17790. /**
  17791. * Gets the actual render size of the texture.
  17792. * @returns the width of the render size
  17793. */
  17794. getRenderSize(): number;
  17795. /**
  17796. * Gets the actual render width of the texture.
  17797. * @returns the width of the render size
  17798. */
  17799. getRenderWidth(): number;
  17800. /**
  17801. * Gets the actual render height of the texture.
  17802. * @returns the height of the render size
  17803. */
  17804. getRenderHeight(): number;
  17805. /**
  17806. * Get if the texture can be rescaled or not.
  17807. */
  17808. readonly canRescale: boolean;
  17809. /**
  17810. * Resize the texture using a ratio.
  17811. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17812. */
  17813. scale(ratio: number): void;
  17814. /**
  17815. * Get the texture reflection matrix used to rotate/transform the reflection.
  17816. * @returns the reflection matrix
  17817. */
  17818. getReflectionTextureMatrix(): Matrix;
  17819. /**
  17820. * Resize the texture to a new desired size.
  17821. * Be carrefull as it will recreate all the data in the new texture.
  17822. * @param size Define the new size. It can be:
  17823. * - a number for squared texture,
  17824. * - an object containing { width: number, height: number }
  17825. * - or an object containing a ratio { ratio: number }
  17826. */
  17827. resize(size: number | {
  17828. width: number;
  17829. height: number;
  17830. } | {
  17831. ratio: number;
  17832. }): void;
  17833. /**
  17834. * Renders all the objects from the render list into the texture.
  17835. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17836. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17837. */
  17838. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17839. private _bestReflectionRenderTargetDimension;
  17840. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17841. private renderToTarget;
  17842. /**
  17843. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17844. * This allowed control for front to back rendering or reversly depending of the special needs.
  17845. *
  17846. * @param renderingGroupId The rendering group id corresponding to its index
  17847. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17848. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17849. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17850. */
  17851. 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;
  17852. /**
  17853. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17854. *
  17855. * @param renderingGroupId The rendering group id corresponding to its index
  17856. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17857. */
  17858. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17859. /**
  17860. * Clones the texture.
  17861. * @returns the cloned texture
  17862. */
  17863. clone(): RenderTargetTexture;
  17864. /**
  17865. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17866. * @returns The JSON representation of the texture
  17867. */
  17868. serialize(): any;
  17869. /**
  17870. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17871. */
  17872. disposeFramebufferObjects(): void;
  17873. /**
  17874. * Dispose the texture and release its associated resources.
  17875. */
  17876. dispose(): void;
  17877. /** @hidden */
  17878. _rebuild(): void;
  17879. /**
  17880. * Clear the info related to rendering groups preventing retention point in material dispose.
  17881. */
  17882. freeRenderingGroups(): void;
  17883. }
  17884. }
  17885. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  17886. import { Scene } from "babylonjs/scene";
  17887. import { Plane } from "babylonjs/Maths/math";
  17888. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17889. /**
  17890. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17891. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17892. * You can then easily use it as a reflectionTexture on a flat surface.
  17893. * In case the surface is not a plane, please consider relying on reflection probes.
  17894. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17895. */
  17896. export class MirrorTexture extends RenderTargetTexture {
  17897. private scene;
  17898. /**
  17899. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17900. * 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.
  17901. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17902. */
  17903. mirrorPlane: Plane;
  17904. /**
  17905. * Define the blur ratio used to blur the reflection if needed.
  17906. */
  17907. blurRatio: number;
  17908. /**
  17909. * Define the adaptive blur kernel used to blur the reflection if needed.
  17910. * This will autocompute the closest best match for the `blurKernel`
  17911. */
  17912. adaptiveBlurKernel: number;
  17913. /**
  17914. * Define the blur kernel used to blur the reflection if needed.
  17915. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17916. */
  17917. blurKernel: number;
  17918. /**
  17919. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17920. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17921. */
  17922. blurKernelX: number;
  17923. /**
  17924. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17925. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17926. */
  17927. blurKernelY: number;
  17928. private _autoComputeBlurKernel;
  17929. protected _onRatioRescale(): void;
  17930. private _updateGammaSpace;
  17931. private _imageProcessingConfigChangeObserver;
  17932. private _transformMatrix;
  17933. private _mirrorMatrix;
  17934. private _savedViewMatrix;
  17935. private _blurX;
  17936. private _blurY;
  17937. private _adaptiveBlurKernel;
  17938. private _blurKernelX;
  17939. private _blurKernelY;
  17940. private _blurRatio;
  17941. /**
  17942. * Instantiates a Mirror Texture.
  17943. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17944. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17945. * You can then easily use it as a reflectionTexture on a flat surface.
  17946. * In case the surface is not a plane, please consider relying on reflection probes.
  17947. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17948. * @param name
  17949. * @param size
  17950. * @param scene
  17951. * @param generateMipMaps
  17952. * @param type
  17953. * @param samplingMode
  17954. * @param generateDepthBuffer
  17955. */
  17956. constructor(name: string, size: number | {
  17957. width: number;
  17958. height: number;
  17959. } | {
  17960. ratio: number;
  17961. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17962. private _preparePostProcesses;
  17963. /**
  17964. * Clone the mirror texture.
  17965. * @returns the cloned texture
  17966. */
  17967. clone(): MirrorTexture;
  17968. /**
  17969. * Serialize the texture to a JSON representation you could use in Parse later on
  17970. * @returns the serialized JSON representation
  17971. */
  17972. serialize(): any;
  17973. /**
  17974. * Dispose the texture and release its associated resources.
  17975. */
  17976. dispose(): void;
  17977. }
  17978. }
  17979. declare module "babylonjs/Materials/Textures/texture" {
  17980. import { Observable } from "babylonjs/Misc/observable";
  17981. import { Nullable } from "babylonjs/types";
  17982. import { Scene } from "babylonjs/scene";
  17983. import { Matrix } from "babylonjs/Maths/math";
  17984. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17985. /**
  17986. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17987. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17988. */
  17989. export class Texture extends BaseTexture {
  17990. /** @hidden */
  17991. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  17992. /** @hidden */
  17993. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  17994. /** @hidden */
  17995. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  17996. /** nearest is mag = nearest and min = nearest and mip = linear */
  17997. static readonly NEAREST_SAMPLINGMODE: number;
  17998. /** nearest is mag = nearest and min = nearest and mip = linear */
  17999. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18000. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18001. static readonly BILINEAR_SAMPLINGMODE: number;
  18002. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18003. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18004. /** Trilinear is mag = linear and min = linear and mip = linear */
  18005. static readonly TRILINEAR_SAMPLINGMODE: number;
  18006. /** Trilinear is mag = linear and min = linear and mip = linear */
  18007. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18008. /** mag = nearest and min = nearest and mip = nearest */
  18009. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18010. /** mag = nearest and min = linear and mip = nearest */
  18011. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18012. /** mag = nearest and min = linear and mip = linear */
  18013. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18014. /** mag = nearest and min = linear and mip = none */
  18015. static readonly NEAREST_LINEAR: number;
  18016. /** mag = nearest and min = nearest and mip = none */
  18017. static readonly NEAREST_NEAREST: number;
  18018. /** mag = linear and min = nearest and mip = nearest */
  18019. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18020. /** mag = linear and min = nearest and mip = linear */
  18021. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18022. /** mag = linear and min = linear and mip = none */
  18023. static readonly LINEAR_LINEAR: number;
  18024. /** mag = linear and min = nearest and mip = none */
  18025. static readonly LINEAR_NEAREST: number;
  18026. /** Explicit coordinates mode */
  18027. static readonly EXPLICIT_MODE: number;
  18028. /** Spherical coordinates mode */
  18029. static readonly SPHERICAL_MODE: number;
  18030. /** Planar coordinates mode */
  18031. static readonly PLANAR_MODE: number;
  18032. /** Cubic coordinates mode */
  18033. static readonly CUBIC_MODE: number;
  18034. /** Projection coordinates mode */
  18035. static readonly PROJECTION_MODE: number;
  18036. /** Inverse Cubic coordinates mode */
  18037. static readonly SKYBOX_MODE: number;
  18038. /** Inverse Cubic coordinates mode */
  18039. static readonly INVCUBIC_MODE: number;
  18040. /** Equirectangular coordinates mode */
  18041. static readonly EQUIRECTANGULAR_MODE: number;
  18042. /** Equirectangular Fixed coordinates mode */
  18043. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18044. /** Equirectangular Fixed Mirrored coordinates mode */
  18045. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18046. /** Texture is not repeating outside of 0..1 UVs */
  18047. static readonly CLAMP_ADDRESSMODE: number;
  18048. /** Texture is repeating outside of 0..1 UVs */
  18049. static readonly WRAP_ADDRESSMODE: number;
  18050. /** Texture is repeating and mirrored */
  18051. static readonly MIRROR_ADDRESSMODE: number;
  18052. /**
  18053. * 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
  18054. */
  18055. static UseSerializedUrlIfAny: boolean;
  18056. /**
  18057. * Define the url of the texture.
  18058. */
  18059. url: Nullable<string>;
  18060. /**
  18061. * Define an offset on the texture to offset the u coordinates of the UVs
  18062. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18063. */
  18064. uOffset: number;
  18065. /**
  18066. * Define an offset on the texture to offset the v coordinates of the UVs
  18067. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18068. */
  18069. vOffset: number;
  18070. /**
  18071. * Define an offset on the texture to scale the u coordinates of the UVs
  18072. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18073. */
  18074. uScale: number;
  18075. /**
  18076. * Define an offset on the texture to scale the v coordinates of the UVs
  18077. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18078. */
  18079. vScale: number;
  18080. /**
  18081. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18082. * @see http://doc.babylonjs.com/how_to/more_materials
  18083. */
  18084. uAng: number;
  18085. /**
  18086. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18087. * @see http://doc.babylonjs.com/how_to/more_materials
  18088. */
  18089. vAng: number;
  18090. /**
  18091. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18092. * @see http://doc.babylonjs.com/how_to/more_materials
  18093. */
  18094. wAng: number;
  18095. /**
  18096. * Defines the center of rotation (U)
  18097. */
  18098. uRotationCenter: number;
  18099. /**
  18100. * Defines the center of rotation (V)
  18101. */
  18102. vRotationCenter: number;
  18103. /**
  18104. * Defines the center of rotation (W)
  18105. */
  18106. wRotationCenter: number;
  18107. /**
  18108. * Are mip maps generated for this texture or not.
  18109. */
  18110. readonly noMipmap: boolean;
  18111. private _noMipmap;
  18112. /** @hidden */
  18113. _invertY: boolean;
  18114. private _rowGenerationMatrix;
  18115. private _cachedTextureMatrix;
  18116. private _projectionModeMatrix;
  18117. private _t0;
  18118. private _t1;
  18119. private _t2;
  18120. private _cachedUOffset;
  18121. private _cachedVOffset;
  18122. private _cachedUScale;
  18123. private _cachedVScale;
  18124. private _cachedUAng;
  18125. private _cachedVAng;
  18126. private _cachedWAng;
  18127. private _cachedProjectionMatrixId;
  18128. private _cachedCoordinatesMode;
  18129. /** @hidden */
  18130. protected _initialSamplingMode: number;
  18131. /** @hidden */
  18132. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18133. private _deleteBuffer;
  18134. protected _format: Nullable<number>;
  18135. private _delayedOnLoad;
  18136. private _delayedOnError;
  18137. /**
  18138. * Observable triggered once the texture has been loaded.
  18139. */
  18140. onLoadObservable: Observable<Texture>;
  18141. protected _isBlocking: boolean;
  18142. /**
  18143. * Is the texture preventing material to render while loading.
  18144. * If false, a default texture will be used instead of the loading one during the preparation step.
  18145. */
  18146. isBlocking: boolean;
  18147. /**
  18148. * Get the current sampling mode associated with the texture.
  18149. */
  18150. readonly samplingMode: number;
  18151. /**
  18152. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18153. */
  18154. readonly invertY: boolean;
  18155. /**
  18156. * Instantiates a new texture.
  18157. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18158. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18159. * @param url define the url of the picture to load as a texture
  18160. * @param scene define the scene the texture will belong to
  18161. * @param noMipmap define if the texture will require mip maps or not
  18162. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18163. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18164. * @param onLoad define a callback triggered when the texture has been loaded
  18165. * @param onError define a callback triggered when an error occurred during the loading session
  18166. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18167. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18168. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18169. */
  18170. 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);
  18171. /**
  18172. * Update the url (and optional buffer) of this texture if url was null during construction.
  18173. * @param url the url of the texture
  18174. * @param buffer the buffer of the texture (defaults to null)
  18175. * @param onLoad callback called when the texture is loaded (defaults to null)
  18176. */
  18177. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18178. /**
  18179. * Finish the loading sequence of a texture flagged as delayed load.
  18180. * @hidden
  18181. */
  18182. delayLoad(): void;
  18183. private _prepareRowForTextureGeneration;
  18184. /**
  18185. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18186. * @returns the transform matrix of the texture.
  18187. */
  18188. getTextureMatrix(): Matrix;
  18189. /**
  18190. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18191. * @returns The reflection texture transform
  18192. */
  18193. getReflectionTextureMatrix(): Matrix;
  18194. /**
  18195. * Clones the texture.
  18196. * @returns the cloned texture
  18197. */
  18198. clone(): Texture;
  18199. /**
  18200. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18201. * @returns The JSON representation of the texture
  18202. */
  18203. serialize(): any;
  18204. /**
  18205. * Get the current class name of the texture useful for serialization or dynamic coding.
  18206. * @returns "Texture"
  18207. */
  18208. getClassName(): string;
  18209. /**
  18210. * Dispose the texture and release its associated resources.
  18211. */
  18212. dispose(): void;
  18213. /**
  18214. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18215. * @param parsedTexture Define the JSON representation of the texture
  18216. * @param scene Define the scene the parsed texture should be instantiated in
  18217. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18218. * @returns The parsed texture if successful
  18219. */
  18220. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18221. /**
  18222. * Creates a texture from its base 64 representation.
  18223. * @param data Define the base64 payload without the data: prefix
  18224. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18225. * @param scene Define the scene the texture should belong to
  18226. * @param noMipmap Forces the texture to not create mip map information if true
  18227. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18228. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18229. * @param onLoad define a callback triggered when the texture has been loaded
  18230. * @param onError define a callback triggered when an error occurred during the loading session
  18231. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18232. * @returns the created texture
  18233. */
  18234. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18235. /**
  18236. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18237. * @param data Define the base64 payload without the data: prefix
  18238. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18239. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18240. * @param scene Define the scene the texture should belong to
  18241. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18242. * @param noMipmap Forces the texture to not create mip map information if true
  18243. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18244. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18245. * @param onLoad define a callback triggered when the texture has been loaded
  18246. * @param onError define a callback triggered when an error occurred during the loading session
  18247. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18248. * @returns the created texture
  18249. */
  18250. 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;
  18251. }
  18252. }
  18253. declare module "babylonjs/Materials/Textures/rawTexture" {
  18254. import { Scene } from "babylonjs/scene";
  18255. import { Texture } from "babylonjs/Materials/Textures/texture";
  18256. /**
  18257. * Raw texture can help creating a texture directly from an array of data.
  18258. * This can be super useful if you either get the data from an uncompressed source or
  18259. * if you wish to create your texture pixel by pixel.
  18260. */
  18261. export class RawTexture extends Texture {
  18262. /**
  18263. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18264. */
  18265. format: number;
  18266. private _engine;
  18267. /**
  18268. * Instantiates a new RawTexture.
  18269. * Raw texture can help creating a texture directly from an array of data.
  18270. * This can be super useful if you either get the data from an uncompressed source or
  18271. * if you wish to create your texture pixel by pixel.
  18272. * @param data define the array of data to use to create the texture
  18273. * @param width define the width of the texture
  18274. * @param height define the height of the texture
  18275. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18276. * @param scene define the scene the texture belongs to
  18277. * @param generateMipMaps define whether mip maps should be generated or not
  18278. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18279. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18280. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18281. */
  18282. constructor(data: ArrayBufferView, width: number, height: number,
  18283. /**
  18284. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18285. */
  18286. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18287. /**
  18288. * Updates the texture underlying data.
  18289. * @param data Define the new data of the texture
  18290. */
  18291. update(data: ArrayBufferView): void;
  18292. /**
  18293. * Creates a luminance texture from some data.
  18294. * @param data Define the texture data
  18295. * @param width Define the width of the texture
  18296. * @param height Define the height of the texture
  18297. * @param scene Define the scene the texture belongs to
  18298. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18299. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18300. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18301. * @returns the luminance texture
  18302. */
  18303. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18304. /**
  18305. * Creates a luminance alpha texture from some data.
  18306. * @param data Define the texture data
  18307. * @param width Define the width of the texture
  18308. * @param height Define the height of the texture
  18309. * @param scene Define the scene the texture belongs to
  18310. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18311. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18312. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18313. * @returns the luminance alpha texture
  18314. */
  18315. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18316. /**
  18317. * Creates an alpha texture from some data.
  18318. * @param data Define the texture data
  18319. * @param width Define the width of the texture
  18320. * @param height Define the height of the texture
  18321. * @param scene Define the scene the texture belongs to
  18322. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18323. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18324. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18325. * @returns the alpha texture
  18326. */
  18327. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18328. /**
  18329. * Creates a RGB texture from some data.
  18330. * @param data Define the texture data
  18331. * @param width Define the width of the texture
  18332. * @param height Define the height of the texture
  18333. * @param scene Define the scene the texture belongs to
  18334. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18335. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18336. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18337. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18338. * @returns the RGB alpha texture
  18339. */
  18340. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18341. /**
  18342. * Creates a RGBA texture from some data.
  18343. * @param data Define the texture data
  18344. * @param width Define the width of the texture
  18345. * @param height Define the height of the texture
  18346. * @param scene Define the scene the texture belongs to
  18347. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18348. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18349. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18350. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18351. * @returns the RGBA texture
  18352. */
  18353. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18354. /**
  18355. * Creates a R texture from some data.
  18356. * @param data Define the texture data
  18357. * @param width Define the width of the texture
  18358. * @param height Define the height of the texture
  18359. * @param scene Define the scene the texture belongs to
  18360. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18361. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18362. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18363. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18364. * @returns the R texture
  18365. */
  18366. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18367. }
  18368. }
  18369. declare module "babylonjs/Animations/runtimeAnimation" {
  18370. import { Animation } from "babylonjs/Animations/animation";
  18371. import { Animatable } from "babylonjs/Animations/animatable";
  18372. import { Scene } from "babylonjs/scene";
  18373. /**
  18374. * Defines a runtime animation
  18375. */
  18376. export class RuntimeAnimation {
  18377. private _events;
  18378. /**
  18379. * The current frame of the runtime animation
  18380. */
  18381. private _currentFrame;
  18382. /**
  18383. * The animation used by the runtime animation
  18384. */
  18385. private _animation;
  18386. /**
  18387. * The target of the runtime animation
  18388. */
  18389. private _target;
  18390. /**
  18391. * The initiating animatable
  18392. */
  18393. private _host;
  18394. /**
  18395. * The original value of the runtime animation
  18396. */
  18397. private _originalValue;
  18398. /**
  18399. * The original blend value of the runtime animation
  18400. */
  18401. private _originalBlendValue;
  18402. /**
  18403. * The offsets cache of the runtime animation
  18404. */
  18405. private _offsetsCache;
  18406. /**
  18407. * The high limits cache of the runtime animation
  18408. */
  18409. private _highLimitsCache;
  18410. /**
  18411. * Specifies if the runtime animation has been stopped
  18412. */
  18413. private _stopped;
  18414. /**
  18415. * The blending factor of the runtime animation
  18416. */
  18417. private _blendingFactor;
  18418. /**
  18419. * The BabylonJS scene
  18420. */
  18421. private _scene;
  18422. /**
  18423. * The current value of the runtime animation
  18424. */
  18425. private _currentValue;
  18426. /** @hidden */
  18427. _workValue: any;
  18428. /**
  18429. * The active target of the runtime animation
  18430. */
  18431. private _activeTarget;
  18432. /**
  18433. * The target path of the runtime animation
  18434. */
  18435. private _targetPath;
  18436. /**
  18437. * The weight of the runtime animation
  18438. */
  18439. private _weight;
  18440. /**
  18441. * The ratio offset of the runtime animation
  18442. */
  18443. private _ratioOffset;
  18444. /**
  18445. * The previous delay of the runtime animation
  18446. */
  18447. private _previousDelay;
  18448. /**
  18449. * The previous ratio of the runtime animation
  18450. */
  18451. private _previousRatio;
  18452. /**
  18453. * Gets the current frame of the runtime animation
  18454. */
  18455. readonly currentFrame: number;
  18456. /**
  18457. * Gets the weight of the runtime animation
  18458. */
  18459. readonly weight: number;
  18460. /**
  18461. * Gets the current value of the runtime animation
  18462. */
  18463. readonly currentValue: any;
  18464. /**
  18465. * Gets the target path of the runtime animation
  18466. */
  18467. readonly targetPath: string;
  18468. /**
  18469. * Gets the actual target of the runtime animation
  18470. */
  18471. readonly target: any;
  18472. /**
  18473. * Create a new RuntimeAnimation object
  18474. * @param target defines the target of the animation
  18475. * @param animation defines the source animation object
  18476. * @param scene defines the hosting scene
  18477. * @param host defines the initiating Animatable
  18478. */
  18479. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18480. /**
  18481. * Gets the animation from the runtime animation
  18482. */
  18483. readonly animation: Animation;
  18484. /**
  18485. * Resets the runtime animation to the beginning
  18486. * @param restoreOriginal defines whether to restore the target property to the original value
  18487. */
  18488. reset(restoreOriginal?: boolean): void;
  18489. /**
  18490. * Specifies if the runtime animation is stopped
  18491. * @returns Boolean specifying if the runtime animation is stopped
  18492. */
  18493. isStopped(): boolean;
  18494. /**
  18495. * Disposes of the runtime animation
  18496. */
  18497. dispose(): void;
  18498. /**
  18499. * Interpolates the animation from the current frame
  18500. * @param currentFrame The frame to interpolate the animation to
  18501. * @param repeatCount The number of times that the animation should loop
  18502. * @param loopMode The type of looping mode to use
  18503. * @param offsetValue Animation offset value
  18504. * @param highLimitValue The high limit value
  18505. * @returns The interpolated value
  18506. */
  18507. private _interpolate;
  18508. /**
  18509. * Apply the interpolated value to the target
  18510. * @param currentValue defines the value computed by the animation
  18511. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18512. */
  18513. setValue(currentValue: any, weight?: number): void;
  18514. private _setValue;
  18515. /**
  18516. * Gets the loop pmode of the runtime animation
  18517. * @returns Loop Mode
  18518. */
  18519. private _getCorrectLoopMode;
  18520. /**
  18521. * Move the current animation to a given frame
  18522. * @param frame defines the frame to move to
  18523. */
  18524. goToFrame(frame: number): void;
  18525. /**
  18526. * @hidden Internal use only
  18527. */
  18528. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18529. /**
  18530. * Execute the current animation
  18531. * @param delay defines the delay to add to the current frame
  18532. * @param from defines the lower bound of the animation range
  18533. * @param to defines the upper bound of the animation range
  18534. * @param loop defines if the current animation must loop
  18535. * @param speedRatio defines the current speed ratio
  18536. * @param weight defines the weight of the animation (default is -1 so no weight)
  18537. * @param onLoop optional callback called when animation loops
  18538. * @returns a boolean indicating if the animation is running
  18539. */
  18540. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18541. }
  18542. }
  18543. declare module "babylonjs/Animations/animatable" {
  18544. import { Animation } from "babylonjs/Animations/animation";
  18545. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18546. import { Nullable } from "babylonjs/types";
  18547. import { Observable } from "babylonjs/Misc/observable";
  18548. import { Scene } from "babylonjs/scene";
  18549. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18550. import { Node } from "babylonjs/node";
  18551. /**
  18552. * Class used to store an actual running animation
  18553. */
  18554. export class Animatable {
  18555. /** defines the target object */
  18556. target: any;
  18557. /** defines the starting frame number (default is 0) */
  18558. fromFrame: number;
  18559. /** defines the ending frame number (default is 100) */
  18560. toFrame: number;
  18561. /** defines if the animation must loop (default is false) */
  18562. loopAnimation: boolean;
  18563. /** defines a callback to call when animation ends if it is not looping */
  18564. onAnimationEnd?: (() => void) | null | undefined;
  18565. /** defines a callback to call when animation loops */
  18566. onAnimationLoop?: (() => void) | null | undefined;
  18567. private _localDelayOffset;
  18568. private _pausedDelay;
  18569. private _runtimeAnimations;
  18570. private _paused;
  18571. private _scene;
  18572. private _speedRatio;
  18573. private _weight;
  18574. private _syncRoot;
  18575. /**
  18576. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18577. * This will only apply for non looping animation (default is true)
  18578. */
  18579. disposeOnEnd: boolean;
  18580. /**
  18581. * Gets a boolean indicating if the animation has started
  18582. */
  18583. animationStarted: boolean;
  18584. /**
  18585. * Observer raised when the animation ends
  18586. */
  18587. onAnimationEndObservable: Observable<Animatable>;
  18588. /**
  18589. * Observer raised when the animation loops
  18590. */
  18591. onAnimationLoopObservable: Observable<Animatable>;
  18592. /**
  18593. * Gets the root Animatable used to synchronize and normalize animations
  18594. */
  18595. readonly syncRoot: Animatable;
  18596. /**
  18597. * Gets the current frame of the first RuntimeAnimation
  18598. * Used to synchronize Animatables
  18599. */
  18600. readonly masterFrame: number;
  18601. /**
  18602. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18603. */
  18604. weight: number;
  18605. /**
  18606. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18607. */
  18608. speedRatio: number;
  18609. /**
  18610. * Creates a new Animatable
  18611. * @param scene defines the hosting scene
  18612. * @param target defines the target object
  18613. * @param fromFrame defines the starting frame number (default is 0)
  18614. * @param toFrame defines the ending frame number (default is 100)
  18615. * @param loopAnimation defines if the animation must loop (default is false)
  18616. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18617. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18618. * @param animations defines a group of animation to add to the new Animatable
  18619. * @param onAnimationLoop defines a callback to call when animation loops
  18620. */
  18621. constructor(scene: Scene,
  18622. /** defines the target object */
  18623. target: any,
  18624. /** defines the starting frame number (default is 0) */
  18625. fromFrame?: number,
  18626. /** defines the ending frame number (default is 100) */
  18627. toFrame?: number,
  18628. /** defines if the animation must loop (default is false) */
  18629. loopAnimation?: boolean, speedRatio?: number,
  18630. /** defines a callback to call when animation ends if it is not looping */
  18631. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18632. /** defines a callback to call when animation loops */
  18633. onAnimationLoop?: (() => void) | null | undefined);
  18634. /**
  18635. * Synchronize and normalize current Animatable with a source Animatable
  18636. * This is useful when using animation weights and when animations are not of the same length
  18637. * @param root defines the root Animatable to synchronize with
  18638. * @returns the current Animatable
  18639. */
  18640. syncWith(root: Animatable): Animatable;
  18641. /**
  18642. * Gets the list of runtime animations
  18643. * @returns an array of RuntimeAnimation
  18644. */
  18645. getAnimations(): RuntimeAnimation[];
  18646. /**
  18647. * Adds more animations to the current animatable
  18648. * @param target defines the target of the animations
  18649. * @param animations defines the new animations to add
  18650. */
  18651. appendAnimations(target: any, animations: Animation[]): void;
  18652. /**
  18653. * Gets the source animation for a specific property
  18654. * @param property defines the propertyu to look for
  18655. * @returns null or the source animation for the given property
  18656. */
  18657. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18658. /**
  18659. * Gets the runtime animation for a specific property
  18660. * @param property defines the propertyu to look for
  18661. * @returns null or the runtime animation for the given property
  18662. */
  18663. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18664. /**
  18665. * Resets the animatable to its original state
  18666. */
  18667. reset(): void;
  18668. /**
  18669. * Allows the animatable to blend with current running animations
  18670. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18671. * @param blendingSpeed defines the blending speed to use
  18672. */
  18673. enableBlending(blendingSpeed: number): void;
  18674. /**
  18675. * Disable animation blending
  18676. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18677. */
  18678. disableBlending(): void;
  18679. /**
  18680. * Jump directly to a given frame
  18681. * @param frame defines the frame to jump to
  18682. */
  18683. goToFrame(frame: number): void;
  18684. /**
  18685. * Pause the animation
  18686. */
  18687. pause(): void;
  18688. /**
  18689. * Restart the animation
  18690. */
  18691. restart(): void;
  18692. private _raiseOnAnimationEnd;
  18693. /**
  18694. * Stop and delete the current animation
  18695. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18696. * @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)
  18697. */
  18698. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18699. /**
  18700. * Wait asynchronously for the animation to end
  18701. * @returns a promise which will be fullfilled when the animation ends
  18702. */
  18703. waitAsync(): Promise<Animatable>;
  18704. /** @hidden */
  18705. _animate(delay: number): boolean;
  18706. }
  18707. module "babylonjs/scene" {
  18708. interface Scene {
  18709. /** @hidden */
  18710. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18711. /** @hidden */
  18712. _processLateAnimationBindingsForMatrices(holder: {
  18713. totalWeight: number;
  18714. animations: RuntimeAnimation[];
  18715. originalValue: Matrix;
  18716. }): any;
  18717. /** @hidden */
  18718. _processLateAnimationBindingsForQuaternions(holder: {
  18719. totalWeight: number;
  18720. animations: RuntimeAnimation[];
  18721. originalValue: Quaternion;
  18722. }, refQuaternion: Quaternion): Quaternion;
  18723. /** @hidden */
  18724. _processLateAnimationBindings(): void;
  18725. /**
  18726. * Will start the animation sequence of a given target
  18727. * @param target defines the target
  18728. * @param from defines from which frame should animation start
  18729. * @param to defines until which frame should animation run.
  18730. * @param weight defines the weight to apply to the animation (1.0 by default)
  18731. * @param loop defines if the animation loops
  18732. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18733. * @param onAnimationEnd defines the function to be executed when the animation ends
  18734. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18735. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18736. * @param onAnimationLoop defines the callback to call when an animation loops
  18737. * @returns the animatable object created for this animation
  18738. */
  18739. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18740. /**
  18741. * Will start the animation sequence of a given target
  18742. * @param target defines the target
  18743. * @param from defines from which frame should animation start
  18744. * @param to defines until which frame should animation run.
  18745. * @param loop defines if the animation loops
  18746. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18747. * @param onAnimationEnd defines the function to be executed when the animation ends
  18748. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18749. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18750. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18751. * @param onAnimationLoop defines the callback to call when an animation loops
  18752. * @returns the animatable object created for this animation
  18753. */
  18754. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18755. /**
  18756. * Will start the animation sequence of a given target and its hierarchy
  18757. * @param target defines the target
  18758. * @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.
  18759. * @param from defines from which frame should animation start
  18760. * @param to defines until which frame should animation run.
  18761. * @param loop defines if the animation loops
  18762. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18763. * @param onAnimationEnd defines the function to be executed when the animation ends
  18764. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18765. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18766. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18767. * @param onAnimationLoop defines the callback to call when an animation loops
  18768. * @returns the list of created animatables
  18769. */
  18770. 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[];
  18771. /**
  18772. * Begin a new animation on a given node
  18773. * @param target defines the target where the animation will take place
  18774. * @param animations defines the list of animations to start
  18775. * @param from defines the initial value
  18776. * @param to defines the final value
  18777. * @param loop defines if you want animation to loop (off by default)
  18778. * @param speedRatio defines the speed ratio to apply to all animations
  18779. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18780. * @param onAnimationLoop defines the callback to call when an animation loops
  18781. * @returns the list of created animatables
  18782. */
  18783. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18784. /**
  18785. * Begin a new animation on a given node and its hierarchy
  18786. * @param target defines the root node where the animation will take place
  18787. * @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.
  18788. * @param animations defines the list of animations to start
  18789. * @param from defines the initial value
  18790. * @param to defines the final value
  18791. * @param loop defines if you want animation to loop (off by default)
  18792. * @param speedRatio defines the speed ratio to apply to all animations
  18793. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18794. * @param onAnimationLoop defines the callback to call when an animation loops
  18795. * @returns the list of animatables created for all nodes
  18796. */
  18797. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18798. /**
  18799. * Gets the animatable associated with a specific target
  18800. * @param target defines the target of the animatable
  18801. * @returns the required animatable if found
  18802. */
  18803. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18804. /**
  18805. * Gets all animatables associated with a given target
  18806. * @param target defines the target to look animatables for
  18807. * @returns an array of Animatables
  18808. */
  18809. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18810. /**
  18811. * Will stop the animation of the given target
  18812. * @param target - the target
  18813. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18814. * @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)
  18815. */
  18816. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18817. /**
  18818. * Stops and removes all animations that have been applied to the scene
  18819. */
  18820. stopAllAnimations(): void;
  18821. }
  18822. }
  18823. module "babylonjs/Bones/bone" {
  18824. interface Bone {
  18825. /**
  18826. * Copy an animation range from another bone
  18827. * @param source defines the source bone
  18828. * @param rangeName defines the range name to copy
  18829. * @param frameOffset defines the frame offset
  18830. * @param rescaleAsRequired defines if rescaling must be applied if required
  18831. * @param skelDimensionsRatio defines the scaling ratio
  18832. * @returns true if operation was successful
  18833. */
  18834. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18835. }
  18836. }
  18837. }
  18838. declare module "babylonjs/Bones/skeleton" {
  18839. import { Bone } from "babylonjs/Bones/bone";
  18840. import { IAnimatable } from "babylonjs/Misc/tools";
  18841. import { Observable } from "babylonjs/Misc/observable";
  18842. import { Vector3, Matrix } from "babylonjs/Maths/math";
  18843. import { Scene } from "babylonjs/scene";
  18844. import { Nullable } from "babylonjs/types";
  18845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18846. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  18847. import { Animatable } from "babylonjs/Animations/animatable";
  18848. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18849. import { Animation } from "babylonjs/Animations/animation";
  18850. import { AnimationRange } from "babylonjs/Animations/animationRange";
  18851. /**
  18852. * Class used to handle skinning animations
  18853. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18854. */
  18855. export class Skeleton implements IAnimatable {
  18856. /** defines the skeleton name */
  18857. name: string;
  18858. /** defines the skeleton Id */
  18859. id: string;
  18860. /**
  18861. * Defines the list of child bones
  18862. */
  18863. bones: Bone[];
  18864. /**
  18865. * Defines an estimate of the dimension of the skeleton at rest
  18866. */
  18867. dimensionsAtRest: Vector3;
  18868. /**
  18869. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18870. */
  18871. needInitialSkinMatrix: boolean;
  18872. /**
  18873. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18874. */
  18875. overrideMesh: Nullable<AbstractMesh>;
  18876. /**
  18877. * Gets the list of animations attached to this skeleton
  18878. */
  18879. animations: Array<Animation>;
  18880. private _scene;
  18881. private _isDirty;
  18882. private _transformMatrices;
  18883. private _transformMatrixTexture;
  18884. private _meshesWithPoseMatrix;
  18885. private _animatables;
  18886. private _identity;
  18887. private _synchronizedWithMesh;
  18888. private _ranges;
  18889. private _lastAbsoluteTransformsUpdateId;
  18890. private _canUseTextureForBones;
  18891. /** @hidden */
  18892. _numBonesWithLinkedTransformNode: number;
  18893. /**
  18894. * Specifies if the skeleton should be serialized
  18895. */
  18896. doNotSerialize: boolean;
  18897. /**
  18898. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18899. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18900. */
  18901. useTextureToStoreBoneMatrices: boolean;
  18902. private _animationPropertiesOverride;
  18903. /**
  18904. * Gets or sets the animation properties override
  18905. */
  18906. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18907. /**
  18908. * An observable triggered before computing the skeleton's matrices
  18909. */
  18910. onBeforeComputeObservable: Observable<Skeleton>;
  18911. /**
  18912. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18913. */
  18914. readonly isUsingTextureForMatrices: boolean;
  18915. /**
  18916. * Creates a new skeleton
  18917. * @param name defines the skeleton name
  18918. * @param id defines the skeleton Id
  18919. * @param scene defines the hosting scene
  18920. */
  18921. constructor(
  18922. /** defines the skeleton name */
  18923. name: string,
  18924. /** defines the skeleton Id */
  18925. id: string, scene: Scene);
  18926. /**
  18927. * Gets the current object class name.
  18928. * @return the class name
  18929. */
  18930. getClassName(): string;
  18931. /**
  18932. * Returns an array containing the root bones
  18933. * @returns an array containing the root bones
  18934. */
  18935. getChildren(): Array<Bone>;
  18936. /**
  18937. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18938. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18939. * @returns a Float32Array containing matrices data
  18940. */
  18941. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18942. /**
  18943. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18944. * @returns a raw texture containing the data
  18945. */
  18946. getTransformMatrixTexture(): Nullable<RawTexture>;
  18947. /**
  18948. * Gets the current hosting scene
  18949. * @returns a scene object
  18950. */
  18951. getScene(): Scene;
  18952. /**
  18953. * Gets a string representing the current skeleton data
  18954. * @param fullDetails defines a boolean indicating if we want a verbose version
  18955. * @returns a string representing the current skeleton data
  18956. */
  18957. toString(fullDetails?: boolean): string;
  18958. /**
  18959. * Get bone's index searching by name
  18960. * @param name defines bone's name to search for
  18961. * @return the indice of the bone. Returns -1 if not found
  18962. */
  18963. getBoneIndexByName(name: string): number;
  18964. /**
  18965. * Creater a new animation range
  18966. * @param name defines the name of the range
  18967. * @param from defines the start key
  18968. * @param to defines the end key
  18969. */
  18970. createAnimationRange(name: string, from: number, to: number): void;
  18971. /**
  18972. * Delete a specific animation range
  18973. * @param name defines the name of the range
  18974. * @param deleteFrames defines if frames must be removed as well
  18975. */
  18976. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18977. /**
  18978. * Gets a specific animation range
  18979. * @param name defines the name of the range to look for
  18980. * @returns the requested animation range or null if not found
  18981. */
  18982. getAnimationRange(name: string): Nullable<AnimationRange>;
  18983. /**
  18984. * Gets the list of all animation ranges defined on this skeleton
  18985. * @returns an array
  18986. */
  18987. getAnimationRanges(): Nullable<AnimationRange>[];
  18988. /**
  18989. * Copy animation range from a source skeleton.
  18990. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18991. * @param source defines the source skeleton
  18992. * @param name defines the name of the range to copy
  18993. * @param rescaleAsRequired defines if rescaling must be applied if required
  18994. * @returns true if operation was successful
  18995. */
  18996. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18997. /**
  18998. * Forces the skeleton to go to rest pose
  18999. */
  19000. returnToRest(): void;
  19001. private _getHighestAnimationFrame;
  19002. /**
  19003. * Begin a specific animation range
  19004. * @param name defines the name of the range to start
  19005. * @param loop defines if looping must be turned on (false by default)
  19006. * @param speedRatio defines the speed ratio to apply (1 by default)
  19007. * @param onAnimationEnd defines a callback which will be called when animation will end
  19008. * @returns a new animatable
  19009. */
  19010. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19011. /** @hidden */
  19012. _markAsDirty(): void;
  19013. /** @hidden */
  19014. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19015. /** @hidden */
  19016. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19017. private _computeTransformMatrices;
  19018. /**
  19019. * Build all resources required to render a skeleton
  19020. */
  19021. prepare(): void;
  19022. /**
  19023. * Gets the list of animatables currently running for this skeleton
  19024. * @returns an array of animatables
  19025. */
  19026. getAnimatables(): IAnimatable[];
  19027. /**
  19028. * Clone the current skeleton
  19029. * @param name defines the name of the new skeleton
  19030. * @param id defines the id of the enw skeleton
  19031. * @returns the new skeleton
  19032. */
  19033. clone(name: string, id: string): Skeleton;
  19034. /**
  19035. * Enable animation blending for this skeleton
  19036. * @param blendingSpeed defines the blending speed to apply
  19037. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19038. */
  19039. enableBlending(blendingSpeed?: number): void;
  19040. /**
  19041. * Releases all resources associated with the current skeleton
  19042. */
  19043. dispose(): void;
  19044. /**
  19045. * Serialize the skeleton in a JSON object
  19046. * @returns a JSON object
  19047. */
  19048. serialize(): any;
  19049. /**
  19050. * Creates a new skeleton from serialized data
  19051. * @param parsedSkeleton defines the serialized data
  19052. * @param scene defines the hosting scene
  19053. * @returns a new skeleton
  19054. */
  19055. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19056. /**
  19057. * Compute all node absolute transforms
  19058. * @param forceUpdate defines if computation must be done even if cache is up to date
  19059. */
  19060. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19061. /**
  19062. * Gets the root pose matrix
  19063. * @returns a matrix
  19064. */
  19065. getPoseMatrix(): Nullable<Matrix>;
  19066. /**
  19067. * Sorts bones per internal index
  19068. */
  19069. sortBones(): void;
  19070. private _sortBones;
  19071. }
  19072. }
  19073. declare module "babylonjs/Morph/morphTarget" {
  19074. import { IAnimatable } from "babylonjs/Misc/tools";
  19075. import { Observable } from "babylonjs/Misc/observable";
  19076. import { Nullable, FloatArray } from "babylonjs/types";
  19077. import { Scene } from "babylonjs/scene";
  19078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19079. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19080. /**
  19081. * Defines a target to use with MorphTargetManager
  19082. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19083. */
  19084. export class MorphTarget implements IAnimatable {
  19085. /** defines the name of the target */
  19086. name: string;
  19087. /**
  19088. * Gets or sets the list of animations
  19089. */
  19090. animations: import("babylonjs/Animations/animation").Animation[];
  19091. private _scene;
  19092. private _positions;
  19093. private _normals;
  19094. private _tangents;
  19095. private _influence;
  19096. /**
  19097. * Observable raised when the influence changes
  19098. */
  19099. onInfluenceChanged: Observable<boolean>;
  19100. /** @hidden */
  19101. _onDataLayoutChanged: Observable<void>;
  19102. /**
  19103. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19104. */
  19105. influence: number;
  19106. /**
  19107. * Gets or sets the id of the morph Target
  19108. */
  19109. id: string;
  19110. private _animationPropertiesOverride;
  19111. /**
  19112. * Gets or sets the animation properties override
  19113. */
  19114. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19115. /**
  19116. * Creates a new MorphTarget
  19117. * @param name defines the name of the target
  19118. * @param influence defines the influence to use
  19119. * @param scene defines the scene the morphtarget belongs to
  19120. */
  19121. constructor(
  19122. /** defines the name of the target */
  19123. name: string, influence?: number, scene?: Nullable<Scene>);
  19124. /**
  19125. * Gets a boolean defining if the target contains position data
  19126. */
  19127. readonly hasPositions: boolean;
  19128. /**
  19129. * Gets a boolean defining if the target contains normal data
  19130. */
  19131. readonly hasNormals: boolean;
  19132. /**
  19133. * Gets a boolean defining if the target contains tangent data
  19134. */
  19135. readonly hasTangents: boolean;
  19136. /**
  19137. * Affects position data to this target
  19138. * @param data defines the position data to use
  19139. */
  19140. setPositions(data: Nullable<FloatArray>): void;
  19141. /**
  19142. * Gets the position data stored in this target
  19143. * @returns a FloatArray containing the position data (or null if not present)
  19144. */
  19145. getPositions(): Nullable<FloatArray>;
  19146. /**
  19147. * Affects normal data to this target
  19148. * @param data defines the normal data to use
  19149. */
  19150. setNormals(data: Nullable<FloatArray>): void;
  19151. /**
  19152. * Gets the normal data stored in this target
  19153. * @returns a FloatArray containing the normal data (or null if not present)
  19154. */
  19155. getNormals(): Nullable<FloatArray>;
  19156. /**
  19157. * Affects tangent data to this target
  19158. * @param data defines the tangent data to use
  19159. */
  19160. setTangents(data: Nullable<FloatArray>): void;
  19161. /**
  19162. * Gets the tangent data stored in this target
  19163. * @returns a FloatArray containing the tangent data (or null if not present)
  19164. */
  19165. getTangents(): Nullable<FloatArray>;
  19166. /**
  19167. * Serializes the current target into a Serialization object
  19168. * @returns the serialized object
  19169. */
  19170. serialize(): any;
  19171. /**
  19172. * Returns the string "MorphTarget"
  19173. * @returns "MorphTarget"
  19174. */
  19175. getClassName(): string;
  19176. /**
  19177. * Creates a new target from serialized data
  19178. * @param serializationObject defines the serialized data to use
  19179. * @returns a new MorphTarget
  19180. */
  19181. static Parse(serializationObject: any): MorphTarget;
  19182. /**
  19183. * Creates a MorphTarget from mesh data
  19184. * @param mesh defines the source mesh
  19185. * @param name defines the name to use for the new target
  19186. * @param influence defines the influence to attach to the target
  19187. * @returns a new MorphTarget
  19188. */
  19189. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19190. }
  19191. }
  19192. declare module "babylonjs/Morph/morphTargetManager" {
  19193. import { Nullable } from "babylonjs/types";
  19194. import { Scene } from "babylonjs/scene";
  19195. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19196. /**
  19197. * This class is used to deform meshes using morphing between different targets
  19198. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19199. */
  19200. export class MorphTargetManager {
  19201. private _targets;
  19202. private _targetInfluenceChangedObservers;
  19203. private _targetDataLayoutChangedObservers;
  19204. private _activeTargets;
  19205. private _scene;
  19206. private _influences;
  19207. private _supportsNormals;
  19208. private _supportsTangents;
  19209. private _vertexCount;
  19210. private _uniqueId;
  19211. private _tempInfluences;
  19212. /**
  19213. * Creates a new MorphTargetManager
  19214. * @param scene defines the current scene
  19215. */
  19216. constructor(scene?: Nullable<Scene>);
  19217. /**
  19218. * Gets the unique ID of this manager
  19219. */
  19220. readonly uniqueId: number;
  19221. /**
  19222. * Gets the number of vertices handled by this manager
  19223. */
  19224. readonly vertexCount: number;
  19225. /**
  19226. * Gets a boolean indicating if this manager supports morphing of normals
  19227. */
  19228. readonly supportsNormals: boolean;
  19229. /**
  19230. * Gets a boolean indicating if this manager supports morphing of tangents
  19231. */
  19232. readonly supportsTangents: boolean;
  19233. /**
  19234. * Gets the number of targets stored in this manager
  19235. */
  19236. readonly numTargets: number;
  19237. /**
  19238. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19239. */
  19240. readonly numInfluencers: number;
  19241. /**
  19242. * Gets the list of influences (one per target)
  19243. */
  19244. readonly influences: Float32Array;
  19245. /**
  19246. * Gets the active target at specified index. An active target is a target with an influence > 0
  19247. * @param index defines the index to check
  19248. * @returns the requested target
  19249. */
  19250. getActiveTarget(index: number): MorphTarget;
  19251. /**
  19252. * Gets the target at specified index
  19253. * @param index defines the index to check
  19254. * @returns the requested target
  19255. */
  19256. getTarget(index: number): MorphTarget;
  19257. /**
  19258. * Add a new target to this manager
  19259. * @param target defines the target to add
  19260. */
  19261. addTarget(target: MorphTarget): void;
  19262. /**
  19263. * Removes a target from the manager
  19264. * @param target defines the target to remove
  19265. */
  19266. removeTarget(target: MorphTarget): void;
  19267. /**
  19268. * Serializes the current manager into a Serialization object
  19269. * @returns the serialized object
  19270. */
  19271. serialize(): any;
  19272. private _syncActiveTargets;
  19273. /**
  19274. * Syncrhonize the targets with all the meshes using this morph target manager
  19275. */
  19276. synchronize(): void;
  19277. /**
  19278. * Creates a new MorphTargetManager from serialized data
  19279. * @param serializationObject defines the serialized data
  19280. * @param scene defines the hosting scene
  19281. * @returns the new MorphTargetManager
  19282. */
  19283. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19284. }
  19285. }
  19286. declare module "babylonjs/Meshes/groundMesh" {
  19287. import { Scene } from "babylonjs/scene";
  19288. import { Vector3 } from "babylonjs/Maths/math";
  19289. import { Mesh } from "babylonjs/Meshes/mesh";
  19290. /**
  19291. * Mesh representing the gorund
  19292. */
  19293. export class GroundMesh extends Mesh {
  19294. /** If octree should be generated */
  19295. generateOctree: boolean;
  19296. private _heightQuads;
  19297. /** @hidden */
  19298. _subdivisionsX: number;
  19299. /** @hidden */
  19300. _subdivisionsY: number;
  19301. /** @hidden */
  19302. _width: number;
  19303. /** @hidden */
  19304. _height: number;
  19305. /** @hidden */
  19306. _minX: number;
  19307. /** @hidden */
  19308. _maxX: number;
  19309. /** @hidden */
  19310. _minZ: number;
  19311. /** @hidden */
  19312. _maxZ: number;
  19313. constructor(name: string, scene: Scene);
  19314. /**
  19315. * "GroundMesh"
  19316. * @returns "GroundMesh"
  19317. */
  19318. getClassName(): string;
  19319. /**
  19320. * The minimum of x and y subdivisions
  19321. */
  19322. readonly subdivisions: number;
  19323. /**
  19324. * X subdivisions
  19325. */
  19326. readonly subdivisionsX: number;
  19327. /**
  19328. * Y subdivisions
  19329. */
  19330. readonly subdivisionsY: number;
  19331. /**
  19332. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19333. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19334. * @param chunksCount the number of subdivisions for x and y
  19335. * @param octreeBlocksSize (Default: 32)
  19336. */
  19337. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19338. /**
  19339. * Returns a height (y) value in the Worl system :
  19340. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19341. * @param x x coordinate
  19342. * @param z z coordinate
  19343. * @returns the ground y position if (x, z) are outside the ground surface.
  19344. */
  19345. getHeightAtCoordinates(x: number, z: number): number;
  19346. /**
  19347. * Returns a normalized vector (Vector3) orthogonal to the ground
  19348. * at the ground coordinates (x, z) expressed in the World system.
  19349. * @param x x coordinate
  19350. * @param z z coordinate
  19351. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19352. */
  19353. getNormalAtCoordinates(x: number, z: number): Vector3;
  19354. /**
  19355. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19356. * at the ground coordinates (x, z) expressed in the World system.
  19357. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19358. * @param x x coordinate
  19359. * @param z z coordinate
  19360. * @param ref vector to store the result
  19361. * @returns the GroundMesh.
  19362. */
  19363. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19364. /**
  19365. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19366. * if the ground has been updated.
  19367. * This can be used in the render loop.
  19368. * @returns the GroundMesh.
  19369. */
  19370. updateCoordinateHeights(): GroundMesh;
  19371. private _getFacetAt;
  19372. private _initHeightQuads;
  19373. private _computeHeightQuads;
  19374. /**
  19375. * Serializes this ground mesh
  19376. * @param serializationObject object to write serialization to
  19377. */
  19378. serialize(serializationObject: any): void;
  19379. /**
  19380. * Parses a serialized ground mesh
  19381. * @param parsedMesh the serialized mesh
  19382. * @param scene the scene to create the ground mesh in
  19383. * @returns the created ground mesh
  19384. */
  19385. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19386. }
  19387. }
  19388. declare module "babylonjs/Physics/physicsJoint" {
  19389. import { Vector3 } from "babylonjs/Maths/math";
  19390. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19391. /**
  19392. * Interface for Physics-Joint data
  19393. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19394. */
  19395. export interface PhysicsJointData {
  19396. /**
  19397. * The main pivot of the joint
  19398. */
  19399. mainPivot?: Vector3;
  19400. /**
  19401. * The connected pivot of the joint
  19402. */
  19403. connectedPivot?: Vector3;
  19404. /**
  19405. * The main axis of the joint
  19406. */
  19407. mainAxis?: Vector3;
  19408. /**
  19409. * The connected axis of the joint
  19410. */
  19411. connectedAxis?: Vector3;
  19412. /**
  19413. * The collision of the joint
  19414. */
  19415. collision?: boolean;
  19416. /**
  19417. * Native Oimo/Cannon/Energy data
  19418. */
  19419. nativeParams?: any;
  19420. }
  19421. /**
  19422. * This is a holder class for the physics joint created by the physics plugin
  19423. * It holds a set of functions to control the underlying joint
  19424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19425. */
  19426. export class PhysicsJoint {
  19427. /**
  19428. * The type of the physics joint
  19429. */
  19430. type: number;
  19431. /**
  19432. * The data for the physics joint
  19433. */
  19434. jointData: PhysicsJointData;
  19435. private _physicsJoint;
  19436. protected _physicsPlugin: IPhysicsEnginePlugin;
  19437. /**
  19438. * Initializes the physics joint
  19439. * @param type The type of the physics joint
  19440. * @param jointData The data for the physics joint
  19441. */
  19442. constructor(
  19443. /**
  19444. * The type of the physics joint
  19445. */
  19446. type: number,
  19447. /**
  19448. * The data for the physics joint
  19449. */
  19450. jointData: PhysicsJointData);
  19451. /**
  19452. * Gets the physics joint
  19453. */
  19454. /**
  19455. * Sets the physics joint
  19456. */
  19457. physicsJoint: any;
  19458. /**
  19459. * Sets the physics plugin
  19460. */
  19461. physicsPlugin: IPhysicsEnginePlugin;
  19462. /**
  19463. * Execute a function that is physics-plugin specific.
  19464. * @param {Function} func the function that will be executed.
  19465. * It accepts two parameters: the physics world and the physics joint
  19466. */
  19467. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19468. /**
  19469. * Distance-Joint type
  19470. */
  19471. static DistanceJoint: number;
  19472. /**
  19473. * Hinge-Joint type
  19474. */
  19475. static HingeJoint: number;
  19476. /**
  19477. * Ball-and-Socket joint type
  19478. */
  19479. static BallAndSocketJoint: number;
  19480. /**
  19481. * Wheel-Joint type
  19482. */
  19483. static WheelJoint: number;
  19484. /**
  19485. * Slider-Joint type
  19486. */
  19487. static SliderJoint: number;
  19488. /**
  19489. * Prismatic-Joint type
  19490. */
  19491. static PrismaticJoint: number;
  19492. /**
  19493. * Universal-Joint type
  19494. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19495. */
  19496. static UniversalJoint: number;
  19497. /**
  19498. * Hinge-Joint 2 type
  19499. */
  19500. static Hinge2Joint: number;
  19501. /**
  19502. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19503. */
  19504. static PointToPointJoint: number;
  19505. /**
  19506. * Spring-Joint type
  19507. */
  19508. static SpringJoint: number;
  19509. /**
  19510. * Lock-Joint type
  19511. */
  19512. static LockJoint: number;
  19513. }
  19514. /**
  19515. * A class representing a physics distance joint
  19516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19517. */
  19518. export class DistanceJoint extends PhysicsJoint {
  19519. /**
  19520. *
  19521. * @param jointData The data for the Distance-Joint
  19522. */
  19523. constructor(jointData: DistanceJointData);
  19524. /**
  19525. * Update the predefined distance.
  19526. * @param maxDistance The maximum preferred distance
  19527. * @param minDistance The minimum preferred distance
  19528. */
  19529. updateDistance(maxDistance: number, minDistance?: number): void;
  19530. }
  19531. /**
  19532. * Represents a Motor-Enabled Joint
  19533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19534. */
  19535. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19536. /**
  19537. * Initializes the Motor-Enabled Joint
  19538. * @param type The type of the joint
  19539. * @param jointData The physica joint data for the joint
  19540. */
  19541. constructor(type: number, jointData: PhysicsJointData);
  19542. /**
  19543. * Set the motor values.
  19544. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19545. * @param force the force to apply
  19546. * @param maxForce max force for this motor.
  19547. */
  19548. setMotor(force?: number, maxForce?: number): void;
  19549. /**
  19550. * Set the motor's limits.
  19551. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19552. * @param upperLimit The upper limit of the motor
  19553. * @param lowerLimit The lower limit of the motor
  19554. */
  19555. setLimit(upperLimit: number, lowerLimit?: number): void;
  19556. }
  19557. /**
  19558. * This class represents a single physics Hinge-Joint
  19559. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19560. */
  19561. export class HingeJoint extends MotorEnabledJoint {
  19562. /**
  19563. * Initializes the Hinge-Joint
  19564. * @param jointData The joint data for the Hinge-Joint
  19565. */
  19566. constructor(jointData: PhysicsJointData);
  19567. /**
  19568. * Set the motor values.
  19569. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19570. * @param {number} force the force to apply
  19571. * @param {number} maxForce max force for this motor.
  19572. */
  19573. setMotor(force?: number, maxForce?: number): void;
  19574. /**
  19575. * Set the motor's limits.
  19576. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19577. * @param upperLimit The upper limit of the motor
  19578. * @param lowerLimit The lower limit of the motor
  19579. */
  19580. setLimit(upperLimit: number, lowerLimit?: number): void;
  19581. }
  19582. /**
  19583. * This class represents a dual hinge physics joint (same as wheel joint)
  19584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19585. */
  19586. export class Hinge2Joint extends MotorEnabledJoint {
  19587. /**
  19588. * Initializes the Hinge2-Joint
  19589. * @param jointData The joint data for the Hinge2-Joint
  19590. */
  19591. constructor(jointData: PhysicsJointData);
  19592. /**
  19593. * Set the motor values.
  19594. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19595. * @param {number} targetSpeed the speed the motor is to reach
  19596. * @param {number} maxForce max force for this motor.
  19597. * @param {motorIndex} the motor's index, 0 or 1.
  19598. */
  19599. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19600. /**
  19601. * Set the motor limits.
  19602. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19603. * @param {number} upperLimit the upper limit
  19604. * @param {number} lowerLimit lower limit
  19605. * @param {motorIndex} the motor's index, 0 or 1.
  19606. */
  19607. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19608. }
  19609. /**
  19610. * Interface for a motor enabled joint
  19611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19612. */
  19613. export interface IMotorEnabledJoint {
  19614. /**
  19615. * Physics joint
  19616. */
  19617. physicsJoint: any;
  19618. /**
  19619. * Sets the motor of the motor-enabled joint
  19620. * @param force The force of the motor
  19621. * @param maxForce The maximum force of the motor
  19622. * @param motorIndex The index of the motor
  19623. */
  19624. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19625. /**
  19626. * Sets the limit of the motor
  19627. * @param upperLimit The upper limit of the motor
  19628. * @param lowerLimit The lower limit of the motor
  19629. * @param motorIndex The index of the motor
  19630. */
  19631. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19632. }
  19633. /**
  19634. * Joint data for a Distance-Joint
  19635. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19636. */
  19637. export interface DistanceJointData extends PhysicsJointData {
  19638. /**
  19639. * Max distance the 2 joint objects can be apart
  19640. */
  19641. maxDistance: number;
  19642. }
  19643. /**
  19644. * Joint data from a spring joint
  19645. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19646. */
  19647. export interface SpringJointData extends PhysicsJointData {
  19648. /**
  19649. * Length of the spring
  19650. */
  19651. length: number;
  19652. /**
  19653. * Stiffness of the spring
  19654. */
  19655. stiffness: number;
  19656. /**
  19657. * Damping of the spring
  19658. */
  19659. damping: number;
  19660. /** this callback will be called when applying the force to the impostors. */
  19661. forceApplicationCallback: () => void;
  19662. }
  19663. }
  19664. declare module "babylonjs/Physics/IPhysicsEngine" {
  19665. import { Nullable } from "babylonjs/types";
  19666. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19668. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19669. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19670. /**
  19671. * Interface used to describe a physics joint
  19672. */
  19673. export interface PhysicsImpostorJoint {
  19674. /** Defines the main impostor to which the joint is linked */
  19675. mainImpostor: PhysicsImpostor;
  19676. /** Defines the impostor that is connected to the main impostor using this joint */
  19677. connectedImpostor: PhysicsImpostor;
  19678. /** Defines the joint itself */
  19679. joint: PhysicsJoint;
  19680. }
  19681. /** @hidden */
  19682. export interface IPhysicsEnginePlugin {
  19683. world: any;
  19684. name: string;
  19685. setGravity(gravity: Vector3): void;
  19686. setTimeStep(timeStep: number): void;
  19687. getTimeStep(): number;
  19688. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19689. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19690. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19691. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19692. removePhysicsBody(impostor: PhysicsImpostor): void;
  19693. generateJoint(joint: PhysicsImpostorJoint): void;
  19694. removeJoint(joint: PhysicsImpostorJoint): void;
  19695. isSupported(): boolean;
  19696. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19697. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19698. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19699. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19700. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19701. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19702. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19703. getBodyMass(impostor: PhysicsImpostor): number;
  19704. getBodyFriction(impostor: PhysicsImpostor): number;
  19705. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19706. getBodyRestitution(impostor: PhysicsImpostor): number;
  19707. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19708. sleepBody(impostor: PhysicsImpostor): void;
  19709. wakeUpBody(impostor: PhysicsImpostor): void;
  19710. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19711. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19712. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19713. getRadius(impostor: PhysicsImpostor): number;
  19714. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19715. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19716. dispose(): void;
  19717. }
  19718. /**
  19719. * Interface used to define a physics engine
  19720. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19721. */
  19722. export interface IPhysicsEngine {
  19723. /**
  19724. * Gets the gravity vector used by the simulation
  19725. */
  19726. gravity: Vector3;
  19727. /**
  19728. * Sets the gravity vector used by the simulation
  19729. * @param gravity defines the gravity vector to use
  19730. */
  19731. setGravity(gravity: Vector3): void;
  19732. /**
  19733. * Set the time step of the physics engine.
  19734. * Default is 1/60.
  19735. * To slow it down, enter 1/600 for example.
  19736. * To speed it up, 1/30
  19737. * @param newTimeStep the new timestep to apply to this world.
  19738. */
  19739. setTimeStep(newTimeStep: number): void;
  19740. /**
  19741. * Get the time step of the physics engine.
  19742. * @returns the current time step
  19743. */
  19744. getTimeStep(): number;
  19745. /**
  19746. * Release all resources
  19747. */
  19748. dispose(): void;
  19749. /**
  19750. * Gets the name of the current physics plugin
  19751. * @returns the name of the plugin
  19752. */
  19753. getPhysicsPluginName(): string;
  19754. /**
  19755. * Adding a new impostor for the impostor tracking.
  19756. * This will be done by the impostor itself.
  19757. * @param impostor the impostor to add
  19758. */
  19759. addImpostor(impostor: PhysicsImpostor): void;
  19760. /**
  19761. * Remove an impostor from the engine.
  19762. * This impostor and its mesh will not longer be updated by the physics engine.
  19763. * @param impostor the impostor to remove
  19764. */
  19765. removeImpostor(impostor: PhysicsImpostor): void;
  19766. /**
  19767. * Add a joint to the physics engine
  19768. * @param mainImpostor defines the main impostor to which the joint is added.
  19769. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19770. * @param joint defines the joint that will connect both impostors.
  19771. */
  19772. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19773. /**
  19774. * Removes a joint from the simulation
  19775. * @param mainImpostor defines the impostor used with the joint
  19776. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19777. * @param joint defines the joint to remove
  19778. */
  19779. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19780. /**
  19781. * Gets the current plugin used to run the simulation
  19782. * @returns current plugin
  19783. */
  19784. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19785. /**
  19786. * Gets the list of physic impostors
  19787. * @returns an array of PhysicsImpostor
  19788. */
  19789. getImpostors(): Array<PhysicsImpostor>;
  19790. /**
  19791. * Gets the impostor for a physics enabled object
  19792. * @param object defines the object impersonated by the impostor
  19793. * @returns the PhysicsImpostor or null if not found
  19794. */
  19795. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19796. /**
  19797. * Gets the impostor for a physics body object
  19798. * @param body defines physics body used by the impostor
  19799. * @returns the PhysicsImpostor or null if not found
  19800. */
  19801. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19802. /**
  19803. * Called by the scene. No need to call it.
  19804. * @param delta defines the timespam between frames
  19805. */
  19806. _step(delta: number): void;
  19807. }
  19808. }
  19809. declare module "babylonjs/Physics/physicsImpostor" {
  19810. import { Nullable, IndicesArray } from "babylonjs/types";
  19811. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19812. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19814. import { Scene } from "babylonjs/scene";
  19815. import { Bone } from "babylonjs/Bones/bone";
  19816. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19817. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19818. /**
  19819. * The interface for the physics imposter parameters
  19820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19821. */
  19822. export interface PhysicsImpostorParameters {
  19823. /**
  19824. * The mass of the physics imposter
  19825. */
  19826. mass: number;
  19827. /**
  19828. * The friction of the physics imposter
  19829. */
  19830. friction?: number;
  19831. /**
  19832. * The coefficient of restitution of the physics imposter
  19833. */
  19834. restitution?: number;
  19835. /**
  19836. * The native options of the physics imposter
  19837. */
  19838. nativeOptions?: any;
  19839. /**
  19840. * Specifies if the parent should be ignored
  19841. */
  19842. ignoreParent?: boolean;
  19843. /**
  19844. * Specifies if bi-directional transformations should be disabled
  19845. */
  19846. disableBidirectionalTransformation?: boolean;
  19847. }
  19848. /**
  19849. * Interface for a physics-enabled object
  19850. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19851. */
  19852. export interface IPhysicsEnabledObject {
  19853. /**
  19854. * The position of the physics-enabled object
  19855. */
  19856. position: Vector3;
  19857. /**
  19858. * The rotation of the physics-enabled object
  19859. */
  19860. rotationQuaternion: Nullable<Quaternion>;
  19861. /**
  19862. * The scale of the physics-enabled object
  19863. */
  19864. scaling: Vector3;
  19865. /**
  19866. * The rotation of the physics-enabled object
  19867. */
  19868. rotation?: Vector3;
  19869. /**
  19870. * The parent of the physics-enabled object
  19871. */
  19872. parent?: any;
  19873. /**
  19874. * The bounding info of the physics-enabled object
  19875. * @returns The bounding info of the physics-enabled object
  19876. */
  19877. getBoundingInfo(): BoundingInfo;
  19878. /**
  19879. * Computes the world matrix
  19880. * @param force Specifies if the world matrix should be computed by force
  19881. * @returns A world matrix
  19882. */
  19883. computeWorldMatrix(force: boolean): Matrix;
  19884. /**
  19885. * Gets the world matrix
  19886. * @returns A world matrix
  19887. */
  19888. getWorldMatrix?(): Matrix;
  19889. /**
  19890. * Gets the child meshes
  19891. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19892. * @returns An array of abstract meshes
  19893. */
  19894. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19895. /**
  19896. * Gets the vertex data
  19897. * @param kind The type of vertex data
  19898. * @returns A nullable array of numbers, or a float32 array
  19899. */
  19900. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19901. /**
  19902. * Gets the indices from the mesh
  19903. * @returns A nullable array of index arrays
  19904. */
  19905. getIndices?(): Nullable<IndicesArray>;
  19906. /**
  19907. * Gets the scene from the mesh
  19908. * @returns the indices array or null
  19909. */
  19910. getScene?(): Scene;
  19911. /**
  19912. * Gets the absolute position from the mesh
  19913. * @returns the absolute position
  19914. */
  19915. getAbsolutePosition(): Vector3;
  19916. /**
  19917. * Gets the absolute pivot point from the mesh
  19918. * @returns the absolute pivot point
  19919. */
  19920. getAbsolutePivotPoint(): Vector3;
  19921. /**
  19922. * Rotates the mesh
  19923. * @param axis The axis of rotation
  19924. * @param amount The amount of rotation
  19925. * @param space The space of the rotation
  19926. * @returns The rotation transform node
  19927. */
  19928. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19929. /**
  19930. * Translates the mesh
  19931. * @param axis The axis of translation
  19932. * @param distance The distance of translation
  19933. * @param space The space of the translation
  19934. * @returns The transform node
  19935. */
  19936. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19937. /**
  19938. * Sets the absolute position of the mesh
  19939. * @param absolutePosition The absolute position of the mesh
  19940. * @returns The transform node
  19941. */
  19942. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19943. /**
  19944. * Gets the class name of the mesh
  19945. * @returns The class name
  19946. */
  19947. getClassName(): string;
  19948. }
  19949. /**
  19950. * Represents a physics imposter
  19951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19952. */
  19953. export class PhysicsImpostor {
  19954. /**
  19955. * The physics-enabled object used as the physics imposter
  19956. */
  19957. object: IPhysicsEnabledObject;
  19958. /**
  19959. * The type of the physics imposter
  19960. */
  19961. type: number;
  19962. private _options;
  19963. private _scene?;
  19964. /**
  19965. * The default object size of the imposter
  19966. */
  19967. static DEFAULT_OBJECT_SIZE: Vector3;
  19968. /**
  19969. * The identity quaternion of the imposter
  19970. */
  19971. static IDENTITY_QUATERNION: Quaternion;
  19972. /** @hidden */
  19973. _pluginData: any;
  19974. private _physicsEngine;
  19975. private _physicsBody;
  19976. private _bodyUpdateRequired;
  19977. private _onBeforePhysicsStepCallbacks;
  19978. private _onAfterPhysicsStepCallbacks;
  19979. /** @hidden */
  19980. _onPhysicsCollideCallbacks: Array<{
  19981. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19982. otherImpostors: Array<PhysicsImpostor>;
  19983. }>;
  19984. private _deltaPosition;
  19985. private _deltaRotation;
  19986. private _deltaRotationConjugated;
  19987. private _parent;
  19988. private _isDisposed;
  19989. private static _tmpVecs;
  19990. private static _tmpQuat;
  19991. /**
  19992. * Specifies if the physics imposter is disposed
  19993. */
  19994. readonly isDisposed: boolean;
  19995. /**
  19996. * Gets the mass of the physics imposter
  19997. */
  19998. mass: number;
  19999. /**
  20000. * Gets the coefficient of friction
  20001. */
  20002. /**
  20003. * Sets the coefficient of friction
  20004. */
  20005. friction: number;
  20006. /**
  20007. * Gets the coefficient of restitution
  20008. */
  20009. /**
  20010. * Sets the coefficient of restitution
  20011. */
  20012. restitution: number;
  20013. /**
  20014. * The unique id of the physics imposter
  20015. * set by the physics engine when adding this impostor to the array
  20016. */
  20017. uniqueId: number;
  20018. private _joints;
  20019. /**
  20020. * Initializes the physics imposter
  20021. * @param object The physics-enabled object used as the physics imposter
  20022. * @param type The type of the physics imposter
  20023. * @param _options The options for the physics imposter
  20024. * @param _scene The Babylon scene
  20025. */
  20026. constructor(
  20027. /**
  20028. * The physics-enabled object used as the physics imposter
  20029. */
  20030. object: IPhysicsEnabledObject,
  20031. /**
  20032. * The type of the physics imposter
  20033. */
  20034. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20035. /**
  20036. * This function will completly initialize this impostor.
  20037. * It will create a new body - but only if this mesh has no parent.
  20038. * If it has, this impostor will not be used other than to define the impostor
  20039. * of the child mesh.
  20040. * @hidden
  20041. */
  20042. _init(): void;
  20043. private _getPhysicsParent;
  20044. /**
  20045. * Should a new body be generated.
  20046. * @returns boolean specifying if body initialization is required
  20047. */
  20048. isBodyInitRequired(): boolean;
  20049. /**
  20050. * Sets the updated scaling
  20051. * @param updated Specifies if the scaling is updated
  20052. */
  20053. setScalingUpdated(): void;
  20054. /**
  20055. * Force a regeneration of this or the parent's impostor's body.
  20056. * Use under cautious - This will remove all joints already implemented.
  20057. */
  20058. forceUpdate(): void;
  20059. /**
  20060. * Gets the body that holds this impostor. Either its own, or its parent.
  20061. */
  20062. /**
  20063. * Set the physics body. Used mainly by the physics engine/plugin
  20064. */
  20065. physicsBody: any;
  20066. /**
  20067. * Get the parent of the physics imposter
  20068. * @returns Physics imposter or null
  20069. */
  20070. /**
  20071. * Sets the parent of the physics imposter
  20072. */
  20073. parent: Nullable<PhysicsImpostor>;
  20074. /**
  20075. * Resets the update flags
  20076. */
  20077. resetUpdateFlags(): void;
  20078. /**
  20079. * Gets the object extend size
  20080. * @returns the object extend size
  20081. */
  20082. getObjectExtendSize(): Vector3;
  20083. /**
  20084. * Gets the object center
  20085. * @returns The object center
  20086. */
  20087. getObjectCenter(): Vector3;
  20088. /**
  20089. * Get a specific parametes from the options parameter
  20090. * @param paramName The object parameter name
  20091. * @returns The object parameter
  20092. */
  20093. getParam(paramName: string): any;
  20094. /**
  20095. * Sets a specific parameter in the options given to the physics plugin
  20096. * @param paramName The parameter name
  20097. * @param value The value of the parameter
  20098. */
  20099. setParam(paramName: string, value: number): void;
  20100. /**
  20101. * Specifically change the body's mass option. Won't recreate the physics body object
  20102. * @param mass The mass of the physics imposter
  20103. */
  20104. setMass(mass: number): void;
  20105. /**
  20106. * Gets the linear velocity
  20107. * @returns linear velocity or null
  20108. */
  20109. getLinearVelocity(): Nullable<Vector3>;
  20110. /**
  20111. * Sets the linear velocity
  20112. * @param velocity linear velocity or null
  20113. */
  20114. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20115. /**
  20116. * Gets the angular velocity
  20117. * @returns angular velocity or null
  20118. */
  20119. getAngularVelocity(): Nullable<Vector3>;
  20120. /**
  20121. * Sets the angular velocity
  20122. * @param velocity The velocity or null
  20123. */
  20124. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20125. /**
  20126. * Execute a function with the physics plugin native code
  20127. * Provide a function the will have two variables - the world object and the physics body object
  20128. * @param func The function to execute with the physics plugin native code
  20129. */
  20130. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20131. /**
  20132. * Register a function that will be executed before the physics world is stepping forward
  20133. * @param func The function to execute before the physics world is stepped forward
  20134. */
  20135. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20136. /**
  20137. * Unregister a function that will be executed before the physics world is stepping forward
  20138. * @param func The function to execute before the physics world is stepped forward
  20139. */
  20140. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20141. /**
  20142. * Register a function that will be executed after the physics step
  20143. * @param func The function to execute after physics step
  20144. */
  20145. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20146. /**
  20147. * Unregisters a function that will be executed after the physics step
  20148. * @param func The function to execute after physics step
  20149. */
  20150. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20151. /**
  20152. * register a function that will be executed when this impostor collides against a different body
  20153. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20154. * @param func Callback that is executed on collision
  20155. */
  20156. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20157. /**
  20158. * Unregisters the physics imposter on contact
  20159. * @param collideAgainst The physics object to collide against
  20160. * @param func Callback to execute on collision
  20161. */
  20162. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20163. private _tmpQuat;
  20164. private _tmpQuat2;
  20165. /**
  20166. * Get the parent rotation
  20167. * @returns The parent rotation
  20168. */
  20169. getParentsRotation(): Quaternion;
  20170. /**
  20171. * this function is executed by the physics engine.
  20172. */
  20173. beforeStep: () => void;
  20174. /**
  20175. * this function is executed by the physics engine
  20176. */
  20177. afterStep: () => void;
  20178. /**
  20179. * Legacy collision detection event support
  20180. */
  20181. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20182. /**
  20183. * event and body object due to cannon's event-based architecture.
  20184. */
  20185. onCollide: (e: {
  20186. body: any;
  20187. }) => void;
  20188. /**
  20189. * Apply a force
  20190. * @param force The force to apply
  20191. * @param contactPoint The contact point for the force
  20192. * @returns The physics imposter
  20193. */
  20194. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20195. /**
  20196. * Apply an impulse
  20197. * @param force The impulse force
  20198. * @param contactPoint The contact point for the impulse force
  20199. * @returns The physics imposter
  20200. */
  20201. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20202. /**
  20203. * A help function to create a joint
  20204. * @param otherImpostor A physics imposter used to create a joint
  20205. * @param jointType The type of joint
  20206. * @param jointData The data for the joint
  20207. * @returns The physics imposter
  20208. */
  20209. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20210. /**
  20211. * Add a joint to this impostor with a different impostor
  20212. * @param otherImpostor A physics imposter used to add a joint
  20213. * @param joint The joint to add
  20214. * @returns The physics imposter
  20215. */
  20216. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20217. /**
  20218. * Will keep this body still, in a sleep mode.
  20219. * @returns the physics imposter
  20220. */
  20221. sleep(): PhysicsImpostor;
  20222. /**
  20223. * Wake the body up.
  20224. * @returns The physics imposter
  20225. */
  20226. wakeUp(): PhysicsImpostor;
  20227. /**
  20228. * Clones the physics imposter
  20229. * @param newObject The physics imposter clones to this physics-enabled object
  20230. * @returns A nullable physics imposter
  20231. */
  20232. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20233. /**
  20234. * Disposes the physics imposter
  20235. */
  20236. dispose(): void;
  20237. /**
  20238. * Sets the delta position
  20239. * @param position The delta position amount
  20240. */
  20241. setDeltaPosition(position: Vector3): void;
  20242. /**
  20243. * Sets the delta rotation
  20244. * @param rotation The delta rotation amount
  20245. */
  20246. setDeltaRotation(rotation: Quaternion): void;
  20247. /**
  20248. * Gets the box size of the physics imposter and stores the result in the input parameter
  20249. * @param result Stores the box size
  20250. * @returns The physics imposter
  20251. */
  20252. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20253. /**
  20254. * Gets the radius of the physics imposter
  20255. * @returns Radius of the physics imposter
  20256. */
  20257. getRadius(): number;
  20258. /**
  20259. * Sync a bone with this impostor
  20260. * @param bone The bone to sync to the impostor.
  20261. * @param boneMesh The mesh that the bone is influencing.
  20262. * @param jointPivot The pivot of the joint / bone in local space.
  20263. * @param distToJoint Optional distance from the impostor to the joint.
  20264. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20265. */
  20266. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20267. /**
  20268. * Sync impostor to a bone
  20269. * @param bone The bone that the impostor will be synced to.
  20270. * @param boneMesh The mesh that the bone is influencing.
  20271. * @param jointPivot The pivot of the joint / bone in local space.
  20272. * @param distToJoint Optional distance from the impostor to the joint.
  20273. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20274. * @param boneAxis Optional vector3 axis the bone is aligned with
  20275. */
  20276. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20277. /**
  20278. * No-Imposter type
  20279. */
  20280. static NoImpostor: number;
  20281. /**
  20282. * Sphere-Imposter type
  20283. */
  20284. static SphereImpostor: number;
  20285. /**
  20286. * Box-Imposter type
  20287. */
  20288. static BoxImpostor: number;
  20289. /**
  20290. * Plane-Imposter type
  20291. */
  20292. static PlaneImpostor: number;
  20293. /**
  20294. * Mesh-imposter type
  20295. */
  20296. static MeshImpostor: number;
  20297. /**
  20298. * Cylinder-Imposter type
  20299. */
  20300. static CylinderImpostor: number;
  20301. /**
  20302. * Particle-Imposter type
  20303. */
  20304. static ParticleImpostor: number;
  20305. /**
  20306. * Heightmap-Imposter type
  20307. */
  20308. static HeightmapImpostor: number;
  20309. }
  20310. }
  20311. declare module "babylonjs/Meshes/mesh" {
  20312. import { Observable } from "babylonjs/Misc/observable";
  20313. import { IAnimatable } from "babylonjs/Misc/tools";
  20314. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20315. import { Camera } from "babylonjs/Cameras/camera";
  20316. import { Scene } from "babylonjs/scene";
  20317. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20318. import { Engine } from "babylonjs/Engines/engine";
  20319. import { Node } from "babylonjs/node";
  20320. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20321. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20322. import { Buffer } from "babylonjs/Meshes/buffer";
  20323. import { Geometry } from "babylonjs/Meshes/geometry";
  20324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20325. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20326. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20327. import { Effect } from "babylonjs/Materials/effect";
  20328. import { Material } from "babylonjs/Materials/material";
  20329. import { Skeleton } from "babylonjs/Bones/skeleton";
  20330. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20331. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20332. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20333. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20334. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20335. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20336. /**
  20337. * Class used to represent a specific level of detail of a mesh
  20338. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20339. */
  20340. export class MeshLODLevel {
  20341. /** Defines the distance where this level should star being displayed */
  20342. distance: number;
  20343. /** Defines the mesh to use to render this level */
  20344. mesh: Nullable<Mesh>;
  20345. /**
  20346. * Creates a new LOD level
  20347. * @param distance defines the distance where this level should star being displayed
  20348. * @param mesh defines the mesh to use to render this level
  20349. */
  20350. constructor(
  20351. /** Defines the distance where this level should star being displayed */
  20352. distance: number,
  20353. /** Defines the mesh to use to render this level */
  20354. mesh: Nullable<Mesh>);
  20355. }
  20356. /**
  20357. * @hidden
  20358. **/
  20359. export class _CreationDataStorage {
  20360. closePath?: boolean;
  20361. closeArray?: boolean;
  20362. idx: number[];
  20363. dashSize: number;
  20364. gapSize: number;
  20365. path3D: Path3D;
  20366. pathArray: Vector3[][];
  20367. arc: number;
  20368. radius: number;
  20369. cap: number;
  20370. tessellation: number;
  20371. }
  20372. /**
  20373. * @hidden
  20374. **/
  20375. class _InstanceDataStorage {
  20376. visibleInstances: any;
  20377. renderIdForInstances: number[];
  20378. batchCache: _InstancesBatch;
  20379. instancesBufferSize: number;
  20380. instancesBuffer: Nullable<Buffer>;
  20381. instancesData: Float32Array;
  20382. overridenInstanceCount: number;
  20383. }
  20384. /**
  20385. * @hidden
  20386. **/
  20387. export class _InstancesBatch {
  20388. mustReturn: boolean;
  20389. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20390. renderSelf: boolean[];
  20391. }
  20392. /**
  20393. * Class used to represent renderable models
  20394. */
  20395. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20396. /**
  20397. * Mesh side orientation : usually the external or front surface
  20398. */
  20399. static readonly FRONTSIDE: number;
  20400. /**
  20401. * Mesh side orientation : usually the internal or back surface
  20402. */
  20403. static readonly BACKSIDE: number;
  20404. /**
  20405. * Mesh side orientation : both internal and external or front and back surfaces
  20406. */
  20407. static readonly DOUBLESIDE: number;
  20408. /**
  20409. * Mesh side orientation : by default, `FRONTSIDE`
  20410. */
  20411. static readonly DEFAULTSIDE: number;
  20412. /**
  20413. * Mesh cap setting : no cap
  20414. */
  20415. static readonly NO_CAP: number;
  20416. /**
  20417. * Mesh cap setting : one cap at the beginning of the mesh
  20418. */
  20419. static readonly CAP_START: number;
  20420. /**
  20421. * Mesh cap setting : one cap at the end of the mesh
  20422. */
  20423. static readonly CAP_END: number;
  20424. /**
  20425. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20426. */
  20427. static readonly CAP_ALL: number;
  20428. /**
  20429. * Gets the default side orientation.
  20430. * @param orientation the orientation to value to attempt to get
  20431. * @returns the default orientation
  20432. * @hidden
  20433. */
  20434. static _GetDefaultSideOrientation(orientation?: number): number;
  20435. private _onBeforeRenderObservable;
  20436. private _onBeforeBindObservable;
  20437. private _onAfterRenderObservable;
  20438. private _onBeforeDrawObservable;
  20439. /**
  20440. * An event triggered before rendering the mesh
  20441. */
  20442. readonly onBeforeRenderObservable: Observable<Mesh>;
  20443. /**
  20444. * An event triggered before binding the mesh
  20445. */
  20446. readonly onBeforeBindObservable: Observable<Mesh>;
  20447. /**
  20448. * An event triggered after rendering the mesh
  20449. */
  20450. readonly onAfterRenderObservable: Observable<Mesh>;
  20451. /**
  20452. * An event triggered before drawing the mesh
  20453. */
  20454. readonly onBeforeDrawObservable: Observable<Mesh>;
  20455. private _onBeforeDrawObserver;
  20456. /**
  20457. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20458. */
  20459. onBeforeDraw: () => void;
  20460. /**
  20461. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20462. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20463. */
  20464. delayLoadState: number;
  20465. /**
  20466. * Gets the list of instances created from this mesh
  20467. * it is not supposed to be modified manually.
  20468. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20469. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20470. */
  20471. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20472. /**
  20473. * Gets the file containing delay loading data for this mesh
  20474. */
  20475. delayLoadingFile: string;
  20476. /** @hidden */
  20477. _binaryInfo: any;
  20478. private _LODLevels;
  20479. /**
  20480. * User defined function used to change how LOD level selection is done
  20481. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20482. */
  20483. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20484. private _morphTargetManager;
  20485. /**
  20486. * Gets or sets the morph target manager
  20487. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20488. */
  20489. morphTargetManager: Nullable<MorphTargetManager>;
  20490. /** @hidden */
  20491. _creationDataStorage: Nullable<_CreationDataStorage>;
  20492. /** @hidden */
  20493. _geometry: Nullable<Geometry>;
  20494. /** @hidden */
  20495. _delayInfo: Array<string>;
  20496. /** @hidden */
  20497. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20498. /** @hidden */
  20499. _instanceDataStorage: _InstanceDataStorage;
  20500. private _effectiveMaterial;
  20501. /** @hidden */
  20502. _shouldGenerateFlatShading: boolean;
  20503. private _preActivateId;
  20504. /** @hidden */
  20505. _originalBuilderSideOrientation: number;
  20506. /**
  20507. * Use this property to change the original side orientation defined at construction time
  20508. */
  20509. overrideMaterialSideOrientation: Nullable<number>;
  20510. private _areNormalsFrozen;
  20511. private _sourcePositions;
  20512. private _sourceNormals;
  20513. private _source;
  20514. private meshMap;
  20515. /**
  20516. * Gets the source mesh (the one used to clone this one from)
  20517. */
  20518. readonly source: Nullable<Mesh>;
  20519. /**
  20520. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20521. */
  20522. isUnIndexed: boolean;
  20523. /**
  20524. * @constructor
  20525. * @param name The value used by scene.getMeshByName() to do a lookup.
  20526. * @param scene The scene to add this mesh to.
  20527. * @param parent The parent of this mesh, if it has one
  20528. * @param source An optional Mesh from which geometry is shared, cloned.
  20529. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20530. * When false, achieved by calling a clone(), also passing False.
  20531. * This will make creation of children, recursive.
  20532. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20533. */
  20534. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20535. /**
  20536. * Gets the class name
  20537. * @returns the string "Mesh".
  20538. */
  20539. getClassName(): string;
  20540. /** @hidden */
  20541. readonly _isMesh: boolean;
  20542. /**
  20543. * Returns a description of this mesh
  20544. * @param fullDetails define if full details about this mesh must be used
  20545. * @returns a descriptive string representing this mesh
  20546. */
  20547. toString(fullDetails?: boolean): string;
  20548. /** @hidden */
  20549. _unBindEffect(): void;
  20550. /**
  20551. * Gets a boolean indicating if this mesh has LOD
  20552. */
  20553. readonly hasLODLevels: boolean;
  20554. /**
  20555. * Gets the list of MeshLODLevel associated with the current mesh
  20556. * @returns an array of MeshLODLevel
  20557. */
  20558. getLODLevels(): MeshLODLevel[];
  20559. private _sortLODLevels;
  20560. /**
  20561. * Add a mesh as LOD level triggered at the given distance.
  20562. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20563. * @param distance The distance from the center of the object to show this level
  20564. * @param mesh The mesh to be added as LOD level (can be null)
  20565. * @return This mesh (for chaining)
  20566. */
  20567. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20568. /**
  20569. * Returns the LOD level mesh at the passed distance or null if not found.
  20570. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20571. * @param distance The distance from the center of the object to show this level
  20572. * @returns a Mesh or `null`
  20573. */
  20574. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20575. /**
  20576. * Remove a mesh from the LOD array
  20577. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20578. * @param mesh defines the mesh to be removed
  20579. * @return This mesh (for chaining)
  20580. */
  20581. removeLODLevel(mesh: Mesh): Mesh;
  20582. /**
  20583. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20584. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20585. * @param camera defines the camera to use to compute distance
  20586. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20587. * @return This mesh (for chaining)
  20588. */
  20589. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20590. /**
  20591. * Gets the mesh internal Geometry object
  20592. */
  20593. readonly geometry: Nullable<Geometry>;
  20594. /**
  20595. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20596. * @returns the total number of vertices
  20597. */
  20598. getTotalVertices(): number;
  20599. /**
  20600. * Returns the content of an associated vertex buffer
  20601. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20602. * - VertexBuffer.PositionKind
  20603. * - VertexBuffer.UVKind
  20604. * - VertexBuffer.UV2Kind
  20605. * - VertexBuffer.UV3Kind
  20606. * - VertexBuffer.UV4Kind
  20607. * - VertexBuffer.UV5Kind
  20608. * - VertexBuffer.UV6Kind
  20609. * - VertexBuffer.ColorKind
  20610. * - VertexBuffer.MatricesIndicesKind
  20611. * - VertexBuffer.MatricesIndicesExtraKind
  20612. * - VertexBuffer.MatricesWeightsKind
  20613. * - VertexBuffer.MatricesWeightsExtraKind
  20614. * @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
  20615. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20616. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20617. */
  20618. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20619. /**
  20620. * Returns the mesh VertexBuffer object from the requested `kind`
  20621. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20622. * - VertexBuffer.PositionKind
  20623. * - VertexBuffer.UVKind
  20624. * - VertexBuffer.UV2Kind
  20625. * - VertexBuffer.UV3Kind
  20626. * - VertexBuffer.UV4Kind
  20627. * - VertexBuffer.UV5Kind
  20628. * - VertexBuffer.UV6Kind
  20629. * - VertexBuffer.ColorKind
  20630. * - VertexBuffer.MatricesIndicesKind
  20631. * - VertexBuffer.MatricesIndicesExtraKind
  20632. * - VertexBuffer.MatricesWeightsKind
  20633. * - VertexBuffer.MatricesWeightsExtraKind
  20634. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20635. */
  20636. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20637. /**
  20638. * Tests if a specific vertex buffer is associated with this mesh
  20639. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20640. * - VertexBuffer.PositionKind
  20641. * - VertexBuffer.UVKind
  20642. * - VertexBuffer.UV2Kind
  20643. * - VertexBuffer.UV3Kind
  20644. * - VertexBuffer.UV4Kind
  20645. * - VertexBuffer.UV5Kind
  20646. * - VertexBuffer.UV6Kind
  20647. * - VertexBuffer.ColorKind
  20648. * - VertexBuffer.MatricesIndicesKind
  20649. * - VertexBuffer.MatricesIndicesExtraKind
  20650. * - VertexBuffer.MatricesWeightsKind
  20651. * - VertexBuffer.MatricesWeightsExtraKind
  20652. * @returns a boolean
  20653. */
  20654. isVerticesDataPresent(kind: string): boolean;
  20655. /**
  20656. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20657. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20658. * - VertexBuffer.PositionKind
  20659. * - VertexBuffer.UVKind
  20660. * - VertexBuffer.UV2Kind
  20661. * - VertexBuffer.UV3Kind
  20662. * - VertexBuffer.UV4Kind
  20663. * - VertexBuffer.UV5Kind
  20664. * - VertexBuffer.UV6Kind
  20665. * - VertexBuffer.ColorKind
  20666. * - VertexBuffer.MatricesIndicesKind
  20667. * - VertexBuffer.MatricesIndicesExtraKind
  20668. * - VertexBuffer.MatricesWeightsKind
  20669. * - VertexBuffer.MatricesWeightsExtraKind
  20670. * @returns a boolean
  20671. */
  20672. isVertexBufferUpdatable(kind: string): boolean;
  20673. /**
  20674. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20675. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20676. * - VertexBuffer.PositionKind
  20677. * - VertexBuffer.UVKind
  20678. * - VertexBuffer.UV2Kind
  20679. * - VertexBuffer.UV3Kind
  20680. * - VertexBuffer.UV4Kind
  20681. * - VertexBuffer.UV5Kind
  20682. * - VertexBuffer.UV6Kind
  20683. * - VertexBuffer.ColorKind
  20684. * - VertexBuffer.MatricesIndicesKind
  20685. * - VertexBuffer.MatricesIndicesExtraKind
  20686. * - VertexBuffer.MatricesWeightsKind
  20687. * - VertexBuffer.MatricesWeightsExtraKind
  20688. * @returns an array of strings
  20689. */
  20690. getVerticesDataKinds(): string[];
  20691. /**
  20692. * Returns a positive integer : the total number of indices in this mesh geometry.
  20693. * @returns the numner of indices or zero if the mesh has no geometry.
  20694. */
  20695. getTotalIndices(): number;
  20696. /**
  20697. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20698. * @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.
  20699. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20700. * @returns the indices array or an empty array if the mesh has no geometry
  20701. */
  20702. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20703. readonly isBlocked: boolean;
  20704. /**
  20705. * Determine if the current mesh is ready to be rendered
  20706. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20707. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20708. * @returns true if all associated assets are ready (material, textures, shaders)
  20709. */
  20710. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20711. /**
  20712. * 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.
  20713. */
  20714. readonly areNormalsFrozen: boolean;
  20715. /**
  20716. * 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.
  20717. * @returns the current mesh
  20718. */
  20719. freezeNormals(): Mesh;
  20720. /**
  20721. * 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
  20722. * @returns the current mesh
  20723. */
  20724. unfreezeNormals(): Mesh;
  20725. /**
  20726. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20727. */
  20728. overridenInstanceCount: number;
  20729. /** @hidden */
  20730. _preActivate(): Mesh;
  20731. /** @hidden */
  20732. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20733. /** @hidden */
  20734. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20735. /**
  20736. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20737. * This means the mesh underlying bounding box and sphere are recomputed.
  20738. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20739. * @returns the current mesh
  20740. */
  20741. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20742. /** @hidden */
  20743. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20744. /**
  20745. * This function will subdivide the mesh into multiple submeshes
  20746. * @param count defines the expected number of submeshes
  20747. */
  20748. subdivide(count: number): void;
  20749. /**
  20750. * Copy a FloatArray into a specific associated vertex buffer
  20751. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20752. * - VertexBuffer.PositionKind
  20753. * - VertexBuffer.UVKind
  20754. * - VertexBuffer.UV2Kind
  20755. * - VertexBuffer.UV3Kind
  20756. * - VertexBuffer.UV4Kind
  20757. * - VertexBuffer.UV5Kind
  20758. * - VertexBuffer.UV6Kind
  20759. * - VertexBuffer.ColorKind
  20760. * - VertexBuffer.MatricesIndicesKind
  20761. * - VertexBuffer.MatricesIndicesExtraKind
  20762. * - VertexBuffer.MatricesWeightsKind
  20763. * - VertexBuffer.MatricesWeightsExtraKind
  20764. * @param data defines the data source
  20765. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20766. * @param stride defines the data stride size (can be null)
  20767. * @returns the current mesh
  20768. */
  20769. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20770. /**
  20771. * Flags an associated vertex buffer as updatable
  20772. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20773. * - VertexBuffer.PositionKind
  20774. * - VertexBuffer.UVKind
  20775. * - VertexBuffer.UV2Kind
  20776. * - VertexBuffer.UV3Kind
  20777. * - VertexBuffer.UV4Kind
  20778. * - VertexBuffer.UV5Kind
  20779. * - VertexBuffer.UV6Kind
  20780. * - VertexBuffer.ColorKind
  20781. * - VertexBuffer.MatricesIndicesKind
  20782. * - VertexBuffer.MatricesIndicesExtraKind
  20783. * - VertexBuffer.MatricesWeightsKind
  20784. * - VertexBuffer.MatricesWeightsExtraKind
  20785. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20786. */
  20787. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20788. /**
  20789. * Sets the mesh global Vertex Buffer
  20790. * @param buffer defines the buffer to use
  20791. * @returns the current mesh
  20792. */
  20793. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20794. /**
  20795. * Update a specific associated vertex buffer
  20796. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20797. * - VertexBuffer.PositionKind
  20798. * - VertexBuffer.UVKind
  20799. * - VertexBuffer.UV2Kind
  20800. * - VertexBuffer.UV3Kind
  20801. * - VertexBuffer.UV4Kind
  20802. * - VertexBuffer.UV5Kind
  20803. * - VertexBuffer.UV6Kind
  20804. * - VertexBuffer.ColorKind
  20805. * - VertexBuffer.MatricesIndicesKind
  20806. * - VertexBuffer.MatricesIndicesExtraKind
  20807. * - VertexBuffer.MatricesWeightsKind
  20808. * - VertexBuffer.MatricesWeightsExtraKind
  20809. * @param data defines the data source
  20810. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20811. * @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)
  20812. * @returns the current mesh
  20813. */
  20814. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20815. /**
  20816. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20817. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20818. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20819. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20820. * @returns the current mesh
  20821. */
  20822. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20823. /**
  20824. * Creates a un-shared specific occurence of the geometry for the mesh.
  20825. * @returns the current mesh
  20826. */
  20827. makeGeometryUnique(): Mesh;
  20828. /**
  20829. * Set the index buffer of this mesh
  20830. * @param indices defines the source data
  20831. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20832. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20833. * @returns the current mesh
  20834. */
  20835. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20836. /**
  20837. * Update the current index buffer
  20838. * @param indices defines the source data
  20839. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20840. * @returns the current mesh
  20841. */
  20842. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20843. /**
  20844. * Invert the geometry to move from a right handed system to a left handed one.
  20845. * @returns the current mesh
  20846. */
  20847. toLeftHanded(): Mesh;
  20848. /** @hidden */
  20849. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20850. /** @hidden */
  20851. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20852. /**
  20853. * Registers for this mesh a javascript function called just before the rendering process
  20854. * @param func defines the function to call before rendering this mesh
  20855. * @returns the current mesh
  20856. */
  20857. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20858. /**
  20859. * Disposes a previously registered javascript function called before the rendering
  20860. * @param func defines the function to remove
  20861. * @returns the current mesh
  20862. */
  20863. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20864. /**
  20865. * Registers for this mesh a javascript function called just after the rendering is complete
  20866. * @param func defines the function to call after rendering this mesh
  20867. * @returns the current mesh
  20868. */
  20869. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20870. /**
  20871. * Disposes a previously registered javascript function called after the rendering.
  20872. * @param func defines the function to remove
  20873. * @returns the current mesh
  20874. */
  20875. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20876. /** @hidden */
  20877. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20878. /** @hidden */
  20879. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20880. /** @hidden */
  20881. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20882. /**
  20883. * 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
  20884. * @param subMesh defines the subMesh to render
  20885. * @param enableAlphaMode defines if alpha mode can be changed
  20886. * @returns the current mesh
  20887. */
  20888. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20889. private _onBeforeDraw;
  20890. /**
  20891. * Renormalize the mesh and patch it up if there are no weights
  20892. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20893. * However in the case of zero weights then we set just a single influence to 1.
  20894. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20895. */
  20896. cleanMatrixWeights(): void;
  20897. private normalizeSkinFourWeights;
  20898. private normalizeSkinWeightsAndExtra;
  20899. /**
  20900. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20901. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20902. * the user know there was an issue with importing the mesh
  20903. * @returns a validation object with skinned, valid and report string
  20904. */
  20905. validateSkinning(): {
  20906. skinned: boolean;
  20907. valid: boolean;
  20908. report: string;
  20909. };
  20910. /** @hidden */
  20911. _checkDelayState(): Mesh;
  20912. private _queueLoad;
  20913. /**
  20914. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20915. * A mesh is in the frustum if its bounding box intersects the frustum
  20916. * @param frustumPlanes defines the frustum to test
  20917. * @returns true if the mesh is in the frustum planes
  20918. */
  20919. isInFrustum(frustumPlanes: Plane[]): boolean;
  20920. /**
  20921. * Sets the mesh material by the material or multiMaterial `id` property
  20922. * @param id is a string identifying the material or the multiMaterial
  20923. * @returns the current mesh
  20924. */
  20925. setMaterialByID(id: string): Mesh;
  20926. /**
  20927. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20928. * @returns an array of IAnimatable
  20929. */
  20930. getAnimatables(): IAnimatable[];
  20931. /**
  20932. * Modifies the mesh geometry according to the passed transformation matrix.
  20933. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20934. * The mesh normals are modified using the same transformation.
  20935. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20936. * @param transform defines the transform matrix to use
  20937. * @see http://doc.babylonjs.com/resources/baking_transformations
  20938. * @returns the current mesh
  20939. */
  20940. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20941. /**
  20942. * Modifies the mesh geometry according to its own current World Matrix.
  20943. * The mesh World Matrix is then reset.
  20944. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20945. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20946. * @see http://doc.babylonjs.com/resources/baking_transformations
  20947. * @returns the current mesh
  20948. */
  20949. bakeCurrentTransformIntoVertices(): Mesh;
  20950. /** @hidden */
  20951. readonly _positions: Nullable<Vector3[]>;
  20952. /** @hidden */
  20953. _resetPointsArrayCache(): Mesh;
  20954. /** @hidden */
  20955. _generatePointsArray(): boolean;
  20956. /**
  20957. * Returns a new Mesh object generated from the current mesh properties.
  20958. * This method must not get confused with createInstance()
  20959. * @param name is a string, the name given to the new mesh
  20960. * @param newParent can be any Node object (default `null`)
  20961. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20962. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20963. * @returns a new mesh
  20964. */
  20965. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20966. /**
  20967. * Releases resources associated with this mesh.
  20968. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20969. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20970. */
  20971. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20972. /**
  20973. * Modifies the mesh geometry according to a displacement map.
  20974. * 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.
  20975. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20976. * @param url is a string, the URL from the image file is to be downloaded.
  20977. * @param minHeight is the lower limit of the displacement.
  20978. * @param maxHeight is the upper limit of the displacement.
  20979. * @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.
  20980. * @param uvOffset is an optional vector2 used to offset UV.
  20981. * @param uvScale is an optional vector2 used to scale UV.
  20982. * @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.
  20983. * @returns the Mesh.
  20984. */
  20985. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20986. /**
  20987. * Modifies the mesh geometry according to a displacementMap buffer.
  20988. * 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.
  20989. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20990. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20991. * @param heightMapWidth is the width of the buffer image.
  20992. * @param heightMapHeight is the height of the buffer image.
  20993. * @param minHeight is the lower limit of the displacement.
  20994. * @param maxHeight is the upper limit of the displacement.
  20995. * @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.
  20996. * @param uvOffset is an optional vector2 used to offset UV.
  20997. * @param uvScale is an optional vector2 used to scale UV.
  20998. * @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.
  20999. * @returns the Mesh.
  21000. */
  21001. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21002. /**
  21003. * Modify the mesh to get a flat shading rendering.
  21004. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21005. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21006. * @returns current mesh
  21007. */
  21008. convertToFlatShadedMesh(): Mesh;
  21009. /**
  21010. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21011. * In other words, more vertices, no more indices and a single bigger VBO.
  21012. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21013. * @returns current mesh
  21014. */
  21015. convertToUnIndexedMesh(): Mesh;
  21016. /**
  21017. * Inverses facet orientations.
  21018. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21019. * @param flipNormals will also inverts the normals
  21020. * @returns current mesh
  21021. */
  21022. flipFaces(flipNormals?: boolean): Mesh;
  21023. /** @hidden */
  21024. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21025. /** @hidden */
  21026. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21027. /**
  21028. * Creates a new InstancedMesh object from the mesh model.
  21029. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21030. * @param name defines the name of the new instance
  21031. * @returns a new InstancedMesh
  21032. */
  21033. createInstance(name: string): InstancedMesh;
  21034. /**
  21035. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21036. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21037. * @returns the current mesh
  21038. */
  21039. synchronizeInstances(): Mesh;
  21040. /**
  21041. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21042. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21043. * This should be used together with the simplification to avoid disappearing triangles.
  21044. * @param successCallback an optional success callback to be called after the optimization finished.
  21045. * @returns the current mesh
  21046. */
  21047. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21048. /**
  21049. * Serialize current mesh
  21050. * @param serializationObject defines the object which will receive the serialization data
  21051. */
  21052. serialize(serializationObject: any): void;
  21053. /** @hidden */
  21054. _syncGeometryWithMorphTargetManager(): void;
  21055. /** @hidden */
  21056. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21057. /**
  21058. * Returns a new Mesh object parsed from the source provided.
  21059. * @param parsedMesh is the source
  21060. * @param scene defines the hosting scene
  21061. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21062. * @returns a new Mesh
  21063. */
  21064. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21065. /**
  21066. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21067. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21068. * @param name defines the name of the mesh to create
  21069. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21070. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21071. * @param closePath creates a seam between the first and the last points of each path of the path array
  21072. * @param offset is taken in account only if the `pathArray` is containing a single path
  21073. * @param scene defines the hosting scene
  21074. * @param updatable defines if the mesh must be flagged as updatable
  21075. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21076. * @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)
  21077. * @returns a new Mesh
  21078. */
  21079. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21080. /**
  21081. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21082. * @param name defines the name of the mesh to create
  21083. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21084. * @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
  21085. * @param scene defines the hosting scene
  21086. * @param updatable defines if the mesh must be flagged as updatable
  21087. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21088. * @returns a new Mesh
  21089. */
  21090. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21091. /**
  21092. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21093. * @param name defines the name of the mesh to create
  21094. * @param size sets the size (float) of each box side (default 1)
  21095. * @param scene defines the hosting scene
  21096. * @param updatable defines if the mesh must be flagged as updatable
  21097. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21098. * @returns a new Mesh
  21099. */
  21100. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21101. /**
  21102. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21103. * @param name defines the name of the mesh to create
  21104. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21105. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21106. * @param scene defines the hosting scene
  21107. * @param updatable defines if the mesh must be flagged as updatable
  21108. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21109. * @returns a new Mesh
  21110. */
  21111. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21112. /**
  21113. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21114. * @param name defines the name of the mesh to create
  21115. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21116. * @param diameterTop set the top cap diameter (floats, default 1)
  21117. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21118. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21119. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21120. * @param scene defines the hosting scene
  21121. * @param updatable defines if the mesh must be flagged as updatable
  21122. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21123. * @returns a new Mesh
  21124. */
  21125. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21126. /**
  21127. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21128. * @param name defines the name of the mesh to create
  21129. * @param diameter sets the diameter size (float) of the torus (default 1)
  21130. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21131. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21132. * @param scene defines the hosting scene
  21133. * @param updatable defines if the mesh must be flagged as updatable
  21134. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21135. * @returns a new Mesh
  21136. */
  21137. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21138. /**
  21139. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21140. * @param name defines the name of the mesh to create
  21141. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21142. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21143. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21144. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21145. * @param p the number of windings on X axis (positive integers, default 2)
  21146. * @param q the number of windings on Y axis (positive integers, default 3)
  21147. * @param scene defines the hosting scene
  21148. * @param updatable defines if the mesh must be flagged as updatable
  21149. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21150. * @returns a new Mesh
  21151. */
  21152. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21153. /**
  21154. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21155. * @param name defines the name of the mesh to create
  21156. * @param points is an array successive Vector3
  21157. * @param scene defines the hosting scene
  21158. * @param updatable defines if the mesh must be flagged as updatable
  21159. * @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).
  21160. * @returns a new Mesh
  21161. */
  21162. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21163. /**
  21164. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21165. * @param name defines the name of the mesh to create
  21166. * @param points is an array successive Vector3
  21167. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21168. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21169. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21170. * @param scene defines the hosting scene
  21171. * @param updatable defines if the mesh must be flagged as updatable
  21172. * @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)
  21173. * @returns a new Mesh
  21174. */
  21175. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21176. /**
  21177. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21178. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21179. * 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.
  21180. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21181. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21182. * Remember you can only change the shape positions, not their number when updating a polygon.
  21183. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21184. * @param name defines the name of the mesh to create
  21185. * @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
  21186. * @param scene defines the hosting scene
  21187. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21188. * @param updatable defines if the mesh must be flagged as updatable
  21189. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21190. * @param earcutInjection can be used to inject your own earcut reference
  21191. * @returns a new Mesh
  21192. */
  21193. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21194. /**
  21195. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21196. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21197. * @param name defines the name of the mesh to create
  21198. * @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
  21199. * @param depth defines the height of extrusion
  21200. * @param scene defines the hosting scene
  21201. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21202. * @param updatable defines if the mesh must be flagged as updatable
  21203. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21204. * @param earcutInjection can be used to inject your own earcut reference
  21205. * @returns a new Mesh
  21206. */
  21207. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21208. /**
  21209. * Creates an extruded shape mesh.
  21210. * 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
  21211. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21212. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21213. * @param name defines the name of the mesh to create
  21214. * @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
  21215. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21216. * @param scale is the value to scale the shape
  21217. * @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
  21218. * @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
  21219. * @param scene defines the hosting scene
  21220. * @param updatable defines if the mesh must be flagged as updatable
  21221. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21222. * @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)
  21223. * @returns a new Mesh
  21224. */
  21225. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21226. /**
  21227. * Creates an custom extruded shape mesh.
  21228. * The custom extrusion is a parametric shape.
  21229. * It has no predefined shape. Its final shape will depend on the input parameters.
  21230. * Please consider using the same method from the MeshBuilder class instead
  21231. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21232. * @param name defines the name of the mesh to create
  21233. * @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
  21234. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21235. * @param scaleFunction is a custom Javascript function called on each path point
  21236. * @param rotationFunction is a custom Javascript function called on each path point
  21237. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21238. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21239. * @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
  21240. * @param scene defines the hosting scene
  21241. * @param updatable defines if the mesh must be flagged as updatable
  21242. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21243. * @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)
  21244. * @returns a new Mesh
  21245. */
  21246. 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;
  21247. /**
  21248. * Creates lathe mesh.
  21249. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21250. * Please consider using the same method from the MeshBuilder class instead
  21251. * @param name defines the name of the mesh to create
  21252. * @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
  21253. * @param radius is the radius value of the lathe
  21254. * @param tessellation is the side number of the lathe.
  21255. * @param scene defines the hosting scene
  21256. * @param updatable defines if the mesh must be flagged as updatable
  21257. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21258. * @returns a new Mesh
  21259. */
  21260. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21261. /**
  21262. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21263. * @param name defines the name of the mesh to create
  21264. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21265. * @param scene defines the hosting scene
  21266. * @param updatable defines if the mesh must be flagged as updatable
  21267. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21268. * @returns a new Mesh
  21269. */
  21270. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21271. /**
  21272. * Creates a ground mesh.
  21273. * Please consider using the same method from the MeshBuilder class instead
  21274. * @param name defines the name of the mesh to create
  21275. * @param width set the width of the ground
  21276. * @param height set the height of the ground
  21277. * @param subdivisions sets the number of subdivisions per side
  21278. * @param scene defines the hosting scene
  21279. * @param updatable defines if the mesh must be flagged as updatable
  21280. * @returns a new Mesh
  21281. */
  21282. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21283. /**
  21284. * Creates a tiled ground mesh.
  21285. * Please consider using the same method from the MeshBuilder class instead
  21286. * @param name defines the name of the mesh to create
  21287. * @param xmin set the ground minimum X coordinate
  21288. * @param zmin set the ground minimum Y coordinate
  21289. * @param xmax set the ground maximum X coordinate
  21290. * @param zmax set the ground maximum Z coordinate
  21291. * @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
  21292. * @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
  21293. * @param scene defines the hosting scene
  21294. * @param updatable defines if the mesh must be flagged as updatable
  21295. * @returns a new Mesh
  21296. */
  21297. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21298. w: number;
  21299. h: number;
  21300. }, precision: {
  21301. w: number;
  21302. h: number;
  21303. }, scene: Scene, updatable?: boolean): Mesh;
  21304. /**
  21305. * Creates a ground mesh from a height map.
  21306. * Please consider using the same method from the MeshBuilder class instead
  21307. * @see http://doc.babylonjs.com/babylon101/height_map
  21308. * @param name defines the name of the mesh to create
  21309. * @param url sets the URL of the height map image resource
  21310. * @param width set the ground width size
  21311. * @param height set the ground height size
  21312. * @param subdivisions sets the number of subdivision per side
  21313. * @param minHeight is the minimum altitude on the ground
  21314. * @param maxHeight is the maximum altitude on the ground
  21315. * @param scene defines the hosting scene
  21316. * @param updatable defines if the mesh must be flagged as updatable
  21317. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21318. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21319. * @returns a new Mesh
  21320. */
  21321. 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;
  21322. /**
  21323. * Creates a tube mesh.
  21324. * The tube is a parametric shape.
  21325. * It has no predefined shape. Its final shape will depend on the input parameters.
  21326. * Please consider using the same method from the MeshBuilder class instead
  21327. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21328. * @param name defines the name of the mesh to create
  21329. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21330. * @param radius sets the tube radius size
  21331. * @param tessellation is the number of sides on the tubular surface
  21332. * @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
  21333. * @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
  21334. * @param scene defines the hosting scene
  21335. * @param updatable defines if the mesh must be flagged as updatable
  21336. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21337. * @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)
  21338. * @returns a new Mesh
  21339. */
  21340. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21341. (i: number, distance: number): number;
  21342. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21343. /**
  21344. * Creates a polyhedron mesh.
  21345. * Please consider using the same method from the MeshBuilder class instead.
  21346. * * 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
  21347. * * The parameter `size` (positive float, default 1) sets the polygon size
  21348. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21349. * * 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`
  21350. * * 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
  21351. * * 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)`)
  21352. * * 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
  21353. * * 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
  21354. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21355. * * If you create a double-sided mesh, you can choose what parts of 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
  21356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21357. * @param name defines the name of the mesh to create
  21358. * @param options defines the options used to create the mesh
  21359. * @param scene defines the hosting scene
  21360. * @returns a new Mesh
  21361. */
  21362. static CreatePolyhedron(name: string, options: {
  21363. type?: number;
  21364. size?: number;
  21365. sizeX?: number;
  21366. sizeY?: number;
  21367. sizeZ?: number;
  21368. custom?: any;
  21369. faceUV?: Vector4[];
  21370. faceColors?: Color4[];
  21371. updatable?: boolean;
  21372. sideOrientation?: number;
  21373. }, scene: Scene): Mesh;
  21374. /**
  21375. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21376. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21377. * * 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`)
  21378. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21379. * * 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
  21380. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21381. * * If you create a double-sided mesh, you can choose what parts of 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
  21382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21383. * @param name defines the name of the mesh
  21384. * @param options defines the options used to create the mesh
  21385. * @param scene defines the hosting scene
  21386. * @returns a new Mesh
  21387. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21388. */
  21389. static CreateIcoSphere(name: string, options: {
  21390. radius?: number;
  21391. flat?: boolean;
  21392. subdivisions?: number;
  21393. sideOrientation?: number;
  21394. updatable?: boolean;
  21395. }, scene: Scene): Mesh;
  21396. /**
  21397. * Creates a decal mesh.
  21398. * Please consider using the same method from the MeshBuilder class instead.
  21399. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21400. * @param name defines the name of the mesh
  21401. * @param sourceMesh defines the mesh receiving the decal
  21402. * @param position sets the position of the decal in world coordinates
  21403. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21404. * @param size sets the decal scaling
  21405. * @param angle sets the angle to rotate the decal
  21406. * @returns a new Mesh
  21407. */
  21408. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21409. /**
  21410. * Prepare internal position array for software CPU skinning
  21411. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21412. */
  21413. setPositionsForCPUSkinning(): Float32Array;
  21414. /**
  21415. * Prepare internal normal array for software CPU skinning
  21416. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21417. */
  21418. setNormalsForCPUSkinning(): Float32Array;
  21419. /**
  21420. * Updates the vertex buffer by applying transformation from the bones
  21421. * @param skeleton defines the skeleton to apply to current mesh
  21422. * @returns the current mesh
  21423. */
  21424. applySkeleton(skeleton: Skeleton): Mesh;
  21425. /**
  21426. * 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
  21427. * @param meshes defines the list of meshes to scan
  21428. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21429. */
  21430. static MinMax(meshes: AbstractMesh[]): {
  21431. min: Vector3;
  21432. max: Vector3;
  21433. };
  21434. /**
  21435. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21436. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21437. * @returns a vector3
  21438. */
  21439. static Center(meshesOrMinMaxVector: {
  21440. min: Vector3;
  21441. max: Vector3;
  21442. } | AbstractMesh[]): Vector3;
  21443. /**
  21444. * Merge the array of meshes into a single mesh for performance reasons.
  21445. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21446. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21447. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21448. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21449. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21450. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21451. * @returns a new mesh
  21452. */
  21453. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21454. /** @hidden */
  21455. addInstance(instance: InstancedMesh): void;
  21456. /** @hidden */
  21457. removeInstance(instance: InstancedMesh): void;
  21458. }
  21459. }
  21460. declare module "babylonjs/Materials/material" {
  21461. import { IAnimatable } from "babylonjs/Misc/tools";
  21462. import { SmartArray } from "babylonjs/Misc/smartArray";
  21463. import { Observable } from "babylonjs/Misc/observable";
  21464. import { Nullable } from "babylonjs/types";
  21465. import { Scene } from "babylonjs/scene";
  21466. import { Matrix } from "babylonjs/Maths/math";
  21467. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21469. import { Mesh } from "babylonjs/Meshes/mesh";
  21470. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21471. import { Effect } from "babylonjs/Materials/effect";
  21472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21473. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21474. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21475. import { Animation } from "babylonjs/Animations/animation";
  21476. /**
  21477. * Base class for the main features of a material in Babylon.js
  21478. */
  21479. export class Material implements IAnimatable {
  21480. /**
  21481. * Returns the triangle fill mode
  21482. */
  21483. static readonly TriangleFillMode: number;
  21484. /**
  21485. * Returns the wireframe mode
  21486. */
  21487. static readonly WireFrameFillMode: number;
  21488. /**
  21489. * Returns the point fill mode
  21490. */
  21491. static readonly PointFillMode: number;
  21492. /**
  21493. * Returns the point list draw mode
  21494. */
  21495. static readonly PointListDrawMode: number;
  21496. /**
  21497. * Returns the line list draw mode
  21498. */
  21499. static readonly LineListDrawMode: number;
  21500. /**
  21501. * Returns the line loop draw mode
  21502. */
  21503. static readonly LineLoopDrawMode: number;
  21504. /**
  21505. * Returns the line strip draw mode
  21506. */
  21507. static readonly LineStripDrawMode: number;
  21508. /**
  21509. * Returns the triangle strip draw mode
  21510. */
  21511. static readonly TriangleStripDrawMode: number;
  21512. /**
  21513. * Returns the triangle fan draw mode
  21514. */
  21515. static readonly TriangleFanDrawMode: number;
  21516. /**
  21517. * Stores the clock-wise side orientation
  21518. */
  21519. static readonly ClockWiseSideOrientation: number;
  21520. /**
  21521. * Stores the counter clock-wise side orientation
  21522. */
  21523. static readonly CounterClockWiseSideOrientation: number;
  21524. /**
  21525. * The dirty texture flag value
  21526. */
  21527. static readonly TextureDirtyFlag: number;
  21528. /**
  21529. * The dirty light flag value
  21530. */
  21531. static readonly LightDirtyFlag: number;
  21532. /**
  21533. * The dirty fresnel flag value
  21534. */
  21535. static readonly FresnelDirtyFlag: number;
  21536. /**
  21537. * The dirty attribute flag value
  21538. */
  21539. static readonly AttributesDirtyFlag: number;
  21540. /**
  21541. * The dirty misc flag value
  21542. */
  21543. static readonly MiscDirtyFlag: number;
  21544. /**
  21545. * The all dirty flag value
  21546. */
  21547. static readonly AllDirtyFlag: number;
  21548. /**
  21549. * The ID of the material
  21550. */
  21551. id: string;
  21552. /**
  21553. * Gets or sets the unique id of the material
  21554. */
  21555. uniqueId: number;
  21556. /**
  21557. * The name of the material
  21558. */
  21559. name: string;
  21560. /**
  21561. * Gets or sets user defined metadata
  21562. */
  21563. metadata: any;
  21564. /**
  21565. * For internal use only. Please do not use.
  21566. */
  21567. reservedDataStore: any;
  21568. /**
  21569. * Specifies if the ready state should be checked on each call
  21570. */
  21571. checkReadyOnEveryCall: boolean;
  21572. /**
  21573. * Specifies if the ready state should be checked once
  21574. */
  21575. checkReadyOnlyOnce: boolean;
  21576. /**
  21577. * The state of the material
  21578. */
  21579. state: string;
  21580. /**
  21581. * The alpha value of the material
  21582. */
  21583. protected _alpha: number;
  21584. /**
  21585. * Sets the alpha value of the material
  21586. */
  21587. /**
  21588. * Gets the alpha value of the material
  21589. */
  21590. alpha: number;
  21591. /**
  21592. * Specifies if back face culling is enabled
  21593. */
  21594. protected _backFaceCulling: boolean;
  21595. /**
  21596. * Sets the back-face culling state
  21597. */
  21598. /**
  21599. * Gets the back-face culling state
  21600. */
  21601. backFaceCulling: boolean;
  21602. /**
  21603. * Stores the value for side orientation
  21604. */
  21605. sideOrientation: number;
  21606. /**
  21607. * Callback triggered when the material is compiled
  21608. */
  21609. onCompiled: (effect: Effect) => void;
  21610. /**
  21611. * Callback triggered when an error occurs
  21612. */
  21613. onError: (effect: Effect, errors: string) => void;
  21614. /**
  21615. * Callback triggered to get the render target textures
  21616. */
  21617. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21618. /**
  21619. * Gets a boolean indicating that current material needs to register RTT
  21620. */
  21621. readonly hasRenderTargetTextures: boolean;
  21622. /**
  21623. * Specifies if the material should be serialized
  21624. */
  21625. doNotSerialize: boolean;
  21626. /**
  21627. * @hidden
  21628. */
  21629. _storeEffectOnSubMeshes: boolean;
  21630. /**
  21631. * Stores the animations for the material
  21632. */
  21633. animations: Array<Animation>;
  21634. /**
  21635. * An event triggered when the material is disposed
  21636. */
  21637. onDisposeObservable: Observable<Material>;
  21638. /**
  21639. * An observer which watches for dispose events
  21640. */
  21641. private _onDisposeObserver;
  21642. private _onUnBindObservable;
  21643. /**
  21644. * Called during a dispose event
  21645. */
  21646. onDispose: () => void;
  21647. private _onBindObservable;
  21648. /**
  21649. * An event triggered when the material is bound
  21650. */
  21651. readonly onBindObservable: Observable<AbstractMesh>;
  21652. /**
  21653. * An observer which watches for bind events
  21654. */
  21655. private _onBindObserver;
  21656. /**
  21657. * Called during a bind event
  21658. */
  21659. onBind: (Mesh: AbstractMesh) => void;
  21660. /**
  21661. * An event triggered when the material is unbound
  21662. */
  21663. readonly onUnBindObservable: Observable<Material>;
  21664. /**
  21665. * Stores the value of the alpha mode
  21666. */
  21667. private _alphaMode;
  21668. /**
  21669. * Sets the value of the alpha mode.
  21670. *
  21671. * | Value | Type | Description |
  21672. * | --- | --- | --- |
  21673. * | 0 | ALPHA_DISABLE | |
  21674. * | 1 | ALPHA_ADD | |
  21675. * | 2 | ALPHA_COMBINE | |
  21676. * | 3 | ALPHA_SUBTRACT | |
  21677. * | 4 | ALPHA_MULTIPLY | |
  21678. * | 5 | ALPHA_MAXIMIZED | |
  21679. * | 6 | ALPHA_ONEONE | |
  21680. * | 7 | ALPHA_PREMULTIPLIED | |
  21681. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21682. * | 9 | ALPHA_INTERPOLATE | |
  21683. * | 10 | ALPHA_SCREENMODE | |
  21684. *
  21685. */
  21686. /**
  21687. * Gets the value of the alpha mode
  21688. */
  21689. alphaMode: number;
  21690. /**
  21691. * Stores the state of the need depth pre-pass value
  21692. */
  21693. private _needDepthPrePass;
  21694. /**
  21695. * Sets the need depth pre-pass value
  21696. */
  21697. /**
  21698. * Gets the depth pre-pass value
  21699. */
  21700. needDepthPrePass: boolean;
  21701. /**
  21702. * Specifies if depth writing should be disabled
  21703. */
  21704. disableDepthWrite: boolean;
  21705. /**
  21706. * Specifies if depth writing should be forced
  21707. */
  21708. forceDepthWrite: boolean;
  21709. /**
  21710. * Specifies if there should be a separate pass for culling
  21711. */
  21712. separateCullingPass: boolean;
  21713. /**
  21714. * Stores the state specifing if fog should be enabled
  21715. */
  21716. private _fogEnabled;
  21717. /**
  21718. * Sets the state for enabling fog
  21719. */
  21720. /**
  21721. * Gets the value of the fog enabled state
  21722. */
  21723. fogEnabled: boolean;
  21724. /**
  21725. * Stores the size of points
  21726. */
  21727. pointSize: number;
  21728. /**
  21729. * Stores the z offset value
  21730. */
  21731. zOffset: number;
  21732. /**
  21733. * Gets a value specifying if wireframe mode is enabled
  21734. */
  21735. /**
  21736. * Sets the state of wireframe mode
  21737. */
  21738. wireframe: boolean;
  21739. /**
  21740. * Gets the value specifying if point clouds are enabled
  21741. */
  21742. /**
  21743. * Sets the state of point cloud mode
  21744. */
  21745. pointsCloud: boolean;
  21746. /**
  21747. * Gets the material fill mode
  21748. */
  21749. /**
  21750. * Sets the material fill mode
  21751. */
  21752. fillMode: number;
  21753. /**
  21754. * @hidden
  21755. * Stores the effects for the material
  21756. */
  21757. _effect: Nullable<Effect>;
  21758. /**
  21759. * @hidden
  21760. * Specifies if the material was previously ready
  21761. */
  21762. _wasPreviouslyReady: boolean;
  21763. /**
  21764. * Specifies if uniform buffers should be used
  21765. */
  21766. private _useUBO;
  21767. /**
  21768. * Stores a reference to the scene
  21769. */
  21770. private _scene;
  21771. /**
  21772. * Stores the fill mode state
  21773. */
  21774. private _fillMode;
  21775. /**
  21776. * Specifies if the depth write state should be cached
  21777. */
  21778. private _cachedDepthWriteState;
  21779. /**
  21780. * Stores the uniform buffer
  21781. */
  21782. protected _uniformBuffer: UniformBuffer;
  21783. /** @hidden */
  21784. _indexInSceneMaterialArray: number;
  21785. /** @hidden */
  21786. meshMap: Nullable<{
  21787. [id: string]: AbstractMesh | undefined;
  21788. }>;
  21789. /**
  21790. * Creates a material instance
  21791. * @param name defines the name of the material
  21792. * @param scene defines the scene to reference
  21793. * @param doNotAdd specifies if the material should be added to the scene
  21794. */
  21795. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21796. /**
  21797. * Returns a string representation of the current material
  21798. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21799. * @returns a string with material information
  21800. */
  21801. toString(fullDetails?: boolean): string;
  21802. /**
  21803. * Gets the class name of the material
  21804. * @returns a string with the class name of the material
  21805. */
  21806. getClassName(): string;
  21807. /**
  21808. * Specifies if updates for the material been locked
  21809. */
  21810. readonly isFrozen: boolean;
  21811. /**
  21812. * Locks updates for the material
  21813. */
  21814. freeze(): void;
  21815. /**
  21816. * Unlocks updates for the material
  21817. */
  21818. unfreeze(): void;
  21819. /**
  21820. * Specifies if the material is ready to be used
  21821. * @param mesh defines the mesh to check
  21822. * @param useInstances specifies if instances should be used
  21823. * @returns a boolean indicating if the material is ready to be used
  21824. */
  21825. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21826. /**
  21827. * Specifies that the submesh is ready to be used
  21828. * @param mesh defines the mesh to check
  21829. * @param subMesh defines which submesh to check
  21830. * @param useInstances specifies that instances should be used
  21831. * @returns a boolean indicating that the submesh is ready or not
  21832. */
  21833. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21834. /**
  21835. * Returns the material effect
  21836. * @returns the effect associated with the material
  21837. */
  21838. getEffect(): Nullable<Effect>;
  21839. /**
  21840. * Returns the current scene
  21841. * @returns a Scene
  21842. */
  21843. getScene(): Scene;
  21844. /**
  21845. * Specifies if the material will require alpha blending
  21846. * @returns a boolean specifying if alpha blending is needed
  21847. */
  21848. needAlphaBlending(): boolean;
  21849. /**
  21850. * Specifies if the mesh will require alpha blending
  21851. * @param mesh defines the mesh to check
  21852. * @returns a boolean specifying if alpha blending is needed for the mesh
  21853. */
  21854. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21855. /**
  21856. * Specifies if this material should be rendered in alpha test mode
  21857. * @returns a boolean specifying if an alpha test is needed.
  21858. */
  21859. needAlphaTesting(): boolean;
  21860. /**
  21861. * Gets the texture used for the alpha test
  21862. * @returns the texture to use for alpha testing
  21863. */
  21864. getAlphaTestTexture(): Nullable<BaseTexture>;
  21865. /**
  21866. * Marks the material to indicate that it needs to be re-calculated
  21867. */
  21868. markDirty(): void;
  21869. /** @hidden */
  21870. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21871. /**
  21872. * Binds the material to the mesh
  21873. * @param world defines the world transformation matrix
  21874. * @param mesh defines the mesh to bind the material to
  21875. */
  21876. bind(world: Matrix, mesh?: Mesh): void;
  21877. /**
  21878. * Binds the submesh to the material
  21879. * @param world defines the world transformation matrix
  21880. * @param mesh defines the mesh containing the submesh
  21881. * @param subMesh defines the submesh to bind the material to
  21882. */
  21883. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21884. /**
  21885. * Binds the world matrix to the material
  21886. * @param world defines the world transformation matrix
  21887. */
  21888. bindOnlyWorldMatrix(world: Matrix): void;
  21889. /**
  21890. * Binds the scene's uniform buffer to the effect.
  21891. * @param effect defines the effect to bind to the scene uniform buffer
  21892. * @param sceneUbo defines the uniform buffer storing scene data
  21893. */
  21894. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21895. /**
  21896. * Binds the view matrix to the effect
  21897. * @param effect defines the effect to bind the view matrix to
  21898. */
  21899. bindView(effect: Effect): void;
  21900. /**
  21901. * Binds the view projection matrix to the effect
  21902. * @param effect defines the effect to bind the view projection matrix to
  21903. */
  21904. bindViewProjection(effect: Effect): void;
  21905. /**
  21906. * Specifies if material alpha testing should be turned on for the mesh
  21907. * @param mesh defines the mesh to check
  21908. */
  21909. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21910. /**
  21911. * Processes to execute after binding the material to a mesh
  21912. * @param mesh defines the rendered mesh
  21913. */
  21914. protected _afterBind(mesh?: Mesh): void;
  21915. /**
  21916. * Unbinds the material from the mesh
  21917. */
  21918. unbind(): void;
  21919. /**
  21920. * Gets the active textures from the material
  21921. * @returns an array of textures
  21922. */
  21923. getActiveTextures(): BaseTexture[];
  21924. /**
  21925. * Specifies if the material uses a texture
  21926. * @param texture defines the texture to check against the material
  21927. * @returns a boolean specifying if the material uses the texture
  21928. */
  21929. hasTexture(texture: BaseTexture): boolean;
  21930. /**
  21931. * Makes a duplicate of the material, and gives it a new name
  21932. * @param name defines the new name for the duplicated material
  21933. * @returns the cloned material
  21934. */
  21935. clone(name: string): Nullable<Material>;
  21936. /**
  21937. * Gets the meshes bound to the material
  21938. * @returns an array of meshes bound to the material
  21939. */
  21940. getBindedMeshes(): AbstractMesh[];
  21941. /**
  21942. * Force shader compilation
  21943. * @param mesh defines the mesh associated with this material
  21944. * @param onCompiled defines a function to execute once the material is compiled
  21945. * @param options defines the options to configure the compilation
  21946. */
  21947. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21948. clipPlane: boolean;
  21949. }>): void;
  21950. /**
  21951. * Force shader compilation
  21952. * @param mesh defines the mesh that will use this material
  21953. * @param options defines additional options for compiling the shaders
  21954. * @returns a promise that resolves when the compilation completes
  21955. */
  21956. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21957. clipPlane: boolean;
  21958. }>): Promise<void>;
  21959. private static readonly _ImageProcessingDirtyCallBack;
  21960. private static readonly _TextureDirtyCallBack;
  21961. private static readonly _FresnelDirtyCallBack;
  21962. private static readonly _MiscDirtyCallBack;
  21963. private static readonly _LightsDirtyCallBack;
  21964. private static readonly _AttributeDirtyCallBack;
  21965. private static _FresnelAndMiscDirtyCallBack;
  21966. private static _TextureAndMiscDirtyCallBack;
  21967. private static readonly _DirtyCallbackArray;
  21968. private static readonly _RunDirtyCallBacks;
  21969. /**
  21970. * Marks a define in the material to indicate that it needs to be re-computed
  21971. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21972. */
  21973. markAsDirty(flag: number): void;
  21974. /**
  21975. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21976. * @param func defines a function which checks material defines against the submeshes
  21977. */
  21978. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21979. /**
  21980. * Indicates that image processing needs to be re-calculated for all submeshes
  21981. */
  21982. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21983. /**
  21984. * Indicates that textures need to be re-calculated for all submeshes
  21985. */
  21986. protected _markAllSubMeshesAsTexturesDirty(): void;
  21987. /**
  21988. * Indicates that fresnel needs to be re-calculated for all submeshes
  21989. */
  21990. protected _markAllSubMeshesAsFresnelDirty(): void;
  21991. /**
  21992. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21993. */
  21994. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21995. /**
  21996. * Indicates that lights need to be re-calculated for all submeshes
  21997. */
  21998. protected _markAllSubMeshesAsLightsDirty(): void;
  21999. /**
  22000. * Indicates that attributes need to be re-calculated for all submeshes
  22001. */
  22002. protected _markAllSubMeshesAsAttributesDirty(): void;
  22003. /**
  22004. * Indicates that misc needs to be re-calculated for all submeshes
  22005. */
  22006. protected _markAllSubMeshesAsMiscDirty(): void;
  22007. /**
  22008. * Indicates that textures and misc need to be re-calculated for all submeshes
  22009. */
  22010. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22011. /**
  22012. * Disposes the material
  22013. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22014. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22015. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22016. */
  22017. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22018. /** @hidden */
  22019. private releaseVertexArrayObject;
  22020. /**
  22021. * Serializes this material
  22022. * @returns the serialized material object
  22023. */
  22024. serialize(): any;
  22025. /**
  22026. * Creates a material from parsed material data
  22027. * @param parsedMaterial defines parsed material data
  22028. * @param scene defines the hosting scene
  22029. * @param rootUrl defines the root URL to use to load textures
  22030. * @returns a new material
  22031. */
  22032. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22033. }
  22034. }
  22035. declare module "babylonjs/Meshes/subMesh" {
  22036. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22037. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22038. import { Engine } from "babylonjs/Engines/engine";
  22039. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22040. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22041. import { Effect } from "babylonjs/Materials/effect";
  22042. import { Collider } from "babylonjs/Collisions/collider";
  22043. import { Material } from "babylonjs/Materials/material";
  22044. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22046. import { Mesh } from "babylonjs/Meshes/mesh";
  22047. import { Ray } from "babylonjs/Culling/ray";
  22048. /**
  22049. * Base class for submeshes
  22050. */
  22051. export class BaseSubMesh {
  22052. /** @hidden */
  22053. _materialDefines: Nullable<MaterialDefines>;
  22054. /** @hidden */
  22055. _materialEffect: Nullable<Effect>;
  22056. /**
  22057. * Gets associated effect
  22058. */
  22059. readonly effect: Nullable<Effect>;
  22060. /**
  22061. * Sets associated effect (effect used to render this submesh)
  22062. * @param effect defines the effect to associate with
  22063. * @param defines defines the set of defines used to compile this effect
  22064. */
  22065. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22066. }
  22067. /**
  22068. * Defines a subdivision inside a mesh
  22069. */
  22070. export class SubMesh extends BaseSubMesh implements ICullable {
  22071. /** the material index to use */
  22072. materialIndex: number;
  22073. /** vertex index start */
  22074. verticesStart: number;
  22075. /** vertices count */
  22076. verticesCount: number;
  22077. /** index start */
  22078. indexStart: number;
  22079. /** indices count */
  22080. indexCount: number;
  22081. /** @hidden */
  22082. _linesIndexCount: number;
  22083. private _mesh;
  22084. private _renderingMesh;
  22085. private _boundingInfo;
  22086. private _linesIndexBuffer;
  22087. /** @hidden */
  22088. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22089. /** @hidden */
  22090. _trianglePlanes: Plane[];
  22091. /** @hidden */
  22092. _lastColliderTransformMatrix: Matrix;
  22093. /** @hidden */
  22094. _renderId: number;
  22095. /** @hidden */
  22096. _alphaIndex: number;
  22097. /** @hidden */
  22098. _distanceToCamera: number;
  22099. /** @hidden */
  22100. _id: number;
  22101. private _currentMaterial;
  22102. /**
  22103. * Add a new submesh to a mesh
  22104. * @param materialIndex defines the material index to use
  22105. * @param verticesStart defines vertex index start
  22106. * @param verticesCount defines vertices count
  22107. * @param indexStart defines index start
  22108. * @param indexCount defines indices count
  22109. * @param mesh defines the parent mesh
  22110. * @param renderingMesh defines an optional rendering mesh
  22111. * @param createBoundingBox defines if bounding box should be created for this submesh
  22112. * @returns the new submesh
  22113. */
  22114. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22115. /**
  22116. * Creates a new submesh
  22117. * @param materialIndex defines the material index to use
  22118. * @param verticesStart defines vertex index start
  22119. * @param verticesCount defines vertices count
  22120. * @param indexStart defines index start
  22121. * @param indexCount defines indices count
  22122. * @param mesh defines the parent mesh
  22123. * @param renderingMesh defines an optional rendering mesh
  22124. * @param createBoundingBox defines if bounding box should be created for this submesh
  22125. */
  22126. constructor(
  22127. /** the material index to use */
  22128. materialIndex: number,
  22129. /** vertex index start */
  22130. verticesStart: number,
  22131. /** vertices count */
  22132. verticesCount: number,
  22133. /** index start */
  22134. indexStart: number,
  22135. /** indices count */
  22136. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22137. /**
  22138. * Returns true if this submesh covers the entire parent mesh
  22139. * @ignorenaming
  22140. */
  22141. readonly IsGlobal: boolean;
  22142. /**
  22143. * Returns the submesh BoudingInfo object
  22144. * @returns current bounding info (or mesh's one if the submesh is global)
  22145. */
  22146. getBoundingInfo(): BoundingInfo;
  22147. /**
  22148. * Sets the submesh BoundingInfo
  22149. * @param boundingInfo defines the new bounding info to use
  22150. * @returns the SubMesh
  22151. */
  22152. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22153. /**
  22154. * Returns the mesh of the current submesh
  22155. * @return the parent mesh
  22156. */
  22157. getMesh(): AbstractMesh;
  22158. /**
  22159. * Returns the rendering mesh of the submesh
  22160. * @returns the rendering mesh (could be different from parent mesh)
  22161. */
  22162. getRenderingMesh(): Mesh;
  22163. /**
  22164. * Returns the submesh material
  22165. * @returns null or the current material
  22166. */
  22167. getMaterial(): Nullable<Material>;
  22168. /**
  22169. * Sets a new updated BoundingInfo object to the submesh
  22170. * @returns the SubMesh
  22171. */
  22172. refreshBoundingInfo(): SubMesh;
  22173. /** @hidden */
  22174. _checkCollision(collider: Collider): boolean;
  22175. /**
  22176. * Updates the submesh BoundingInfo
  22177. * @param world defines the world matrix to use to update the bounding info
  22178. * @returns the submesh
  22179. */
  22180. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22181. /**
  22182. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22183. * @param frustumPlanes defines the frustum planes
  22184. * @returns true if the submesh is intersecting with the frustum
  22185. */
  22186. isInFrustum(frustumPlanes: Plane[]): boolean;
  22187. /**
  22188. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22189. * @param frustumPlanes defines the frustum planes
  22190. * @returns true if the submesh is inside the frustum
  22191. */
  22192. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22193. /**
  22194. * Renders the submesh
  22195. * @param enableAlphaMode defines if alpha needs to be used
  22196. * @returns the submesh
  22197. */
  22198. render(enableAlphaMode: boolean): SubMesh;
  22199. /**
  22200. * @hidden
  22201. */
  22202. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22203. /**
  22204. * Checks if the submesh intersects with a ray
  22205. * @param ray defines the ray to test
  22206. * @returns true is the passed ray intersects the submesh bounding box
  22207. */
  22208. canIntersects(ray: Ray): boolean;
  22209. /**
  22210. * Intersects current submesh with a ray
  22211. * @param ray defines the ray to test
  22212. * @param positions defines mesh's positions array
  22213. * @param indices defines mesh's indices array
  22214. * @param fastCheck defines if only bounding info should be used
  22215. * @returns intersection info or null if no intersection
  22216. */
  22217. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  22218. /** @hidden */
  22219. private _intersectLines;
  22220. /** @hidden */
  22221. private _intersectTriangles;
  22222. /** @hidden */
  22223. _rebuild(): void;
  22224. /**
  22225. * Creates a new submesh from the passed mesh
  22226. * @param newMesh defines the new hosting mesh
  22227. * @param newRenderingMesh defines an optional rendering mesh
  22228. * @returns the new submesh
  22229. */
  22230. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22231. /**
  22232. * Release associated resources
  22233. */
  22234. dispose(): void;
  22235. /**
  22236. * Gets the class name
  22237. * @returns the string "SubMesh".
  22238. */
  22239. getClassName(): string;
  22240. /**
  22241. * Creates a new submesh from indices data
  22242. * @param materialIndex the index of the main mesh material
  22243. * @param startIndex the index where to start the copy in the mesh indices array
  22244. * @param indexCount the number of indices to copy then from the startIndex
  22245. * @param mesh the main mesh to create the submesh from
  22246. * @param renderingMesh the optional rendering mesh
  22247. * @returns a new submesh
  22248. */
  22249. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22250. }
  22251. }
  22252. declare module "babylonjs/Meshes/geometry" {
  22253. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22254. import { Scene } from "babylonjs/scene";
  22255. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22256. import { Engine } from "babylonjs/Engines/engine";
  22257. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22258. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22259. import { Effect } from "babylonjs/Materials/effect";
  22260. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22261. import { Mesh } from "babylonjs/Meshes/mesh";
  22262. /**
  22263. * Class used to store geometry data (vertex buffers + index buffer)
  22264. */
  22265. export class Geometry implements IGetSetVerticesData {
  22266. /**
  22267. * Gets or sets the ID of the geometry
  22268. */
  22269. id: string;
  22270. /**
  22271. * Gets or sets the unique ID of the geometry
  22272. */
  22273. uniqueId: number;
  22274. /**
  22275. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22276. */
  22277. delayLoadState: number;
  22278. /**
  22279. * Gets the file containing the data to load when running in delay load state
  22280. */
  22281. delayLoadingFile: Nullable<string>;
  22282. /**
  22283. * Callback called when the geometry is updated
  22284. */
  22285. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22286. private _scene;
  22287. private _engine;
  22288. private _meshes;
  22289. private _totalVertices;
  22290. /** @hidden */
  22291. _indices: IndicesArray;
  22292. /** @hidden */
  22293. _vertexBuffers: {
  22294. [key: string]: VertexBuffer;
  22295. };
  22296. private _isDisposed;
  22297. private _extend;
  22298. private _boundingBias;
  22299. /** @hidden */
  22300. _delayInfo: Array<string>;
  22301. private _indexBuffer;
  22302. private _indexBufferIsUpdatable;
  22303. /** @hidden */
  22304. _boundingInfo: Nullable<BoundingInfo>;
  22305. /** @hidden */
  22306. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22307. /** @hidden */
  22308. _softwareSkinningFrameId: number;
  22309. private _vertexArrayObjects;
  22310. private _updatable;
  22311. /** @hidden */
  22312. _positions: Nullable<Vector3[]>;
  22313. /**
  22314. * 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
  22315. */
  22316. /**
  22317. * 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
  22318. */
  22319. boundingBias: Vector2;
  22320. /**
  22321. * Static function used to attach a new empty geometry to a mesh
  22322. * @param mesh defines the mesh to attach the geometry to
  22323. * @returns the new Geometry
  22324. */
  22325. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22326. /**
  22327. * Creates a new geometry
  22328. * @param id defines the unique ID
  22329. * @param scene defines the hosting scene
  22330. * @param vertexData defines the VertexData used to get geometry data
  22331. * @param updatable defines if geometry must be updatable (false by default)
  22332. * @param mesh defines the mesh that will be associated with the geometry
  22333. */
  22334. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22335. /**
  22336. * Gets the current extend of the geometry
  22337. */
  22338. readonly extend: {
  22339. minimum: Vector3;
  22340. maximum: Vector3;
  22341. };
  22342. /**
  22343. * Gets the hosting scene
  22344. * @returns the hosting Scene
  22345. */
  22346. getScene(): Scene;
  22347. /**
  22348. * Gets the hosting engine
  22349. * @returns the hosting Engine
  22350. */
  22351. getEngine(): Engine;
  22352. /**
  22353. * Defines if the geometry is ready to use
  22354. * @returns true if the geometry is ready to be used
  22355. */
  22356. isReady(): boolean;
  22357. /**
  22358. * Gets a value indicating that the geometry should not be serialized
  22359. */
  22360. readonly doNotSerialize: boolean;
  22361. /** @hidden */
  22362. _rebuild(): void;
  22363. /**
  22364. * Affects all geometry data in one call
  22365. * @param vertexData defines the geometry data
  22366. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22367. */
  22368. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22369. /**
  22370. * Set specific vertex data
  22371. * @param kind defines the data kind (Position, normal, etc...)
  22372. * @param data defines the vertex data to use
  22373. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22374. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22375. */
  22376. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22377. /**
  22378. * Removes a specific vertex data
  22379. * @param kind defines the data kind (Position, normal, etc...)
  22380. */
  22381. removeVerticesData(kind: string): void;
  22382. /**
  22383. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22384. * @param buffer defines the vertex buffer to use
  22385. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22386. */
  22387. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22388. /**
  22389. * Update a specific vertex buffer
  22390. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22391. * It will do nothing if the buffer is not updatable
  22392. * @param kind defines the data kind (Position, normal, etc...)
  22393. * @param data defines the data to use
  22394. * @param offset defines the offset in the target buffer where to store the data
  22395. * @param useBytes set to true if the offset is in bytes
  22396. */
  22397. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22398. /**
  22399. * Update a specific vertex buffer
  22400. * This function will create a new buffer if the current one is not updatable
  22401. * @param kind defines the data kind (Position, normal, etc...)
  22402. * @param data defines the data to use
  22403. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22404. */
  22405. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22406. private _updateBoundingInfo;
  22407. /** @hidden */
  22408. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22409. /**
  22410. * Gets total number of vertices
  22411. * @returns the total number of vertices
  22412. */
  22413. getTotalVertices(): number;
  22414. /**
  22415. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22416. * @param kind defines the data kind (Position, normal, etc...)
  22417. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22418. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22419. * @returns a float array containing vertex data
  22420. */
  22421. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22422. /**
  22423. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22424. * @param kind defines the data kind (Position, normal, etc...)
  22425. * @returns true if the vertex buffer with the specified kind is updatable
  22426. */
  22427. isVertexBufferUpdatable(kind: string): boolean;
  22428. /**
  22429. * Gets a specific vertex buffer
  22430. * @param kind defines the data kind (Position, normal, etc...)
  22431. * @returns a VertexBuffer
  22432. */
  22433. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22434. /**
  22435. * Returns all vertex buffers
  22436. * @return an object holding all vertex buffers indexed by kind
  22437. */
  22438. getVertexBuffers(): Nullable<{
  22439. [key: string]: VertexBuffer;
  22440. }>;
  22441. /**
  22442. * Gets a boolean indicating if specific vertex buffer is present
  22443. * @param kind defines the data kind (Position, normal, etc...)
  22444. * @returns true if data is present
  22445. */
  22446. isVerticesDataPresent(kind: string): boolean;
  22447. /**
  22448. * Gets a list of all attached data kinds (Position, normal, etc...)
  22449. * @returns a list of string containing all kinds
  22450. */
  22451. getVerticesDataKinds(): string[];
  22452. /**
  22453. * Update index buffer
  22454. * @param indices defines the indices to store in the index buffer
  22455. * @param offset defines the offset in the target buffer where to store the data
  22456. */
  22457. updateIndices(indices: IndicesArray, offset?: number): void;
  22458. /**
  22459. * Creates a new index buffer
  22460. * @param indices defines the indices to store in the index buffer
  22461. * @param totalVertices defines the total number of vertices (could be null)
  22462. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22463. */
  22464. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22465. /**
  22466. * Return the total number of indices
  22467. * @returns the total number of indices
  22468. */
  22469. getTotalIndices(): number;
  22470. /**
  22471. * Gets the index buffer array
  22472. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22473. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22474. * @returns the index buffer array
  22475. */
  22476. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22477. /**
  22478. * Gets the index buffer
  22479. * @return the index buffer
  22480. */
  22481. getIndexBuffer(): Nullable<WebGLBuffer>;
  22482. /** @hidden */
  22483. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22484. /**
  22485. * Release the associated resources for a specific mesh
  22486. * @param mesh defines the source mesh
  22487. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22488. */
  22489. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22490. /**
  22491. * Apply current geometry to a given mesh
  22492. * @param mesh defines the mesh to apply geometry to
  22493. */
  22494. applyToMesh(mesh: Mesh): void;
  22495. private _updateExtend;
  22496. private _applyToMesh;
  22497. private notifyUpdate;
  22498. /**
  22499. * Load the geometry if it was flagged as delay loaded
  22500. * @param scene defines the hosting scene
  22501. * @param onLoaded defines a callback called when the geometry is loaded
  22502. */
  22503. load(scene: Scene, onLoaded?: () => void): void;
  22504. private _queueLoad;
  22505. /**
  22506. * Invert the geometry to move from a right handed system to a left handed one.
  22507. */
  22508. toLeftHanded(): void;
  22509. /** @hidden */
  22510. _resetPointsArrayCache(): void;
  22511. /** @hidden */
  22512. _generatePointsArray(): boolean;
  22513. /**
  22514. * Gets a value indicating if the geometry is disposed
  22515. * @returns true if the geometry was disposed
  22516. */
  22517. isDisposed(): boolean;
  22518. private _disposeVertexArrayObjects;
  22519. /**
  22520. * Free all associated resources
  22521. */
  22522. dispose(): void;
  22523. /**
  22524. * Clone the current geometry into a new geometry
  22525. * @param id defines the unique ID of the new geometry
  22526. * @returns a new geometry object
  22527. */
  22528. copy(id: string): Geometry;
  22529. /**
  22530. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22531. * @return a JSON representation of the current geometry data (without the vertices data)
  22532. */
  22533. serialize(): any;
  22534. private toNumberArray;
  22535. /**
  22536. * Serialize all vertices data into a JSON oject
  22537. * @returns a JSON representation of the current geometry data
  22538. */
  22539. serializeVerticeData(): any;
  22540. /**
  22541. * Extracts a clone of a mesh geometry
  22542. * @param mesh defines the source mesh
  22543. * @param id defines the unique ID of the new geometry object
  22544. * @returns the new geometry object
  22545. */
  22546. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22547. /**
  22548. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22549. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22550. * Be aware Math.random() could cause collisions, but:
  22551. * "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"
  22552. * @returns a string containing a new GUID
  22553. */
  22554. static RandomId(): string;
  22555. /** @hidden */
  22556. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22557. private static _CleanMatricesWeights;
  22558. /**
  22559. * Create a new geometry from persisted data (Using .babylon file format)
  22560. * @param parsedVertexData defines the persisted data
  22561. * @param scene defines the hosting scene
  22562. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22563. * @returns the new geometry object
  22564. */
  22565. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22566. }
  22567. }
  22568. declare module "babylonjs/Meshes/mesh.vertexData" {
  22569. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22570. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22571. import { Geometry } from "babylonjs/Meshes/geometry";
  22572. import { Mesh } from "babylonjs/Meshes/mesh";
  22573. /**
  22574. * Define an interface for all classes that will get and set the data on vertices
  22575. */
  22576. export interface IGetSetVerticesData {
  22577. /**
  22578. * Gets a boolean indicating if specific vertex data is present
  22579. * @param kind defines the vertex data kind to use
  22580. * @returns true is data kind is present
  22581. */
  22582. isVerticesDataPresent(kind: string): boolean;
  22583. /**
  22584. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22585. * @param kind defines the data kind (Position, normal, etc...)
  22586. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22587. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22588. * @returns a float array containing vertex data
  22589. */
  22590. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22591. /**
  22592. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22593. * @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.
  22594. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22595. * @returns the indices array or an empty array if the mesh has no geometry
  22596. */
  22597. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22598. /**
  22599. * Set specific vertex data
  22600. * @param kind defines the data kind (Position, normal, etc...)
  22601. * @param data defines the vertex data to use
  22602. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22603. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22604. */
  22605. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22606. /**
  22607. * Update a specific associated vertex buffer
  22608. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22609. * - VertexBuffer.PositionKind
  22610. * - VertexBuffer.UVKind
  22611. * - VertexBuffer.UV2Kind
  22612. * - VertexBuffer.UV3Kind
  22613. * - VertexBuffer.UV4Kind
  22614. * - VertexBuffer.UV5Kind
  22615. * - VertexBuffer.UV6Kind
  22616. * - VertexBuffer.ColorKind
  22617. * - VertexBuffer.MatricesIndicesKind
  22618. * - VertexBuffer.MatricesIndicesExtraKind
  22619. * - VertexBuffer.MatricesWeightsKind
  22620. * - VertexBuffer.MatricesWeightsExtraKind
  22621. * @param data defines the data source
  22622. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22623. * @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)
  22624. */
  22625. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22626. /**
  22627. * Creates a new index buffer
  22628. * @param indices defines the indices to store in the index buffer
  22629. * @param totalVertices defines the total number of vertices (could be null)
  22630. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22631. */
  22632. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22633. }
  22634. /**
  22635. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22636. */
  22637. export class VertexData {
  22638. /**
  22639. * Mesh side orientation : usually the external or front surface
  22640. */
  22641. static readonly FRONTSIDE: number;
  22642. /**
  22643. * Mesh side orientation : usually the internal or back surface
  22644. */
  22645. static readonly BACKSIDE: number;
  22646. /**
  22647. * Mesh side orientation : both internal and external or front and back surfaces
  22648. */
  22649. static readonly DOUBLESIDE: number;
  22650. /**
  22651. * Mesh side orientation : by default, `FRONTSIDE`
  22652. */
  22653. static readonly DEFAULTSIDE: number;
  22654. /**
  22655. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22656. */
  22657. positions: Nullable<FloatArray>;
  22658. /**
  22659. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22660. */
  22661. normals: Nullable<FloatArray>;
  22662. /**
  22663. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22664. */
  22665. tangents: Nullable<FloatArray>;
  22666. /**
  22667. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22668. */
  22669. uvs: Nullable<FloatArray>;
  22670. /**
  22671. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22672. */
  22673. uvs2: Nullable<FloatArray>;
  22674. /**
  22675. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22676. */
  22677. uvs3: Nullable<FloatArray>;
  22678. /**
  22679. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22680. */
  22681. uvs4: Nullable<FloatArray>;
  22682. /**
  22683. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22684. */
  22685. uvs5: Nullable<FloatArray>;
  22686. /**
  22687. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22688. */
  22689. uvs6: Nullable<FloatArray>;
  22690. /**
  22691. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22692. */
  22693. colors: Nullable<FloatArray>;
  22694. /**
  22695. * 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).
  22696. */
  22697. matricesIndices: Nullable<FloatArray>;
  22698. /**
  22699. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22700. */
  22701. matricesWeights: Nullable<FloatArray>;
  22702. /**
  22703. * An array extending the number of possible indices
  22704. */
  22705. matricesIndicesExtra: Nullable<FloatArray>;
  22706. /**
  22707. * An array extending the number of possible weights when the number of indices is extended
  22708. */
  22709. matricesWeightsExtra: Nullable<FloatArray>;
  22710. /**
  22711. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22712. */
  22713. indices: Nullable<IndicesArray>;
  22714. /**
  22715. * Uses the passed data array to set the set the values for the specified kind of data
  22716. * @param data a linear array of floating numbers
  22717. * @param kind the type of data that is being set, eg positions, colors etc
  22718. */
  22719. set(data: FloatArray, kind: string): void;
  22720. /**
  22721. * Associates the vertexData to the passed Mesh.
  22722. * Sets it as updatable or not (default `false`)
  22723. * @param mesh the mesh the vertexData is applied to
  22724. * @param updatable when used and having the value true allows new data to update the vertexData
  22725. * @returns the VertexData
  22726. */
  22727. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22728. /**
  22729. * Associates the vertexData to the passed Geometry.
  22730. * Sets it as updatable or not (default `false`)
  22731. * @param geometry the geometry the vertexData is applied to
  22732. * @param updatable when used and having the value true allows new data to update the vertexData
  22733. * @returns VertexData
  22734. */
  22735. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22736. /**
  22737. * Updates the associated mesh
  22738. * @param mesh the mesh to be updated
  22739. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22740. * @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
  22741. * @returns VertexData
  22742. */
  22743. updateMesh(mesh: Mesh): VertexData;
  22744. /**
  22745. * Updates the associated geometry
  22746. * @param geometry the geometry to be updated
  22747. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22748. * @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
  22749. * @returns VertexData.
  22750. */
  22751. updateGeometry(geometry: Geometry): VertexData;
  22752. private _applyTo;
  22753. private _update;
  22754. /**
  22755. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22756. * @param matrix the transforming matrix
  22757. * @returns the VertexData
  22758. */
  22759. transform(matrix: Matrix): VertexData;
  22760. /**
  22761. * Merges the passed VertexData into the current one
  22762. * @param other the VertexData to be merged into the current one
  22763. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22764. * @returns the modified VertexData
  22765. */
  22766. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22767. private _mergeElement;
  22768. private _validate;
  22769. /**
  22770. * Serializes the VertexData
  22771. * @returns a serialized object
  22772. */
  22773. serialize(): any;
  22774. /**
  22775. * Extracts the vertexData from a mesh
  22776. * @param mesh the mesh from which to extract the VertexData
  22777. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22778. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22779. * @returns the object VertexData associated to the passed mesh
  22780. */
  22781. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22782. /**
  22783. * Extracts the vertexData from the geometry
  22784. * @param geometry the geometry from which to extract the VertexData
  22785. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22786. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22787. * @returns the object VertexData associated to the passed mesh
  22788. */
  22789. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22790. private static _ExtractFrom;
  22791. /**
  22792. * Creates the VertexData for a Ribbon
  22793. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22794. * * pathArray array of paths, each of which an array of successive Vector3
  22795. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22796. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22797. * * 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
  22798. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22799. * * 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)
  22800. * * 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)
  22801. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22802. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22803. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22804. * @returns the VertexData of the ribbon
  22805. */
  22806. static CreateRibbon(options: {
  22807. pathArray: Vector3[][];
  22808. closeArray?: boolean;
  22809. closePath?: boolean;
  22810. offset?: number;
  22811. sideOrientation?: number;
  22812. frontUVs?: Vector4;
  22813. backUVs?: Vector4;
  22814. invertUV?: boolean;
  22815. uvs?: Vector2[];
  22816. colors?: Color4[];
  22817. }): VertexData;
  22818. /**
  22819. * Creates the VertexData for a box
  22820. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22821. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22822. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22823. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22824. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22825. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22826. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22827. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22828. * * 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)
  22829. * * 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)
  22830. * @returns the VertexData of the box
  22831. */
  22832. static CreateBox(options: {
  22833. size?: number;
  22834. width?: number;
  22835. height?: number;
  22836. depth?: number;
  22837. faceUV?: Vector4[];
  22838. faceColors?: Color4[];
  22839. sideOrientation?: number;
  22840. frontUVs?: Vector4;
  22841. backUVs?: Vector4;
  22842. }): VertexData;
  22843. /**
  22844. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22845. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22846. * * segments sets the number of horizontal strips optional, default 32
  22847. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22848. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22849. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22850. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22851. * * 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
  22852. * * 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
  22853. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22854. * * 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)
  22855. * * 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)
  22856. * @returns the VertexData of the ellipsoid
  22857. */
  22858. static CreateSphere(options: {
  22859. segments?: number;
  22860. diameter?: number;
  22861. diameterX?: number;
  22862. diameterY?: number;
  22863. diameterZ?: number;
  22864. arc?: number;
  22865. slice?: number;
  22866. sideOrientation?: number;
  22867. frontUVs?: Vector4;
  22868. backUVs?: Vector4;
  22869. }): VertexData;
  22870. /**
  22871. * Creates the VertexData for a cylinder, cone or prism
  22872. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22873. * * height sets the height (y direction) of the cylinder, optional, default 2
  22874. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22875. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22876. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22877. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22878. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22879. * * 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
  22880. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22881. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22882. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22883. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22884. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22885. * * 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)
  22886. * * 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)
  22887. * @returns the VertexData of the cylinder, cone or prism
  22888. */
  22889. static CreateCylinder(options: {
  22890. height?: number;
  22891. diameterTop?: number;
  22892. diameterBottom?: number;
  22893. diameter?: number;
  22894. tessellation?: number;
  22895. subdivisions?: number;
  22896. arc?: number;
  22897. faceColors?: Color4[];
  22898. faceUV?: Vector4[];
  22899. hasRings?: boolean;
  22900. enclose?: boolean;
  22901. sideOrientation?: number;
  22902. frontUVs?: Vector4;
  22903. backUVs?: Vector4;
  22904. }): VertexData;
  22905. /**
  22906. * Creates the VertexData for a torus
  22907. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22908. * * diameter the diameter of the torus, optional default 1
  22909. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22910. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22911. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22912. * * 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)
  22913. * * 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)
  22914. * @returns the VertexData of the torus
  22915. */
  22916. static CreateTorus(options: {
  22917. diameter?: number;
  22918. thickness?: number;
  22919. tessellation?: number;
  22920. sideOrientation?: number;
  22921. frontUVs?: Vector4;
  22922. backUVs?: Vector4;
  22923. }): VertexData;
  22924. /**
  22925. * Creates the VertexData of the LineSystem
  22926. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22927. * - lines an array of lines, each line being an array of successive Vector3
  22928. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22929. * @returns the VertexData of the LineSystem
  22930. */
  22931. static CreateLineSystem(options: {
  22932. lines: Vector3[][];
  22933. colors?: Nullable<Color4[][]>;
  22934. }): VertexData;
  22935. /**
  22936. * Create the VertexData for a DashedLines
  22937. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22938. * - points an array successive Vector3
  22939. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22940. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22941. * - dashNb the intended total number of dashes, optional, default 200
  22942. * @returns the VertexData for the DashedLines
  22943. */
  22944. static CreateDashedLines(options: {
  22945. points: Vector3[];
  22946. dashSize?: number;
  22947. gapSize?: number;
  22948. dashNb?: number;
  22949. }): VertexData;
  22950. /**
  22951. * Creates the VertexData for a Ground
  22952. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22953. * - width the width (x direction) of the ground, optional, default 1
  22954. * - height the height (z direction) of the ground, optional, default 1
  22955. * - subdivisions the number of subdivisions per side, optional, default 1
  22956. * @returns the VertexData of the Ground
  22957. */
  22958. static CreateGround(options: {
  22959. width?: number;
  22960. height?: number;
  22961. subdivisions?: number;
  22962. subdivisionsX?: number;
  22963. subdivisionsY?: number;
  22964. }): VertexData;
  22965. /**
  22966. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22967. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22968. * * xmin the ground minimum X coordinate, optional, default -1
  22969. * * zmin the ground minimum Z coordinate, optional, default -1
  22970. * * xmax the ground maximum X coordinate, optional, default 1
  22971. * * zmax the ground maximum Z coordinate, optional, default 1
  22972. * * 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}
  22973. * * 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}
  22974. * @returns the VertexData of the TiledGround
  22975. */
  22976. static CreateTiledGround(options: {
  22977. xmin: number;
  22978. zmin: number;
  22979. xmax: number;
  22980. zmax: number;
  22981. subdivisions?: {
  22982. w: number;
  22983. h: number;
  22984. };
  22985. precision?: {
  22986. w: number;
  22987. h: number;
  22988. };
  22989. }): VertexData;
  22990. /**
  22991. * Creates the VertexData of the Ground designed from a heightmap
  22992. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22993. * * width the width (x direction) of the ground
  22994. * * height the height (z direction) of the ground
  22995. * * subdivisions the number of subdivisions per side
  22996. * * minHeight the minimum altitude on the ground, optional, default 0
  22997. * * maxHeight the maximum altitude on the ground, optional default 1
  22998. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22999. * * buffer the array holding the image color data
  23000. * * bufferWidth the width of image
  23001. * * bufferHeight the height of image
  23002. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23003. * @returns the VertexData of the Ground designed from a heightmap
  23004. */
  23005. static CreateGroundFromHeightMap(options: {
  23006. width: number;
  23007. height: number;
  23008. subdivisions: number;
  23009. minHeight: number;
  23010. maxHeight: number;
  23011. colorFilter: Color3;
  23012. buffer: Uint8Array;
  23013. bufferWidth: number;
  23014. bufferHeight: number;
  23015. alphaFilter: number;
  23016. }): VertexData;
  23017. /**
  23018. * Creates the VertexData for a Plane
  23019. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23020. * * size sets the width and height of the plane to the value of size, optional default 1
  23021. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23022. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23023. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23024. * * 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)
  23025. * * 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)
  23026. * @returns the VertexData of the box
  23027. */
  23028. static CreatePlane(options: {
  23029. size?: number;
  23030. width?: number;
  23031. height?: number;
  23032. sideOrientation?: number;
  23033. frontUVs?: Vector4;
  23034. backUVs?: Vector4;
  23035. }): VertexData;
  23036. /**
  23037. * Creates the VertexData of the Disc or regular Polygon
  23038. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23039. * * radius the radius of the disc, optional default 0.5
  23040. * * tessellation the number of polygon sides, optional, default 64
  23041. * * 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
  23042. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23043. * * 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)
  23044. * * 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)
  23045. * @returns the VertexData of the box
  23046. */
  23047. static CreateDisc(options: {
  23048. radius?: number;
  23049. tessellation?: number;
  23050. arc?: number;
  23051. sideOrientation?: number;
  23052. frontUVs?: Vector4;
  23053. backUVs?: Vector4;
  23054. }): VertexData;
  23055. /**
  23056. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23057. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23058. * @param polygon a mesh built from polygonTriangulation.build()
  23059. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23060. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23061. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23062. * @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)
  23063. * @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)
  23064. * @returns the VertexData of the Polygon
  23065. */
  23066. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23067. /**
  23068. * Creates the VertexData of the IcoSphere
  23069. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23070. * * radius the radius of the IcoSphere, optional default 1
  23071. * * radiusX allows stretching in the x direction, optional, default radius
  23072. * * radiusY allows stretching in the y direction, optional, default radius
  23073. * * radiusZ allows stretching in the z direction, optional, default radius
  23074. * * flat when true creates a flat shaded mesh, optional, default true
  23075. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23076. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23077. * * 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)
  23078. * * 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)
  23079. * @returns the VertexData of the IcoSphere
  23080. */
  23081. static CreateIcoSphere(options: {
  23082. radius?: number;
  23083. radiusX?: number;
  23084. radiusY?: number;
  23085. radiusZ?: number;
  23086. flat?: boolean;
  23087. subdivisions?: number;
  23088. sideOrientation?: number;
  23089. frontUVs?: Vector4;
  23090. backUVs?: Vector4;
  23091. }): VertexData;
  23092. /**
  23093. * Creates the VertexData for a Polyhedron
  23094. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23095. * * type provided types are:
  23096. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23097. * * 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)
  23098. * * size the size of the IcoSphere, optional default 1
  23099. * * sizeX allows stretching in the x direction, optional, default size
  23100. * * sizeY allows stretching in the y direction, optional, default size
  23101. * * sizeZ allows stretching in the z direction, optional, default size
  23102. * * 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
  23103. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23104. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23105. * * flat when true creates a flat shaded mesh, optional, default true
  23106. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23107. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23108. * * 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)
  23109. * * 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)
  23110. * @returns the VertexData of the Polyhedron
  23111. */
  23112. static CreatePolyhedron(options: {
  23113. type?: number;
  23114. size?: number;
  23115. sizeX?: number;
  23116. sizeY?: number;
  23117. sizeZ?: number;
  23118. custom?: any;
  23119. faceUV?: Vector4[];
  23120. faceColors?: Color4[];
  23121. flat?: boolean;
  23122. sideOrientation?: number;
  23123. frontUVs?: Vector4;
  23124. backUVs?: Vector4;
  23125. }): VertexData;
  23126. /**
  23127. * Creates the VertexData for a TorusKnot
  23128. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23129. * * radius the radius of the torus knot, optional, default 2
  23130. * * tube the thickness of the tube, optional, default 0.5
  23131. * * radialSegments the number of sides on each tube segments, optional, default 32
  23132. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23133. * * p the number of windings around the z axis, optional, default 2
  23134. * * q the number of windings around the x axis, optional, default 3
  23135. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23136. * * 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)
  23137. * * 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)
  23138. * @returns the VertexData of the Torus Knot
  23139. */
  23140. static CreateTorusKnot(options: {
  23141. radius?: number;
  23142. tube?: number;
  23143. radialSegments?: number;
  23144. tubularSegments?: number;
  23145. p?: number;
  23146. q?: number;
  23147. sideOrientation?: number;
  23148. frontUVs?: Vector4;
  23149. backUVs?: Vector4;
  23150. }): VertexData;
  23151. /**
  23152. * Compute normals for given positions and indices
  23153. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23154. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23155. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23156. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23157. * * facetNormals : optional array of facet normals (vector3)
  23158. * * facetPositions : optional array of facet positions (vector3)
  23159. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23160. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23161. * * bInfo : optional bounding info, required for facetPartitioning computation
  23162. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23163. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23164. * * useRightHandedSystem: optional boolean to for right handed system computation
  23165. * * depthSort : optional boolean to enable the facet depth sort computation
  23166. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23167. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23168. */
  23169. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23170. facetNormals?: any;
  23171. facetPositions?: any;
  23172. facetPartitioning?: any;
  23173. ratio?: number;
  23174. bInfo?: any;
  23175. bbSize?: Vector3;
  23176. subDiv?: any;
  23177. useRightHandedSystem?: boolean;
  23178. depthSort?: boolean;
  23179. distanceTo?: Vector3;
  23180. depthSortedFacets?: any;
  23181. }): void;
  23182. /** @hidden */
  23183. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23184. /**
  23185. * Applies VertexData created from the imported parameters to the geometry
  23186. * @param parsedVertexData the parsed data from an imported file
  23187. * @param geometry the geometry to apply the VertexData to
  23188. */
  23189. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23190. }
  23191. }
  23192. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23193. import { Nullable } from "babylonjs/types";
  23194. import { Scene } from "babylonjs/scene";
  23195. import { Vector4 } from "babylonjs/Maths/math";
  23196. import { Mesh } from "babylonjs/Meshes/mesh";
  23197. /**
  23198. * Class containing static functions to help procedurally build meshes
  23199. */
  23200. export class DiscBuilder {
  23201. /**
  23202. * Creates a plane polygonal mesh. By default, this is a disc
  23203. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23204. * * 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
  23205. * * 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
  23206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23207. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23209. * @param name defines the name of the mesh
  23210. * @param options defines the options used to create the mesh
  23211. * @param scene defines the hosting scene
  23212. * @returns the plane polygonal mesh
  23213. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23214. */
  23215. static CreateDisc(name: string, options: {
  23216. radius?: number;
  23217. tessellation?: number;
  23218. arc?: number;
  23219. updatable?: boolean;
  23220. sideOrientation?: number;
  23221. frontUVs?: Vector4;
  23222. backUVs?: Vector4;
  23223. }, scene?: Nullable<Scene>): Mesh;
  23224. }
  23225. }
  23226. declare module "babylonjs/Particles/solidParticleSystem" {
  23227. import { Vector3 } from "babylonjs/Maths/math";
  23228. import { Mesh } from "babylonjs/Meshes/mesh";
  23229. import { Scene, IDisposable } from "babylonjs/scene";
  23230. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23231. /**
  23232. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23233. *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.
  23234. * The SPS is also a particle system. It provides some methods to manage the particles.
  23235. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23236. *
  23237. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23238. */
  23239. export class SolidParticleSystem implements IDisposable {
  23240. /**
  23241. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23242. * Example : var p = SPS.particles[i];
  23243. */
  23244. particles: SolidParticle[];
  23245. /**
  23246. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23247. */
  23248. nbParticles: number;
  23249. /**
  23250. * If the particles must ever face the camera (default false). Useful for planar particles.
  23251. */
  23252. billboard: boolean;
  23253. /**
  23254. * Recompute normals when adding a shape
  23255. */
  23256. recomputeNormals: boolean;
  23257. /**
  23258. * This a counter ofr your own usage. It's not set by any SPS functions.
  23259. */
  23260. counter: number;
  23261. /**
  23262. * The SPS name. This name is also given to the underlying mesh.
  23263. */
  23264. name: string;
  23265. /**
  23266. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23267. */
  23268. mesh: Mesh;
  23269. /**
  23270. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23271. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23272. */
  23273. vars: any;
  23274. /**
  23275. * This array is populated when the SPS is set as 'pickable'.
  23276. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23277. * Each element of this array is an object `{idx: int, faceId: int}`.
  23278. * `idx` is the picked particle index in the `SPS.particles` array
  23279. * `faceId` is the picked face index counted within this particle.
  23280. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23281. */
  23282. pickedParticles: {
  23283. idx: number;
  23284. faceId: number;
  23285. }[];
  23286. /**
  23287. * This array is populated when `enableDepthSort` is set to true.
  23288. * Each element of this array is an instance of the class DepthSortedParticle.
  23289. */
  23290. depthSortedParticles: DepthSortedParticle[];
  23291. /**
  23292. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23293. * @hidden
  23294. */
  23295. _bSphereOnly: boolean;
  23296. /**
  23297. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23298. * @hidden
  23299. */
  23300. _bSphereRadiusFactor: number;
  23301. private _scene;
  23302. private _positions;
  23303. private _indices;
  23304. private _normals;
  23305. private _colors;
  23306. private _uvs;
  23307. private _indices32;
  23308. private _positions32;
  23309. private _normals32;
  23310. private _fixedNormal32;
  23311. private _colors32;
  23312. private _uvs32;
  23313. private _index;
  23314. private _updatable;
  23315. private _pickable;
  23316. private _isVisibilityBoxLocked;
  23317. private _alwaysVisible;
  23318. private _depthSort;
  23319. private _shapeCounter;
  23320. private _copy;
  23321. private _color;
  23322. private _computeParticleColor;
  23323. private _computeParticleTexture;
  23324. private _computeParticleRotation;
  23325. private _computeParticleVertex;
  23326. private _computeBoundingBox;
  23327. private _depthSortParticles;
  23328. private _camera;
  23329. private _mustUnrotateFixedNormals;
  23330. private _particlesIntersect;
  23331. private _needs32Bits;
  23332. /**
  23333. * Creates a SPS (Solid Particle System) object.
  23334. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23335. * @param scene (Scene) is the scene in which the SPS is added.
  23336. * @param options defines the options of the sps e.g.
  23337. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23338. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23339. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23340. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23341. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23342. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23343. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23344. */
  23345. constructor(name: string, scene: Scene, options?: {
  23346. updatable?: boolean;
  23347. isPickable?: boolean;
  23348. enableDepthSort?: boolean;
  23349. particleIntersection?: boolean;
  23350. boundingSphereOnly?: boolean;
  23351. bSphereRadiusFactor?: number;
  23352. });
  23353. /**
  23354. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23355. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23356. * @returns the created mesh
  23357. */
  23358. buildMesh(): Mesh;
  23359. /**
  23360. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23361. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23362. * Thus the particles generated from `digest()` have their property `position` set yet.
  23363. * @param mesh ( Mesh ) is the mesh to be digested
  23364. * @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
  23365. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23366. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23367. * @returns the current SPS
  23368. */
  23369. digest(mesh: Mesh, options?: {
  23370. facetNb?: number;
  23371. number?: number;
  23372. delta?: number;
  23373. }): SolidParticleSystem;
  23374. private _unrotateFixedNormals;
  23375. private _resetCopy;
  23376. private _meshBuilder;
  23377. private _posToShape;
  23378. private _uvsToShapeUV;
  23379. private _addParticle;
  23380. /**
  23381. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23382. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23383. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23384. * @param nb (positive integer) the number of particles to be created from this model
  23385. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23386. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23387. * @returns the number of shapes in the system
  23388. */
  23389. addShape(mesh: Mesh, nb: number, options?: {
  23390. positionFunction?: any;
  23391. vertexFunction?: any;
  23392. }): number;
  23393. private _rebuildParticle;
  23394. /**
  23395. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23396. * @returns the SPS.
  23397. */
  23398. rebuildMesh(): SolidParticleSystem;
  23399. /**
  23400. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23401. * This method calls `updateParticle()` for each particle of the SPS.
  23402. * For an animated SPS, it is usually called within the render loop.
  23403. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23404. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23405. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23406. * @returns the SPS.
  23407. */
  23408. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23409. /**
  23410. * Disposes the SPS.
  23411. */
  23412. dispose(): void;
  23413. /**
  23414. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23415. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23416. * @returns the SPS.
  23417. */
  23418. refreshVisibleSize(): SolidParticleSystem;
  23419. /**
  23420. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23421. * @param size the size (float) of the visibility box
  23422. * note : this doesn't lock the SPS mesh bounding box.
  23423. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23424. */
  23425. setVisibilityBox(size: number): void;
  23426. /**
  23427. * Gets whether the SPS as always visible or not
  23428. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23429. */
  23430. /**
  23431. * Sets the SPS as always visible or not
  23432. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23433. */
  23434. isAlwaysVisible: boolean;
  23435. /**
  23436. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23437. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23438. */
  23439. /**
  23440. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23441. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23442. */
  23443. isVisibilityBoxLocked: boolean;
  23444. /**
  23445. * Tells to `setParticles()` to compute the particle rotations or not.
  23446. * Default value : true. The SPS is faster when it's set to false.
  23447. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23448. */
  23449. /**
  23450. * Gets if `setParticles()` computes the particle rotations or not.
  23451. * Default value : true. The SPS is faster when it's set to false.
  23452. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23453. */
  23454. computeParticleRotation: boolean;
  23455. /**
  23456. * Tells to `setParticles()` to compute the particle colors or not.
  23457. * Default value : true. The SPS is faster when it's set to false.
  23458. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23459. */
  23460. /**
  23461. * Gets if `setParticles()` computes the particle colors or not.
  23462. * Default value : true. The SPS is faster when it's set to false.
  23463. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23464. */
  23465. computeParticleColor: boolean;
  23466. /**
  23467. * Gets if `setParticles()` computes the particle textures or not.
  23468. * Default value : true. The SPS is faster when it's set to false.
  23469. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23470. */
  23471. computeParticleTexture: boolean;
  23472. /**
  23473. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23474. * Default value : false. The SPS is faster when it's set to false.
  23475. * Note : the particle custom vertex positions aren't stored values.
  23476. */
  23477. /**
  23478. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23479. * Default value : false. The SPS is faster when it's set to false.
  23480. * Note : the particle custom vertex positions aren't stored values.
  23481. */
  23482. computeParticleVertex: boolean;
  23483. /**
  23484. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23485. */
  23486. /**
  23487. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23488. */
  23489. computeBoundingBox: boolean;
  23490. /**
  23491. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23492. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23493. * Default : `true`
  23494. */
  23495. /**
  23496. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23497. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23498. * Default : `true`
  23499. */
  23500. depthSortParticles: boolean;
  23501. /**
  23502. * This function does nothing. It may be overwritten to set all the particle first values.
  23503. * The SPS doesn't call this function, you may have to call it by your own.
  23504. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23505. */
  23506. initParticles(): void;
  23507. /**
  23508. * This function does nothing. It may be overwritten to recycle a particle.
  23509. * The SPS doesn't call this function, you may have to call it by your own.
  23510. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23511. * @param particle The particle to recycle
  23512. * @returns the recycled particle
  23513. */
  23514. recycleParticle(particle: SolidParticle): SolidParticle;
  23515. /**
  23516. * Updates a particle : this function should be overwritten by the user.
  23517. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23518. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23519. * @example : just set a particle position or velocity and recycle conditions
  23520. * @param particle The particle to update
  23521. * @returns the updated particle
  23522. */
  23523. updateParticle(particle: SolidParticle): SolidParticle;
  23524. /**
  23525. * Updates a vertex of a particle : it can be overwritten by the user.
  23526. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23527. * @param particle the current particle
  23528. * @param vertex the current index of the current particle
  23529. * @param pt the index of the current vertex in the particle shape
  23530. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23531. * @example : just set a vertex particle position
  23532. * @returns the updated vertex
  23533. */
  23534. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23535. /**
  23536. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23537. * This does nothing and may be overwritten by the user.
  23538. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23539. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23540. * @param update the boolean update value actually passed to setParticles()
  23541. */
  23542. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23543. /**
  23544. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23545. * This will be passed three parameters.
  23546. * This does nothing and may be overwritten by the user.
  23547. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23548. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23549. * @param update the boolean update value actually passed to setParticles()
  23550. */
  23551. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23552. }
  23553. }
  23554. declare module "babylonjs/Particles/solidParticle" {
  23555. import { Nullable } from "babylonjs/types";
  23556. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23557. import { Mesh } from "babylonjs/Meshes/mesh";
  23558. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23559. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23560. /**
  23561. * Represents one particle of a solid particle system.
  23562. */
  23563. export class SolidParticle {
  23564. /**
  23565. * particle global index
  23566. */
  23567. idx: number;
  23568. /**
  23569. * The color of the particle
  23570. */
  23571. color: Nullable<Color4>;
  23572. /**
  23573. * The world space position of the particle.
  23574. */
  23575. position: Vector3;
  23576. /**
  23577. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23578. */
  23579. rotation: Vector3;
  23580. /**
  23581. * The world space rotation quaternion of the particle.
  23582. */
  23583. rotationQuaternion: Nullable<Quaternion>;
  23584. /**
  23585. * The scaling of the particle.
  23586. */
  23587. scaling: Vector3;
  23588. /**
  23589. * The uvs of the particle.
  23590. */
  23591. uvs: Vector4;
  23592. /**
  23593. * The current speed of the particle.
  23594. */
  23595. velocity: Vector3;
  23596. /**
  23597. * The pivot point in the particle local space.
  23598. */
  23599. pivot: Vector3;
  23600. /**
  23601. * Must the particle be translated from its pivot point in its local space ?
  23602. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23603. * Default : false
  23604. */
  23605. translateFromPivot: boolean;
  23606. /**
  23607. * Is the particle active or not ?
  23608. */
  23609. alive: boolean;
  23610. /**
  23611. * Is the particle visible or not ?
  23612. */
  23613. isVisible: boolean;
  23614. /**
  23615. * Index of this particle in the global "positions" array (Internal use)
  23616. * @hidden
  23617. */
  23618. _pos: number;
  23619. /**
  23620. * @hidden Index of this particle in the global "indices" array (Internal use)
  23621. */
  23622. _ind: number;
  23623. /**
  23624. * @hidden ModelShape of this particle (Internal use)
  23625. */
  23626. _model: ModelShape;
  23627. /**
  23628. * ModelShape id of this particle
  23629. */
  23630. shapeId: number;
  23631. /**
  23632. * Index of the particle in its shape id (Internal use)
  23633. */
  23634. idxInShape: number;
  23635. /**
  23636. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23637. */
  23638. _modelBoundingInfo: BoundingInfo;
  23639. /**
  23640. * @hidden Particle BoundingInfo object (Internal use)
  23641. */
  23642. _boundingInfo: BoundingInfo;
  23643. /**
  23644. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23645. */
  23646. _sps: SolidParticleSystem;
  23647. /**
  23648. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23649. */
  23650. _stillInvisible: boolean;
  23651. /**
  23652. * @hidden Last computed particle rotation matrix
  23653. */
  23654. _rotationMatrix: number[];
  23655. /**
  23656. * Parent particle Id, if any.
  23657. * Default null.
  23658. */
  23659. parentId: Nullable<number>;
  23660. /**
  23661. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23662. * The possible values are :
  23663. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23664. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23665. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23666. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23667. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23668. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23669. * */
  23670. cullingStrategy: number;
  23671. /**
  23672. * @hidden Internal global position in the SPS.
  23673. */
  23674. _globalPosition: Vector3;
  23675. /**
  23676. * Creates a Solid Particle object.
  23677. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23678. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23679. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23680. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23681. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23682. * @param shapeId (integer) is the model shape identifier in the SPS.
  23683. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23684. * @param sps defines the sps it is associated to
  23685. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23686. */
  23687. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23688. /**
  23689. * Legacy support, changed scale to scaling
  23690. */
  23691. /**
  23692. * Legacy support, changed scale to scaling
  23693. */
  23694. scale: Vector3;
  23695. /**
  23696. * Legacy support, changed quaternion to rotationQuaternion
  23697. */
  23698. /**
  23699. * Legacy support, changed quaternion to rotationQuaternion
  23700. */
  23701. quaternion: Nullable<Quaternion>;
  23702. /**
  23703. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23704. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23705. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23706. * @returns true if it intersects
  23707. */
  23708. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23709. /**
  23710. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23711. * A particle is in the frustum if its bounding box intersects the frustum
  23712. * @param frustumPlanes defines the frustum to test
  23713. * @returns true if the particle is in the frustum planes
  23714. */
  23715. isInFrustum(frustumPlanes: Plane[]): boolean;
  23716. /**
  23717. * get the rotation matrix of the particle
  23718. * @hidden
  23719. */
  23720. getRotationMatrix(m: Matrix): void;
  23721. }
  23722. /**
  23723. * Represents the shape of the model used by one particle of a solid particle system.
  23724. * SPS internal tool, don't use it manually.
  23725. */
  23726. export class ModelShape {
  23727. /**
  23728. * The shape id
  23729. * @hidden
  23730. */
  23731. shapeID: number;
  23732. /**
  23733. * flat array of model positions (internal use)
  23734. * @hidden
  23735. */
  23736. _shape: Vector3[];
  23737. /**
  23738. * flat array of model UVs (internal use)
  23739. * @hidden
  23740. */
  23741. _shapeUV: number[];
  23742. /**
  23743. * length of the shape in the model indices array (internal use)
  23744. * @hidden
  23745. */
  23746. _indicesLength: number;
  23747. /**
  23748. * Custom position function (internal use)
  23749. * @hidden
  23750. */
  23751. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23752. /**
  23753. * Custom vertex function (internal use)
  23754. * @hidden
  23755. */
  23756. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23757. /**
  23758. * 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.
  23759. * SPS internal tool, don't use it manually.
  23760. * @hidden
  23761. */
  23762. 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>);
  23763. }
  23764. /**
  23765. * Represents a Depth Sorted Particle in the solid particle system.
  23766. */
  23767. export class DepthSortedParticle {
  23768. /**
  23769. * Index of the particle in the "indices" array
  23770. */
  23771. ind: number;
  23772. /**
  23773. * Length of the particle shape in the "indices" array
  23774. */
  23775. indicesLength: number;
  23776. /**
  23777. * Squared distance from the particle to the camera
  23778. */
  23779. sqDistance: number;
  23780. }
  23781. }
  23782. declare module "babylonjs/Meshes/abstractMesh" {
  23783. import { Observable } from "babylonjs/Misc/observable";
  23784. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23785. import { Camera } from "babylonjs/Cameras/camera";
  23786. import { Scene, IDisposable } from "babylonjs/scene";
  23787. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23788. import { Node } from "babylonjs/node";
  23789. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23790. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23791. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23792. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23793. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23794. import { Material } from "babylonjs/Materials/material";
  23795. import { Light } from "babylonjs/Lights/light";
  23796. import { Skeleton } from "babylonjs/Bones/skeleton";
  23797. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23798. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23799. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23800. import { Ray } from "babylonjs/Culling/ray";
  23801. import { Collider } from "babylonjs/Collisions/collider";
  23802. /**
  23803. * Class used to store all common mesh properties
  23804. */
  23805. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23806. /** No occlusion */
  23807. static OCCLUSION_TYPE_NONE: number;
  23808. /** Occlusion set to optimisitic */
  23809. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23810. /** Occlusion set to strict */
  23811. static OCCLUSION_TYPE_STRICT: number;
  23812. /** Use an accurante occlusion algorithm */
  23813. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23814. /** Use a conservative occlusion algorithm */
  23815. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23816. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23817. * Test order :
  23818. * Is the bounding sphere outside the frustum ?
  23819. * If not, are the bounding box vertices outside the frustum ?
  23820. * It not, then the cullable object is in the frustum.
  23821. */
  23822. static readonly CULLINGSTRATEGY_STANDARD: number;
  23823. /** Culling strategy : Bounding Sphere Only.
  23824. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23825. * It's also less accurate than the standard because some not visible objects can still be selected.
  23826. * Test : is the bounding sphere outside the frustum ?
  23827. * If not, then the cullable object is in the frustum.
  23828. */
  23829. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23830. /** Culling strategy : Optimistic Inclusion.
  23831. * This in an inclusion test first, then the standard exclusion test.
  23832. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23833. * 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.
  23834. * Anyway, it's as accurate as the standard strategy.
  23835. * Test :
  23836. * Is the cullable object bounding sphere center in the frustum ?
  23837. * If not, apply the default culling strategy.
  23838. */
  23839. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23840. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23841. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23842. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23843. * 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.
  23844. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23845. * Test :
  23846. * Is the cullable object bounding sphere center in the frustum ?
  23847. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23848. */
  23849. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23850. /**
  23851. * No billboard
  23852. */
  23853. static readonly BILLBOARDMODE_NONE: number;
  23854. /** Billboard on X axis */
  23855. static readonly BILLBOARDMODE_X: number;
  23856. /** Billboard on Y axis */
  23857. static readonly BILLBOARDMODE_Y: number;
  23858. /** Billboard on Z axis */
  23859. static readonly BILLBOARDMODE_Z: number;
  23860. /** Billboard on all axes */
  23861. static readonly BILLBOARDMODE_ALL: number;
  23862. private _facetData;
  23863. /**
  23864. * The culling strategy to use to check whether the mesh must be rendered or not.
  23865. * This value can be changed at any time and will be used on the next render mesh selection.
  23866. * The possible values are :
  23867. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23868. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23869. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23870. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23871. * Please read each static variable documentation to get details about the culling process.
  23872. * */
  23873. cullingStrategy: number;
  23874. /**
  23875. * Gets the number of facets in the mesh
  23876. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23877. */
  23878. readonly facetNb: number;
  23879. /**
  23880. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23881. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23882. */
  23883. partitioningSubdivisions: number;
  23884. /**
  23885. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23886. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23888. */
  23889. partitioningBBoxRatio: number;
  23890. /**
  23891. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23892. * Works only for updatable meshes.
  23893. * Doesn't work with multi-materials
  23894. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23895. */
  23896. mustDepthSortFacets: boolean;
  23897. /**
  23898. * The location (Vector3) where the facet depth sort must be computed from.
  23899. * By default, the active camera position.
  23900. * Used only when facet depth sort is enabled
  23901. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23902. */
  23903. facetDepthSortFrom: Vector3;
  23904. /**
  23905. * gets a boolean indicating if facetData is enabled
  23906. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23907. */
  23908. readonly isFacetDataEnabled: boolean;
  23909. /** @hidden */
  23910. _updateNonUniformScalingState(value: boolean): boolean;
  23911. /**
  23912. * An event triggered when this mesh collides with another one
  23913. */
  23914. onCollideObservable: Observable<AbstractMesh>;
  23915. private _onCollideObserver;
  23916. /** Set a function to call when this mesh collides with another one */
  23917. onCollide: () => void;
  23918. /**
  23919. * An event triggered when the collision's position changes
  23920. */
  23921. onCollisionPositionChangeObservable: Observable<Vector3>;
  23922. private _onCollisionPositionChangeObserver;
  23923. /** Set a function to call when the collision's position changes */
  23924. onCollisionPositionChange: () => void;
  23925. /**
  23926. * An event triggered when material is changed
  23927. */
  23928. onMaterialChangedObservable: Observable<AbstractMesh>;
  23929. /**
  23930. * Gets or sets the orientation for POV movement & rotation
  23931. */
  23932. definedFacingForward: boolean;
  23933. /** @hidden */
  23934. _occlusionQuery: Nullable<WebGLQuery>;
  23935. private _visibility;
  23936. /**
  23937. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23938. */
  23939. /**
  23940. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23941. */
  23942. visibility: number;
  23943. /** Gets or sets the alpha index used to sort transparent meshes
  23944. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23945. */
  23946. alphaIndex: number;
  23947. /**
  23948. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23949. */
  23950. isVisible: boolean;
  23951. /**
  23952. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23953. */
  23954. isPickable: boolean;
  23955. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23956. showSubMeshesBoundingBox: boolean;
  23957. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23958. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23959. */
  23960. isBlocker: boolean;
  23961. /**
  23962. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23963. */
  23964. enablePointerMoveEvents: boolean;
  23965. /**
  23966. * Specifies the rendering group id for this mesh (0 by default)
  23967. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23968. */
  23969. renderingGroupId: number;
  23970. private _material;
  23971. /** Gets or sets current material */
  23972. material: Nullable<Material>;
  23973. private _receiveShadows;
  23974. /**
  23975. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23976. * @see http://doc.babylonjs.com/babylon101/shadows
  23977. */
  23978. receiveShadows: boolean;
  23979. /** Defines color to use when rendering outline */
  23980. outlineColor: Color3;
  23981. /** Define width to use when rendering outline */
  23982. outlineWidth: number;
  23983. /** Defines color to use when rendering overlay */
  23984. overlayColor: Color3;
  23985. /** Defines alpha to use when rendering overlay */
  23986. overlayAlpha: number;
  23987. private _hasVertexAlpha;
  23988. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23989. hasVertexAlpha: boolean;
  23990. private _useVertexColors;
  23991. /** 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) */
  23992. useVertexColors: boolean;
  23993. private _computeBonesUsingShaders;
  23994. /**
  23995. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23996. */
  23997. computeBonesUsingShaders: boolean;
  23998. private _numBoneInfluencers;
  23999. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24000. numBoneInfluencers: number;
  24001. private _applyFog;
  24002. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24003. applyFog: boolean;
  24004. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24005. useOctreeForRenderingSelection: boolean;
  24006. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24007. useOctreeForPicking: boolean;
  24008. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24009. useOctreeForCollisions: boolean;
  24010. private _layerMask;
  24011. /**
  24012. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24013. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24014. */
  24015. layerMask: number;
  24016. /**
  24017. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24018. */
  24019. alwaysSelectAsActiveMesh: boolean;
  24020. /**
  24021. * Gets or sets the current action manager
  24022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24023. */
  24024. actionManager: Nullable<AbstractActionManager>;
  24025. private _checkCollisions;
  24026. private _collisionMask;
  24027. private _collisionGroup;
  24028. /**
  24029. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24030. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24031. */
  24032. ellipsoid: Vector3;
  24033. /**
  24034. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24035. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24036. */
  24037. ellipsoidOffset: Vector3;
  24038. private _collider;
  24039. private _oldPositionForCollisions;
  24040. private _diffPositionForCollisions;
  24041. /**
  24042. * Gets or sets a collision mask used to mask collisions (default is -1).
  24043. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24044. */
  24045. collisionMask: number;
  24046. /**
  24047. * Gets or sets the current collision group mask (-1 by default).
  24048. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24049. */
  24050. collisionGroup: number;
  24051. /**
  24052. * Defines edge width used when edgesRenderer is enabled
  24053. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24054. */
  24055. edgesWidth: number;
  24056. /**
  24057. * Defines edge color used when edgesRenderer is enabled
  24058. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24059. */
  24060. edgesColor: Color4;
  24061. /** @hidden */
  24062. _edgesRenderer: Nullable<IEdgesRenderer>;
  24063. /** @hidden */
  24064. _masterMesh: Nullable<AbstractMesh>;
  24065. /** @hidden */
  24066. _boundingInfo: Nullable<BoundingInfo>;
  24067. /** @hidden */
  24068. _renderId: number;
  24069. /**
  24070. * Gets or sets the list of subMeshes
  24071. * @see http://doc.babylonjs.com/how_to/multi_materials
  24072. */
  24073. subMeshes: SubMesh[];
  24074. /** @hidden */
  24075. _intersectionsInProgress: AbstractMesh[];
  24076. /** @hidden */
  24077. _unIndexed: boolean;
  24078. /** @hidden */
  24079. _lightSources: Light[];
  24080. /** @hidden */
  24081. readonly _positions: Nullable<Vector3[]>;
  24082. /** @hidden */
  24083. _waitingActions: any;
  24084. /** @hidden */
  24085. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24086. private _skeleton;
  24087. /** @hidden */
  24088. _bonesTransformMatrices: Nullable<Float32Array>;
  24089. /**
  24090. * Gets or sets a skeleton to apply skining transformations
  24091. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24092. */
  24093. skeleton: Nullable<Skeleton>;
  24094. /**
  24095. * An event triggered when the mesh is rebuilt.
  24096. */
  24097. onRebuildObservable: Observable<AbstractMesh>;
  24098. /**
  24099. * Creates a new AbstractMesh
  24100. * @param name defines the name of the mesh
  24101. * @param scene defines the hosting scene
  24102. */
  24103. constructor(name: string, scene?: Nullable<Scene>);
  24104. /**
  24105. * Returns the string "AbstractMesh"
  24106. * @returns "AbstractMesh"
  24107. */
  24108. getClassName(): string;
  24109. /**
  24110. * Gets a string representation of the current mesh
  24111. * @param fullDetails defines a boolean indicating if full details must be included
  24112. * @returns a string representation of the current mesh
  24113. */
  24114. toString(fullDetails?: boolean): string;
  24115. /** @hidden */
  24116. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24117. /** @hidden */
  24118. _rebuild(): void;
  24119. /** @hidden */
  24120. _resyncLightSources(): void;
  24121. /** @hidden */
  24122. _resyncLighSource(light: Light): void;
  24123. /** @hidden */
  24124. _unBindEffect(): void;
  24125. /** @hidden */
  24126. _removeLightSource(light: Light): void;
  24127. private _markSubMeshesAsDirty;
  24128. /** @hidden */
  24129. _markSubMeshesAsLightDirty(): void;
  24130. /** @hidden */
  24131. _markSubMeshesAsAttributesDirty(): void;
  24132. /** @hidden */
  24133. _markSubMeshesAsMiscDirty(): void;
  24134. /**
  24135. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24136. */
  24137. scaling: Vector3;
  24138. /**
  24139. * Returns true if the mesh is blocked. Implemented by child classes
  24140. */
  24141. readonly isBlocked: boolean;
  24142. /**
  24143. * Returns the mesh itself by default. Implemented by child classes
  24144. * @param camera defines the camera to use to pick the right LOD level
  24145. * @returns the currentAbstractMesh
  24146. */
  24147. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24148. /**
  24149. * Returns 0 by default. Implemented by child classes
  24150. * @returns an integer
  24151. */
  24152. getTotalVertices(): number;
  24153. /**
  24154. * Returns a positive integer : the total number of indices in this mesh geometry.
  24155. * @returns the numner of indices or zero if the mesh has no geometry.
  24156. */
  24157. getTotalIndices(): number;
  24158. /**
  24159. * Returns null by default. Implemented by child classes
  24160. * @returns null
  24161. */
  24162. getIndices(): Nullable<IndicesArray>;
  24163. /**
  24164. * Returns the array of the requested vertex data kind. Implemented by child classes
  24165. * @param kind defines the vertex data kind to use
  24166. * @returns null
  24167. */
  24168. getVerticesData(kind: string): Nullable<FloatArray>;
  24169. /**
  24170. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24171. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24172. * Note that a new underlying VertexBuffer object is created each call.
  24173. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24174. * @param kind defines vertex data kind:
  24175. * * VertexBuffer.PositionKind
  24176. * * VertexBuffer.UVKind
  24177. * * VertexBuffer.UV2Kind
  24178. * * VertexBuffer.UV3Kind
  24179. * * VertexBuffer.UV4Kind
  24180. * * VertexBuffer.UV5Kind
  24181. * * VertexBuffer.UV6Kind
  24182. * * VertexBuffer.ColorKind
  24183. * * VertexBuffer.MatricesIndicesKind
  24184. * * VertexBuffer.MatricesIndicesExtraKind
  24185. * * VertexBuffer.MatricesWeightsKind
  24186. * * VertexBuffer.MatricesWeightsExtraKind
  24187. * @param data defines the data source
  24188. * @param updatable defines if the data must be flagged as updatable (or static)
  24189. * @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
  24190. * @returns the current mesh
  24191. */
  24192. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24193. /**
  24194. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24195. * If the mesh has no geometry, it is simply returned as it is.
  24196. * @param kind defines vertex data kind:
  24197. * * VertexBuffer.PositionKind
  24198. * * VertexBuffer.UVKind
  24199. * * VertexBuffer.UV2Kind
  24200. * * VertexBuffer.UV3Kind
  24201. * * VertexBuffer.UV4Kind
  24202. * * VertexBuffer.UV5Kind
  24203. * * VertexBuffer.UV6Kind
  24204. * * VertexBuffer.ColorKind
  24205. * * VertexBuffer.MatricesIndicesKind
  24206. * * VertexBuffer.MatricesIndicesExtraKind
  24207. * * VertexBuffer.MatricesWeightsKind
  24208. * * VertexBuffer.MatricesWeightsExtraKind
  24209. * @param data defines the data source
  24210. * @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
  24211. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24212. * @returns the current mesh
  24213. */
  24214. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24215. /**
  24216. * Sets the mesh indices,
  24217. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24218. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24219. * @param totalVertices Defines the total number of vertices
  24220. * @returns the current mesh
  24221. */
  24222. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24223. /**
  24224. * Gets a boolean indicating if specific vertex data is present
  24225. * @param kind defines the vertex data kind to use
  24226. * @returns true is data kind is present
  24227. */
  24228. isVerticesDataPresent(kind: string): boolean;
  24229. /**
  24230. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24231. * @returns a BoundingInfo
  24232. */
  24233. getBoundingInfo(): BoundingInfo;
  24234. /**
  24235. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24236. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24237. * @returns the current mesh
  24238. */
  24239. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24240. /**
  24241. * Overwrite the current bounding info
  24242. * @param boundingInfo defines the new bounding info
  24243. * @returns the current mesh
  24244. */
  24245. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24246. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24247. readonly useBones: boolean;
  24248. /** @hidden */
  24249. _preActivate(): void;
  24250. /** @hidden */
  24251. _preActivateForIntermediateRendering(renderId: number): void;
  24252. /** @hidden */
  24253. _activate(renderId: number): void;
  24254. /**
  24255. * Gets the current world matrix
  24256. * @returns a Matrix
  24257. */
  24258. getWorldMatrix(): Matrix;
  24259. /** @hidden */
  24260. _getWorldMatrixDeterminant(): number;
  24261. /**
  24262. * Perform relative position change from the point of view of behind the front of the mesh.
  24263. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24264. * Supports definition of mesh facing forward or backward
  24265. * @param amountRight defines the distance on the right axis
  24266. * @param amountUp defines the distance on the up axis
  24267. * @param amountForward defines the distance on the forward axis
  24268. * @returns the current mesh
  24269. */
  24270. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24271. /**
  24272. * Calculate relative position change from the point of view of behind the front of the mesh.
  24273. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24274. * Supports definition of mesh facing forward or backward
  24275. * @param amountRight defines the distance on the right axis
  24276. * @param amountUp defines the distance on the up axis
  24277. * @param amountForward defines the distance on the forward axis
  24278. * @returns the new displacement vector
  24279. */
  24280. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24281. /**
  24282. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24283. * Supports definition of mesh facing forward or backward
  24284. * @param flipBack defines the flip
  24285. * @param twirlClockwise defines the twirl
  24286. * @param tiltRight defines the tilt
  24287. * @returns the current mesh
  24288. */
  24289. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24290. /**
  24291. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24292. * Supports definition of mesh facing forward or backward.
  24293. * @param flipBack defines the flip
  24294. * @param twirlClockwise defines the twirl
  24295. * @param tiltRight defines the tilt
  24296. * @returns the new rotation vector
  24297. */
  24298. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24299. /**
  24300. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24301. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24302. * @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
  24303. * @returns the new bounding vectors
  24304. */
  24305. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24306. min: Vector3;
  24307. max: Vector3;
  24308. };
  24309. /**
  24310. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24311. * This means the mesh underlying bounding box and sphere are recomputed.
  24312. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24313. * @returns the current mesh
  24314. */
  24315. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24316. /** @hidden */
  24317. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24318. /** @hidden */
  24319. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24320. /** @hidden */
  24321. _updateBoundingInfo(): AbstractMesh;
  24322. /** @hidden */
  24323. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24324. /** @hidden */
  24325. protected _afterComputeWorldMatrix(): void;
  24326. /**
  24327. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24328. * A mesh is in the frustum if its bounding box intersects the frustum
  24329. * @param frustumPlanes defines the frustum to test
  24330. * @returns true if the mesh is in the frustum planes
  24331. */
  24332. isInFrustum(frustumPlanes: Plane[]): boolean;
  24333. /**
  24334. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24335. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24336. * @param frustumPlanes defines the frustum to test
  24337. * @returns true if the mesh is completely in the frustum planes
  24338. */
  24339. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24340. /**
  24341. * True if the mesh intersects another mesh or a SolidParticle object
  24342. * @param mesh defines a target mesh or SolidParticle to test
  24343. * @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)
  24344. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24345. * @returns true if there is an intersection
  24346. */
  24347. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24348. /**
  24349. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24350. * @param point defines the point to test
  24351. * @returns true if there is an intersection
  24352. */
  24353. intersectsPoint(point: Vector3): boolean;
  24354. /**
  24355. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24356. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24357. */
  24358. checkCollisions: boolean;
  24359. /**
  24360. * Gets Collider object used to compute collisions (not physics)
  24361. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24362. */
  24363. readonly collider: Collider;
  24364. /**
  24365. * Move the mesh using collision engine
  24366. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24367. * @param displacement defines the requested displacement vector
  24368. * @returns the current mesh
  24369. */
  24370. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24371. private _onCollisionPositionChange;
  24372. /** @hidden */
  24373. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24374. /** @hidden */
  24375. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24376. /** @hidden */
  24377. _checkCollision(collider: Collider): AbstractMesh;
  24378. /** @hidden */
  24379. _generatePointsArray(): boolean;
  24380. /**
  24381. * Checks if the passed Ray intersects with the mesh
  24382. * @param ray defines the ray to use
  24383. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24384. * @returns the picking info
  24385. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24386. */
  24387. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24388. /**
  24389. * Clones the current mesh
  24390. * @param name defines the mesh name
  24391. * @param newParent defines the new mesh parent
  24392. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24393. * @returns the new mesh
  24394. */
  24395. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24396. /**
  24397. * Disposes all the submeshes of the current meshnp
  24398. * @returns the current mesh
  24399. */
  24400. releaseSubMeshes(): AbstractMesh;
  24401. /**
  24402. * Releases resources associated with this abstract mesh.
  24403. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24404. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24405. */
  24406. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24407. /**
  24408. * Adds the passed mesh as a child to the current mesh
  24409. * @param mesh defines the child mesh
  24410. * @returns the current mesh
  24411. */
  24412. addChild(mesh: AbstractMesh): AbstractMesh;
  24413. /**
  24414. * Removes the passed mesh from the current mesh children list
  24415. * @param mesh defines the child mesh
  24416. * @returns the current mesh
  24417. */
  24418. removeChild(mesh: AbstractMesh): AbstractMesh;
  24419. /** @hidden */
  24420. private _initFacetData;
  24421. /**
  24422. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24423. * This method can be called within the render loop.
  24424. * 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
  24425. * @returns the current mesh
  24426. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24427. */
  24428. updateFacetData(): AbstractMesh;
  24429. /**
  24430. * Returns the facetLocalNormals array.
  24431. * The normals are expressed in the mesh local spac
  24432. * @returns an array of Vector3
  24433. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24434. */
  24435. getFacetLocalNormals(): Vector3[];
  24436. /**
  24437. * Returns the facetLocalPositions array.
  24438. * The facet positions are expressed in the mesh local space
  24439. * @returns an array of Vector3
  24440. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24441. */
  24442. getFacetLocalPositions(): Vector3[];
  24443. /**
  24444. * Returns the facetLocalPartioning array
  24445. * @returns an array of array of numbers
  24446. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24447. */
  24448. getFacetLocalPartitioning(): number[][];
  24449. /**
  24450. * Returns the i-th facet position in the world system.
  24451. * This method allocates a new Vector3 per call
  24452. * @param i defines the facet index
  24453. * @returns a new Vector3
  24454. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24455. */
  24456. getFacetPosition(i: number): Vector3;
  24457. /**
  24458. * Sets the reference Vector3 with the i-th facet position in the world system
  24459. * @param i defines the facet index
  24460. * @param ref defines the target vector
  24461. * @returns the current mesh
  24462. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24463. */
  24464. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24465. /**
  24466. * Returns the i-th facet normal in the world system.
  24467. * This method allocates a new Vector3 per call
  24468. * @param i defines the facet index
  24469. * @returns a new Vector3
  24470. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24471. */
  24472. getFacetNormal(i: number): Vector3;
  24473. /**
  24474. * Sets the reference Vector3 with the i-th facet normal in the world system
  24475. * @param i defines the facet index
  24476. * @param ref defines the target vector
  24477. * @returns the current mesh
  24478. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24479. */
  24480. getFacetNormalToRef(i: number, ref: Vector3): this;
  24481. /**
  24482. * 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)
  24483. * @param x defines x coordinate
  24484. * @param y defines y coordinate
  24485. * @param z defines z coordinate
  24486. * @returns the array of facet indexes
  24487. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24488. */
  24489. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24490. /**
  24491. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24492. * @param projected sets as the (x,y,z) world projection on the facet
  24493. * @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
  24494. * @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
  24495. * @param x defines x coordinate
  24496. * @param y defines y coordinate
  24497. * @param z defines z coordinate
  24498. * @returns the face index if found (or null instead)
  24499. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24500. */
  24501. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24502. /**
  24503. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24504. * @param projected sets as the (x,y,z) local projection on the facet
  24505. * @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
  24506. * @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
  24507. * @param x defines x coordinate
  24508. * @param y defines y coordinate
  24509. * @param z defines z coordinate
  24510. * @returns the face index if found (or null instead)
  24511. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24512. */
  24513. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24514. /**
  24515. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24516. * @returns the parameters
  24517. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24518. */
  24519. getFacetDataParameters(): any;
  24520. /**
  24521. * Disables the feature FacetData and frees the related memory
  24522. * @returns the current mesh
  24523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24524. */
  24525. disableFacetData(): AbstractMesh;
  24526. /**
  24527. * Updates the AbstractMesh indices array
  24528. * @param indices defines the data source
  24529. * @returns the current mesh
  24530. */
  24531. updateIndices(indices: IndicesArray): AbstractMesh;
  24532. /**
  24533. * Creates new normals data for the mesh
  24534. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24535. * @returns the current mesh
  24536. */
  24537. createNormals(updatable: boolean): AbstractMesh;
  24538. /**
  24539. * Align the mesh with a normal
  24540. * @param normal defines the normal to use
  24541. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24542. * @returns the current mesh
  24543. */
  24544. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24545. /** @hidden */
  24546. _checkOcclusionQuery(): boolean;
  24547. }
  24548. }
  24549. declare module "babylonjs/Actions/actionEvent" {
  24550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24551. import { Nullable } from "babylonjs/types";
  24552. import { Sprite } from "babylonjs/Sprites/sprite";
  24553. import { Scene } from "babylonjs/scene";
  24554. import { Vector2 } from "babylonjs/Maths/math";
  24555. /**
  24556. * Interface used to define ActionEvent
  24557. */
  24558. export interface IActionEvent {
  24559. /** The mesh or sprite that triggered the action */
  24560. source: any;
  24561. /** The X mouse cursor position at the time of the event */
  24562. pointerX: number;
  24563. /** The Y mouse cursor position at the time of the event */
  24564. pointerY: number;
  24565. /** The mesh that is currently pointed at (can be null) */
  24566. meshUnderPointer: Nullable<AbstractMesh>;
  24567. /** the original (browser) event that triggered the ActionEvent */
  24568. sourceEvent?: any;
  24569. /** additional data for the event */
  24570. additionalData?: any;
  24571. }
  24572. /**
  24573. * ActionEvent is the event being sent when an action is triggered.
  24574. */
  24575. export class ActionEvent implements IActionEvent {
  24576. /** The mesh or sprite that triggered the action */
  24577. source: any;
  24578. /** The X mouse cursor position at the time of the event */
  24579. pointerX: number;
  24580. /** The Y mouse cursor position at the time of the event */
  24581. pointerY: number;
  24582. /** The mesh that is currently pointed at (can be null) */
  24583. meshUnderPointer: Nullable<AbstractMesh>;
  24584. /** the original (browser) event that triggered the ActionEvent */
  24585. sourceEvent?: any;
  24586. /** additional data for the event */
  24587. additionalData?: any;
  24588. /**
  24589. * Creates a new ActionEvent
  24590. * @param source The mesh or sprite that triggered the action
  24591. * @param pointerX The X mouse cursor position at the time of the event
  24592. * @param pointerY The Y mouse cursor position at the time of the event
  24593. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24594. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24595. * @param additionalData additional data for the event
  24596. */
  24597. constructor(
  24598. /** The mesh or sprite that triggered the action */
  24599. source: any,
  24600. /** The X mouse cursor position at the time of the event */
  24601. pointerX: number,
  24602. /** The Y mouse cursor position at the time of the event */
  24603. pointerY: number,
  24604. /** The mesh that is currently pointed at (can be null) */
  24605. meshUnderPointer: Nullable<AbstractMesh>,
  24606. /** the original (browser) event that triggered the ActionEvent */
  24607. sourceEvent?: any,
  24608. /** additional data for the event */
  24609. additionalData?: any);
  24610. /**
  24611. * Helper function to auto-create an ActionEvent from a source mesh.
  24612. * @param source The source mesh that triggered the event
  24613. * @param evt The original (browser) event
  24614. * @param additionalData additional data for the event
  24615. * @returns the new ActionEvent
  24616. */
  24617. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24618. /**
  24619. * Helper function to auto-create an ActionEvent from a source sprite
  24620. * @param source The source sprite that triggered the event
  24621. * @param scene Scene associated with the sprite
  24622. * @param evt The original (browser) event
  24623. * @param additionalData additional data for the event
  24624. * @returns the new ActionEvent
  24625. */
  24626. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24627. /**
  24628. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24629. * @param scene the scene where the event occurred
  24630. * @param evt The original (browser) event
  24631. * @returns the new ActionEvent
  24632. */
  24633. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24634. /**
  24635. * Helper function to auto-create an ActionEvent from a primitive
  24636. * @param prim defines the target primitive
  24637. * @param pointerPos defines the pointer position
  24638. * @param evt The original (browser) event
  24639. * @param additionalData additional data for the event
  24640. * @returns the new ActionEvent
  24641. */
  24642. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24643. }
  24644. }
  24645. declare module "babylonjs/Actions/abstractActionManager" {
  24646. import { IDisposable } from "babylonjs/scene";
  24647. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  24648. import { IAction } from "babylonjs/Actions/action";
  24649. /**
  24650. * Abstract class used to decouple action Manager from scene and meshes.
  24651. * Do not instantiate.
  24652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24653. */
  24654. export abstract class AbstractActionManager implements IDisposable {
  24655. /** Gets the list of active triggers */
  24656. static Triggers: {
  24657. [key: string]: number;
  24658. };
  24659. /** Gets the cursor to use when hovering items */
  24660. hoverCursor: string;
  24661. /** Gets the list of actions */
  24662. actions: IAction[];
  24663. /**
  24664. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24665. */
  24666. isRecursive: boolean;
  24667. /**
  24668. * Releases all associated resources
  24669. */
  24670. abstract dispose(): void;
  24671. /**
  24672. * Does this action manager has pointer triggers
  24673. */
  24674. abstract readonly hasPointerTriggers: boolean;
  24675. /**
  24676. * Does this action manager has pick triggers
  24677. */
  24678. abstract readonly hasPickTriggers: boolean;
  24679. /**
  24680. * Process a specific trigger
  24681. * @param trigger defines the trigger to process
  24682. * @param evt defines the event details to be processed
  24683. */
  24684. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24685. /**
  24686. * Does this action manager handles actions of any of the given triggers
  24687. * @param triggers defines the triggers to be tested
  24688. * @return a boolean indicating whether one (or more) of the triggers is handled
  24689. */
  24690. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24691. /**
  24692. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24693. * speed.
  24694. * @param triggerA defines the trigger to be tested
  24695. * @param triggerB defines the trigger to be tested
  24696. * @return a boolean indicating whether one (or more) of the triggers is handled
  24697. */
  24698. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24699. /**
  24700. * Does this action manager handles actions of a given trigger
  24701. * @param trigger defines the trigger to be tested
  24702. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24703. * @return whether the trigger is handled
  24704. */
  24705. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24706. /**
  24707. * Serialize this manager to a JSON object
  24708. * @param name defines the property name to store this manager
  24709. * @returns a JSON representation of this manager
  24710. */
  24711. abstract serialize(name: string): any;
  24712. /**
  24713. * Does exist one action manager with at least one trigger
  24714. **/
  24715. static readonly HasTriggers: boolean;
  24716. /**
  24717. * Does exist one action manager with at least one pick trigger
  24718. **/
  24719. static readonly HasPickTriggers: boolean;
  24720. /**
  24721. * Does exist one action manager that handles actions of a given trigger
  24722. * @param trigger defines the trigger to be tested
  24723. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24724. **/
  24725. static HasSpecificTrigger(trigger: number): boolean;
  24726. }
  24727. }
  24728. declare module "babylonjs/node" {
  24729. import { Scene } from "babylonjs/scene";
  24730. import { Nullable } from "babylonjs/types";
  24731. import { Matrix } from "babylonjs/Maths/math";
  24732. import { Engine } from "babylonjs/Engines/engine";
  24733. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24734. import { Observable } from "babylonjs/Misc/observable";
  24735. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24736. import { Animatable } from "babylonjs/Animations/animatable";
  24737. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24738. import { Animation } from "babylonjs/Animations/animation";
  24739. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24741. /**
  24742. * Defines how a node can be built from a string name.
  24743. */
  24744. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24745. /**
  24746. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24747. */
  24748. export class Node implements IBehaviorAware<Node> {
  24749. /** @hidden */
  24750. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24751. private static _NodeConstructors;
  24752. /**
  24753. * Add a new node constructor
  24754. * @param type defines the type name of the node to construct
  24755. * @param constructorFunc defines the constructor function
  24756. */
  24757. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24758. /**
  24759. * Returns a node constructor based on type name
  24760. * @param type defines the type name
  24761. * @param name defines the new node name
  24762. * @param scene defines the hosting scene
  24763. * @param options defines optional options to transmit to constructors
  24764. * @returns the new constructor or null
  24765. */
  24766. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24767. /**
  24768. * Gets or sets the name of the node
  24769. */
  24770. name: string;
  24771. /**
  24772. * Gets or sets the id of the node
  24773. */
  24774. id: string;
  24775. /**
  24776. * Gets or sets the unique id of the node
  24777. */
  24778. uniqueId: number;
  24779. /**
  24780. * Gets or sets a string used to store user defined state for the node
  24781. */
  24782. state: string;
  24783. /**
  24784. * Gets or sets an object used to store user defined information for the node
  24785. */
  24786. metadata: any;
  24787. /**
  24788. * For internal use only. Please do not use.
  24789. */
  24790. reservedDataStore: any;
  24791. /**
  24792. * Gets or sets a boolean used to define if the node must be serialized
  24793. */
  24794. doNotSerialize: boolean;
  24795. /** @hidden */
  24796. _isDisposed: boolean;
  24797. /**
  24798. * Gets a list of Animations associated with the node
  24799. */
  24800. animations: import("babylonjs/Animations/animation").Animation[];
  24801. protected _ranges: {
  24802. [name: string]: Nullable<AnimationRange>;
  24803. };
  24804. /**
  24805. * Callback raised when the node is ready to be used
  24806. */
  24807. onReady: (node: Node) => void;
  24808. private _isEnabled;
  24809. private _isParentEnabled;
  24810. private _isReady;
  24811. /** @hidden */
  24812. _currentRenderId: number;
  24813. private _parentRenderId;
  24814. protected _childRenderId: number;
  24815. /** @hidden */
  24816. _waitingParentId: Nullable<string>;
  24817. /** @hidden */
  24818. _scene: Scene;
  24819. /** @hidden */
  24820. _cache: any;
  24821. private _parentNode;
  24822. private _children;
  24823. /** @hidden */
  24824. _worldMatrix: Matrix;
  24825. /** @hidden */
  24826. _worldMatrixDeterminant: number;
  24827. /** @hidden */
  24828. private _sceneRootNodesIndex;
  24829. /**
  24830. * Gets a boolean indicating if the node has been disposed
  24831. * @returns true if the node was disposed
  24832. */
  24833. isDisposed(): boolean;
  24834. /**
  24835. * Gets or sets the parent of the node
  24836. */
  24837. parent: Nullable<Node>;
  24838. private addToSceneRootNodes;
  24839. private removeFromSceneRootNodes;
  24840. private _animationPropertiesOverride;
  24841. /**
  24842. * Gets or sets the animation properties override
  24843. */
  24844. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24845. /**
  24846. * Gets a string idenfifying the name of the class
  24847. * @returns "Node" string
  24848. */
  24849. getClassName(): string;
  24850. /** @hidden */
  24851. readonly _isNode: boolean;
  24852. /**
  24853. * An event triggered when the mesh is disposed
  24854. */
  24855. onDisposeObservable: Observable<Node>;
  24856. private _onDisposeObserver;
  24857. /**
  24858. * Sets a callback that will be raised when the node will be disposed
  24859. */
  24860. onDispose: () => void;
  24861. /**
  24862. * Creates a new Node
  24863. * @param name the name and id to be given to this node
  24864. * @param scene the scene this node will be added to
  24865. * @param addToRootNodes the node will be added to scene.rootNodes
  24866. */
  24867. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24868. /**
  24869. * Gets the scene of the node
  24870. * @returns a scene
  24871. */
  24872. getScene(): Scene;
  24873. /**
  24874. * Gets the engine of the node
  24875. * @returns a Engine
  24876. */
  24877. getEngine(): Engine;
  24878. private _behaviors;
  24879. /**
  24880. * Attach a behavior to the node
  24881. * @see http://doc.babylonjs.com/features/behaviour
  24882. * @param behavior defines the behavior to attach
  24883. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24884. * @returns the current Node
  24885. */
  24886. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24887. /**
  24888. * Remove an attached behavior
  24889. * @see http://doc.babylonjs.com/features/behaviour
  24890. * @param behavior defines the behavior to attach
  24891. * @returns the current Node
  24892. */
  24893. removeBehavior(behavior: Behavior<Node>): Node;
  24894. /**
  24895. * Gets the list of attached behaviors
  24896. * @see http://doc.babylonjs.com/features/behaviour
  24897. */
  24898. readonly behaviors: Behavior<Node>[];
  24899. /**
  24900. * Gets an attached behavior by name
  24901. * @param name defines the name of the behavior to look for
  24902. * @see http://doc.babylonjs.com/features/behaviour
  24903. * @returns null if behavior was not found else the requested behavior
  24904. */
  24905. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24906. /**
  24907. * Returns the latest update of the World matrix
  24908. * @returns a Matrix
  24909. */
  24910. getWorldMatrix(): Matrix;
  24911. /** @hidden */
  24912. _getWorldMatrixDeterminant(): number;
  24913. /**
  24914. * Returns directly the latest state of the mesh World matrix.
  24915. * A Matrix is returned.
  24916. */
  24917. readonly worldMatrixFromCache: Matrix;
  24918. /** @hidden */
  24919. _initCache(): void;
  24920. /** @hidden */
  24921. updateCache(force?: boolean): void;
  24922. /** @hidden */
  24923. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24924. /** @hidden */
  24925. _updateCache(ignoreParentClass?: boolean): void;
  24926. /** @hidden */
  24927. _isSynchronized(): boolean;
  24928. /** @hidden */
  24929. _markSyncedWithParent(): void;
  24930. /** @hidden */
  24931. isSynchronizedWithParent(): boolean;
  24932. /** @hidden */
  24933. isSynchronized(): boolean;
  24934. /**
  24935. * Is this node ready to be used/rendered
  24936. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24937. * @return true if the node is ready
  24938. */
  24939. isReady(completeCheck?: boolean): boolean;
  24940. /**
  24941. * Is this node enabled?
  24942. * 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
  24943. * @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
  24944. * @return whether this node (and its parent) is enabled
  24945. */
  24946. isEnabled(checkAncestors?: boolean): boolean;
  24947. /** @hidden */
  24948. protected _syncParentEnabledState(): void;
  24949. /**
  24950. * Set the enabled state of this node
  24951. * @param value defines the new enabled state
  24952. */
  24953. setEnabled(value: boolean): void;
  24954. /**
  24955. * Is this node a descendant of the given node?
  24956. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24957. * @param ancestor defines the parent node to inspect
  24958. * @returns a boolean indicating if this node is a descendant of the given node
  24959. */
  24960. isDescendantOf(ancestor: Node): boolean;
  24961. /** @hidden */
  24962. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24963. /**
  24964. * Will return all nodes that have this node as ascendant
  24965. * @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
  24966. * @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
  24967. * @return all children nodes of all types
  24968. */
  24969. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24970. /**
  24971. * Get all child-meshes of this node
  24972. * @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)
  24973. * @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
  24974. * @returns an array of AbstractMesh
  24975. */
  24976. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24977. /**
  24978. * Get all direct children of this node
  24979. * @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
  24980. * @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)
  24981. * @returns an array of Node
  24982. */
  24983. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24984. /** @hidden */
  24985. _setReady(state: boolean): void;
  24986. /**
  24987. * Get an animation by name
  24988. * @param name defines the name of the animation to look for
  24989. * @returns null if not found else the requested animation
  24990. */
  24991. getAnimationByName(name: string): Nullable<Animation>;
  24992. /**
  24993. * Creates an animation range for this node
  24994. * @param name defines the name of the range
  24995. * @param from defines the starting key
  24996. * @param to defines the end key
  24997. */
  24998. createAnimationRange(name: string, from: number, to: number): void;
  24999. /**
  25000. * Delete a specific animation range
  25001. * @param name defines the name of the range to delete
  25002. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25003. */
  25004. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25005. /**
  25006. * Get an animation range by name
  25007. * @param name defines the name of the animation range to look for
  25008. * @returns null if not found else the requested animation range
  25009. */
  25010. getAnimationRange(name: string): Nullable<AnimationRange>;
  25011. /**
  25012. * Gets the list of all animation ranges defined on this node
  25013. * @returns an array
  25014. */
  25015. getAnimationRanges(): Nullable<AnimationRange>[];
  25016. /**
  25017. * Will start the animation sequence
  25018. * @param name defines the range frames for animation sequence
  25019. * @param loop defines if the animation should loop (false by default)
  25020. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25021. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25022. * @returns the object created for this animation. If range does not exist, it will return null
  25023. */
  25024. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25025. /**
  25026. * Serialize animation ranges into a JSON compatible object
  25027. * @returns serialization object
  25028. */
  25029. serializeAnimationRanges(): any;
  25030. /**
  25031. * Computes the world matrix of the node
  25032. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25033. * @returns the world matrix
  25034. */
  25035. computeWorldMatrix(force?: boolean): Matrix;
  25036. /**
  25037. * Releases resources associated with this node.
  25038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25040. */
  25041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25042. /**
  25043. * Parse animation range data from a serialization object and store them into a given node
  25044. * @param node defines where to store the animation ranges
  25045. * @param parsedNode defines the serialization object to read data from
  25046. * @param scene defines the hosting scene
  25047. */
  25048. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25049. }
  25050. }
  25051. declare module "babylonjs/Animations/animation" {
  25052. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25053. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25054. import { Nullable } from "babylonjs/types";
  25055. import { Scene } from "babylonjs/scene";
  25056. import { IAnimatable } from "babylonjs/Misc/tools";
  25057. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25058. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25059. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25060. import { Node } from "babylonjs/node";
  25061. import { Animatable } from "babylonjs/Animations/animatable";
  25062. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25063. /**
  25064. * Class used to store any kind of animation
  25065. */
  25066. export class Animation {
  25067. /**Name of the animation */
  25068. name: string;
  25069. /**Property to animate */
  25070. targetProperty: string;
  25071. /**The frames per second of the animation */
  25072. framePerSecond: number;
  25073. /**The data type of the animation */
  25074. dataType: number;
  25075. /**The loop mode of the animation */
  25076. loopMode?: number | undefined;
  25077. /**Specifies if blending should be enabled */
  25078. enableBlending?: boolean | undefined;
  25079. /**
  25080. * Use matrix interpolation instead of using direct key value when animating matrices
  25081. */
  25082. static AllowMatricesInterpolation: boolean;
  25083. /**
  25084. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25085. */
  25086. static AllowMatrixDecomposeForInterpolation: boolean;
  25087. /**
  25088. * Stores the key frames of the animation
  25089. */
  25090. private _keys;
  25091. /**
  25092. * Stores the easing function of the animation
  25093. */
  25094. private _easingFunction;
  25095. /**
  25096. * @hidden Internal use only
  25097. */
  25098. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25099. /**
  25100. * The set of event that will be linked to this animation
  25101. */
  25102. private _events;
  25103. /**
  25104. * Stores an array of target property paths
  25105. */
  25106. targetPropertyPath: string[];
  25107. /**
  25108. * Stores the blending speed of the animation
  25109. */
  25110. blendingSpeed: number;
  25111. /**
  25112. * Stores the animation ranges for the animation
  25113. */
  25114. private _ranges;
  25115. /**
  25116. * @hidden Internal use
  25117. */
  25118. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25119. /**
  25120. * Sets up an animation
  25121. * @param property The property to animate
  25122. * @param animationType The animation type to apply
  25123. * @param framePerSecond The frames per second of the animation
  25124. * @param easingFunction The easing function used in the animation
  25125. * @returns The created animation
  25126. */
  25127. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25128. /**
  25129. * Create and start an animation on a node
  25130. * @param name defines the name of the global animation that will be run on all nodes
  25131. * @param node defines the root node where the animation will take place
  25132. * @param targetProperty defines property to animate
  25133. * @param framePerSecond defines the number of frame per second yo use
  25134. * @param totalFrame defines the number of frames in total
  25135. * @param from defines the initial value
  25136. * @param to defines the final value
  25137. * @param loopMode defines which loop mode you want to use (off by default)
  25138. * @param easingFunction defines the easing function to use (linear by default)
  25139. * @param onAnimationEnd defines the callback to call when animation end
  25140. * @returns the animatable created for this animation
  25141. */
  25142. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25143. /**
  25144. * Create and start an animation on a node and its descendants
  25145. * @param name defines the name of the global animation that will be run on all nodes
  25146. * @param node defines the root node where the animation will take place
  25147. * @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
  25148. * @param targetProperty defines property to animate
  25149. * @param framePerSecond defines the number of frame per second to use
  25150. * @param totalFrame defines the number of frames in total
  25151. * @param from defines the initial value
  25152. * @param to defines the final value
  25153. * @param loopMode defines which loop mode you want to use (off by default)
  25154. * @param easingFunction defines the easing function to use (linear by default)
  25155. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25156. * @returns the list of animatables created for all nodes
  25157. * @example https://www.babylonjs-playground.com/#MH0VLI
  25158. */
  25159. 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[]>;
  25160. /**
  25161. * Creates a new animation, merges it with the existing animations and starts it
  25162. * @param name Name of the animation
  25163. * @param node Node which contains the scene that begins the animations
  25164. * @param targetProperty Specifies which property to animate
  25165. * @param framePerSecond The frames per second of the animation
  25166. * @param totalFrame The total number of frames
  25167. * @param from The frame at the beginning of the animation
  25168. * @param to The frame at the end of the animation
  25169. * @param loopMode Specifies the loop mode of the animation
  25170. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25171. * @param onAnimationEnd Callback to run once the animation is complete
  25172. * @returns Nullable animation
  25173. */
  25174. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25175. /**
  25176. * Transition property of an host to the target Value
  25177. * @param property The property to transition
  25178. * @param targetValue The target Value of the property
  25179. * @param host The object where the property to animate belongs
  25180. * @param scene Scene used to run the animation
  25181. * @param frameRate Framerate (in frame/s) to use
  25182. * @param transition The transition type we want to use
  25183. * @param duration The duration of the animation, in milliseconds
  25184. * @param onAnimationEnd Callback trigger at the end of the animation
  25185. * @returns Nullable animation
  25186. */
  25187. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25188. /**
  25189. * Return the array of runtime animations currently using this animation
  25190. */
  25191. readonly runtimeAnimations: RuntimeAnimation[];
  25192. /**
  25193. * Specifies if any of the runtime animations are currently running
  25194. */
  25195. readonly hasRunningRuntimeAnimations: boolean;
  25196. /**
  25197. * Initializes the animation
  25198. * @param name Name of the animation
  25199. * @param targetProperty Property to animate
  25200. * @param framePerSecond The frames per second of the animation
  25201. * @param dataType The data type of the animation
  25202. * @param loopMode The loop mode of the animation
  25203. * @param enableBlending Specifies if blending should be enabled
  25204. */
  25205. constructor(
  25206. /**Name of the animation */
  25207. name: string,
  25208. /**Property to animate */
  25209. targetProperty: string,
  25210. /**The frames per second of the animation */
  25211. framePerSecond: number,
  25212. /**The data type of the animation */
  25213. dataType: number,
  25214. /**The loop mode of the animation */
  25215. loopMode?: number | undefined,
  25216. /**Specifies if blending should be enabled */
  25217. enableBlending?: boolean | undefined);
  25218. /**
  25219. * Converts the animation to a string
  25220. * @param fullDetails support for multiple levels of logging within scene loading
  25221. * @returns String form of the animation
  25222. */
  25223. toString(fullDetails?: boolean): string;
  25224. /**
  25225. * Add an event to this animation
  25226. * @param event Event to add
  25227. */
  25228. addEvent(event: AnimationEvent): void;
  25229. /**
  25230. * Remove all events found at the given frame
  25231. * @param frame The frame to remove events from
  25232. */
  25233. removeEvents(frame: number): void;
  25234. /**
  25235. * Retrieves all the events from the animation
  25236. * @returns Events from the animation
  25237. */
  25238. getEvents(): AnimationEvent[];
  25239. /**
  25240. * Creates an animation range
  25241. * @param name Name of the animation range
  25242. * @param from Starting frame of the animation range
  25243. * @param to Ending frame of the animation
  25244. */
  25245. createRange(name: string, from: number, to: number): void;
  25246. /**
  25247. * Deletes an animation range by name
  25248. * @param name Name of the animation range to delete
  25249. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25250. */
  25251. deleteRange(name: string, deleteFrames?: boolean): void;
  25252. /**
  25253. * Gets the animation range by name, or null if not defined
  25254. * @param name Name of the animation range
  25255. * @returns Nullable animation range
  25256. */
  25257. getRange(name: string): Nullable<AnimationRange>;
  25258. /**
  25259. * Gets the key frames from the animation
  25260. * @returns The key frames of the animation
  25261. */
  25262. getKeys(): Array<IAnimationKey>;
  25263. /**
  25264. * Gets the highest frame rate of the animation
  25265. * @returns Highest frame rate of the animation
  25266. */
  25267. getHighestFrame(): number;
  25268. /**
  25269. * Gets the easing function of the animation
  25270. * @returns Easing function of the animation
  25271. */
  25272. getEasingFunction(): IEasingFunction;
  25273. /**
  25274. * Sets the easing function of the animation
  25275. * @param easingFunction A custom mathematical formula for animation
  25276. */
  25277. setEasingFunction(easingFunction: EasingFunction): void;
  25278. /**
  25279. * Interpolates a scalar linearly
  25280. * @param startValue Start value of the animation curve
  25281. * @param endValue End value of the animation curve
  25282. * @param gradient Scalar amount to interpolate
  25283. * @returns Interpolated scalar value
  25284. */
  25285. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25286. /**
  25287. * Interpolates a scalar cubically
  25288. * @param startValue Start value of the animation curve
  25289. * @param outTangent End tangent of the animation
  25290. * @param endValue End value of the animation curve
  25291. * @param inTangent Start tangent of the animation curve
  25292. * @param gradient Scalar amount to interpolate
  25293. * @returns Interpolated scalar value
  25294. */
  25295. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25296. /**
  25297. * Interpolates a quaternion using a spherical linear interpolation
  25298. * @param startValue Start value of the animation curve
  25299. * @param endValue End value of the animation curve
  25300. * @param gradient Scalar amount to interpolate
  25301. * @returns Interpolated quaternion value
  25302. */
  25303. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25304. /**
  25305. * Interpolates a quaternion cubically
  25306. * @param startValue Start value of the animation curve
  25307. * @param outTangent End tangent of the animation curve
  25308. * @param endValue End value of the animation curve
  25309. * @param inTangent Start tangent of the animation curve
  25310. * @param gradient Scalar amount to interpolate
  25311. * @returns Interpolated quaternion value
  25312. */
  25313. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25314. /**
  25315. * Interpolates a Vector3 linearl
  25316. * @param startValue Start value of the animation curve
  25317. * @param endValue End value of the animation curve
  25318. * @param gradient Scalar amount to interpolate
  25319. * @returns Interpolated scalar value
  25320. */
  25321. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25322. /**
  25323. * Interpolates a Vector3 cubically
  25324. * @param startValue Start value of the animation curve
  25325. * @param outTangent End tangent of the animation
  25326. * @param endValue End value of the animation curve
  25327. * @param inTangent Start tangent of the animation curve
  25328. * @param gradient Scalar amount to interpolate
  25329. * @returns InterpolatedVector3 value
  25330. */
  25331. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25332. /**
  25333. * Interpolates a Vector2 linearly
  25334. * @param startValue Start value of the animation curve
  25335. * @param endValue End value of the animation curve
  25336. * @param gradient Scalar amount to interpolate
  25337. * @returns Interpolated Vector2 value
  25338. */
  25339. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25340. /**
  25341. * Interpolates a Vector2 cubically
  25342. * @param startValue Start value of the animation curve
  25343. * @param outTangent End tangent of the animation
  25344. * @param endValue End value of the animation curve
  25345. * @param inTangent Start tangent of the animation curve
  25346. * @param gradient Scalar amount to interpolate
  25347. * @returns Interpolated Vector2 value
  25348. */
  25349. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25350. /**
  25351. * Interpolates a size linearly
  25352. * @param startValue Start value of the animation curve
  25353. * @param endValue End value of the animation curve
  25354. * @param gradient Scalar amount to interpolate
  25355. * @returns Interpolated Size value
  25356. */
  25357. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25358. /**
  25359. * Interpolates a Color3 linearly
  25360. * @param startValue Start value of the animation curve
  25361. * @param endValue End value of the animation curve
  25362. * @param gradient Scalar amount to interpolate
  25363. * @returns Interpolated Color3 value
  25364. */
  25365. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25366. /**
  25367. * @hidden Internal use only
  25368. */
  25369. _getKeyValue(value: any): any;
  25370. /**
  25371. * @hidden Internal use only
  25372. */
  25373. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25374. /**
  25375. * Defines the function to use to interpolate matrices
  25376. * @param startValue defines the start matrix
  25377. * @param endValue defines the end matrix
  25378. * @param gradient defines the gradient between both matrices
  25379. * @param result defines an optional target matrix where to store the interpolation
  25380. * @returns the interpolated matrix
  25381. */
  25382. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25383. /**
  25384. * Makes a copy of the animation
  25385. * @returns Cloned animation
  25386. */
  25387. clone(): Animation;
  25388. /**
  25389. * Sets the key frames of the animation
  25390. * @param values The animation key frames to set
  25391. */
  25392. setKeys(values: Array<IAnimationKey>): void;
  25393. /**
  25394. * Serializes the animation to an object
  25395. * @returns Serialized object
  25396. */
  25397. serialize(): any;
  25398. /**
  25399. * Float animation type
  25400. */
  25401. private static _ANIMATIONTYPE_FLOAT;
  25402. /**
  25403. * Vector3 animation type
  25404. */
  25405. private static _ANIMATIONTYPE_VECTOR3;
  25406. /**
  25407. * Quaternion animation type
  25408. */
  25409. private static _ANIMATIONTYPE_QUATERNION;
  25410. /**
  25411. * Matrix animation type
  25412. */
  25413. private static _ANIMATIONTYPE_MATRIX;
  25414. /**
  25415. * Color3 animation type
  25416. */
  25417. private static _ANIMATIONTYPE_COLOR3;
  25418. /**
  25419. * Vector2 animation type
  25420. */
  25421. private static _ANIMATIONTYPE_VECTOR2;
  25422. /**
  25423. * Size animation type
  25424. */
  25425. private static _ANIMATIONTYPE_SIZE;
  25426. /**
  25427. * Relative Loop Mode
  25428. */
  25429. private static _ANIMATIONLOOPMODE_RELATIVE;
  25430. /**
  25431. * Cycle Loop Mode
  25432. */
  25433. private static _ANIMATIONLOOPMODE_CYCLE;
  25434. /**
  25435. * Constant Loop Mode
  25436. */
  25437. private static _ANIMATIONLOOPMODE_CONSTANT;
  25438. /**
  25439. * Get the float animation type
  25440. */
  25441. static readonly ANIMATIONTYPE_FLOAT: number;
  25442. /**
  25443. * Get the Vector3 animation type
  25444. */
  25445. static readonly ANIMATIONTYPE_VECTOR3: number;
  25446. /**
  25447. * Get the Vector2 animation type
  25448. */
  25449. static readonly ANIMATIONTYPE_VECTOR2: number;
  25450. /**
  25451. * Get the Size animation type
  25452. */
  25453. static readonly ANIMATIONTYPE_SIZE: number;
  25454. /**
  25455. * Get the Quaternion animation type
  25456. */
  25457. static readonly ANIMATIONTYPE_QUATERNION: number;
  25458. /**
  25459. * Get the Matrix animation type
  25460. */
  25461. static readonly ANIMATIONTYPE_MATRIX: number;
  25462. /**
  25463. * Get the Color3 animation type
  25464. */
  25465. static readonly ANIMATIONTYPE_COLOR3: number;
  25466. /**
  25467. * Get the Relative Loop Mode
  25468. */
  25469. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25470. /**
  25471. * Get the Cycle Loop Mode
  25472. */
  25473. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25474. /**
  25475. * Get the Constant Loop Mode
  25476. */
  25477. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25478. /** @hidden */
  25479. static _UniversalLerp(left: any, right: any, amount: number): any;
  25480. /**
  25481. * Parses an animation object and creates an animation
  25482. * @param parsedAnimation Parsed animation object
  25483. * @returns Animation object
  25484. */
  25485. static Parse(parsedAnimation: any): Animation;
  25486. /**
  25487. * Appends the serialized animations from the source animations
  25488. * @param source Source containing the animations
  25489. * @param destination Target to store the animations
  25490. */
  25491. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25492. }
  25493. }
  25494. declare module "babylonjs/Materials/Textures/baseTexture" {
  25495. import { Observable } from "babylonjs/Misc/observable";
  25496. import { IAnimatable } from "babylonjs/Misc/tools";
  25497. import { Nullable } from "babylonjs/types";
  25498. import { Scene } from "babylonjs/scene";
  25499. import { Matrix, ISize } from "babylonjs/Maths/math";
  25500. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25501. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25502. /**
  25503. * Base class of all the textures in babylon.
  25504. * It groups all the common properties the materials, post process, lights... might need
  25505. * in order to make a correct use of the texture.
  25506. */
  25507. export class BaseTexture implements IAnimatable {
  25508. /**
  25509. * Default anisotropic filtering level for the application.
  25510. * It is set to 4 as a good tradeoff between perf and quality.
  25511. */
  25512. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25513. /**
  25514. * Gets or sets the unique id of the texture
  25515. */
  25516. uniqueId: number;
  25517. /**
  25518. * Define the name of the texture.
  25519. */
  25520. name: string;
  25521. /**
  25522. * Gets or sets an object used to store user defined information.
  25523. */
  25524. metadata: any;
  25525. /**
  25526. * For internal use only. Please do not use.
  25527. */
  25528. reservedDataStore: any;
  25529. private _hasAlpha;
  25530. /**
  25531. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25532. */
  25533. hasAlpha: boolean;
  25534. /**
  25535. * Defines if the alpha value should be determined via the rgb values.
  25536. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25537. */
  25538. getAlphaFromRGB: boolean;
  25539. /**
  25540. * Intensity or strength of the texture.
  25541. * It is commonly used by materials to fine tune the intensity of the texture
  25542. */
  25543. level: number;
  25544. /**
  25545. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25546. * This is part of the texture as textures usually maps to one uv set.
  25547. */
  25548. coordinatesIndex: number;
  25549. private _coordinatesMode;
  25550. /**
  25551. * How a texture is mapped.
  25552. *
  25553. * | Value | Type | Description |
  25554. * | ----- | ----------------------------------- | ----------- |
  25555. * | 0 | EXPLICIT_MODE | |
  25556. * | 1 | SPHERICAL_MODE | |
  25557. * | 2 | PLANAR_MODE | |
  25558. * | 3 | CUBIC_MODE | |
  25559. * | 4 | PROJECTION_MODE | |
  25560. * | 5 | SKYBOX_MODE | |
  25561. * | 6 | INVCUBIC_MODE | |
  25562. * | 7 | EQUIRECTANGULAR_MODE | |
  25563. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25564. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25565. */
  25566. coordinatesMode: number;
  25567. /**
  25568. * | Value | Type | Description |
  25569. * | ----- | ------------------ | ----------- |
  25570. * | 0 | CLAMP_ADDRESSMODE | |
  25571. * | 1 | WRAP_ADDRESSMODE | |
  25572. * | 2 | MIRROR_ADDRESSMODE | |
  25573. */
  25574. wrapU: number;
  25575. /**
  25576. * | Value | Type | Description |
  25577. * | ----- | ------------------ | ----------- |
  25578. * | 0 | CLAMP_ADDRESSMODE | |
  25579. * | 1 | WRAP_ADDRESSMODE | |
  25580. * | 2 | MIRROR_ADDRESSMODE | |
  25581. */
  25582. wrapV: number;
  25583. /**
  25584. * | Value | Type | Description |
  25585. * | ----- | ------------------ | ----------- |
  25586. * | 0 | CLAMP_ADDRESSMODE | |
  25587. * | 1 | WRAP_ADDRESSMODE | |
  25588. * | 2 | MIRROR_ADDRESSMODE | |
  25589. */
  25590. wrapR: number;
  25591. /**
  25592. * With compliant hardware and browser (supporting anisotropic filtering)
  25593. * this defines the level of anisotropic filtering in the texture.
  25594. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25595. */
  25596. anisotropicFilteringLevel: number;
  25597. /**
  25598. * Define if the texture is a cube texture or if false a 2d texture.
  25599. */
  25600. isCube: boolean;
  25601. /**
  25602. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25603. */
  25604. is3D: boolean;
  25605. /**
  25606. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25607. * HDR texture are usually stored in linear space.
  25608. * This only impacts the PBR and Background materials
  25609. */
  25610. gammaSpace: boolean;
  25611. /**
  25612. * Gets whether or not the texture contains RGBD data.
  25613. */
  25614. readonly isRGBD: boolean;
  25615. /**
  25616. * Is Z inverted in the texture (useful in a cube texture).
  25617. */
  25618. invertZ: boolean;
  25619. /**
  25620. * Are mip maps generated for this texture or not.
  25621. */
  25622. readonly noMipmap: boolean;
  25623. /**
  25624. * @hidden
  25625. */
  25626. lodLevelInAlpha: boolean;
  25627. /**
  25628. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25629. */
  25630. lodGenerationOffset: number;
  25631. /**
  25632. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25633. */
  25634. lodGenerationScale: number;
  25635. /**
  25636. * Define if the texture is a render target.
  25637. */
  25638. isRenderTarget: boolean;
  25639. /**
  25640. * Define the unique id of the texture in the scene.
  25641. */
  25642. readonly uid: string;
  25643. /**
  25644. * Return a string representation of the texture.
  25645. * @returns the texture as a string
  25646. */
  25647. toString(): string;
  25648. /**
  25649. * Get the class name of the texture.
  25650. * @returns "BaseTexture"
  25651. */
  25652. getClassName(): string;
  25653. /**
  25654. * Define the list of animation attached to the texture.
  25655. */
  25656. animations: import("babylonjs/Animations/animation").Animation[];
  25657. /**
  25658. * An event triggered when the texture is disposed.
  25659. */
  25660. onDisposeObservable: Observable<BaseTexture>;
  25661. private _onDisposeObserver;
  25662. /**
  25663. * Callback triggered when the texture has been disposed.
  25664. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25665. */
  25666. onDispose: () => void;
  25667. /**
  25668. * Define the current state of the loading sequence when in delayed load mode.
  25669. */
  25670. delayLoadState: number;
  25671. private _scene;
  25672. /** @hidden */
  25673. _texture: Nullable<InternalTexture>;
  25674. private _uid;
  25675. /**
  25676. * Define if the texture is preventinga material to render or not.
  25677. * If not and the texture is not ready, the engine will use a default black texture instead.
  25678. */
  25679. readonly isBlocking: boolean;
  25680. /**
  25681. * Instantiates a new BaseTexture.
  25682. * Base class of all the textures in babylon.
  25683. * It groups all the common properties the materials, post process, lights... might need
  25684. * in order to make a correct use of the texture.
  25685. * @param scene Define the scene the texture blongs to
  25686. */
  25687. constructor(scene: Nullable<Scene>);
  25688. /**
  25689. * Get the scene the texture belongs to.
  25690. * @returns the scene or null if undefined
  25691. */
  25692. getScene(): Nullable<Scene>;
  25693. /**
  25694. * Get the texture transform matrix used to offset tile the texture for istance.
  25695. * @returns the transformation matrix
  25696. */
  25697. getTextureMatrix(): Matrix;
  25698. /**
  25699. * Get the texture reflection matrix used to rotate/transform the reflection.
  25700. * @returns the reflection matrix
  25701. */
  25702. getReflectionTextureMatrix(): Matrix;
  25703. /**
  25704. * Get the underlying lower level texture from Babylon.
  25705. * @returns the insternal texture
  25706. */
  25707. getInternalTexture(): Nullable<InternalTexture>;
  25708. /**
  25709. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25710. * @returns true if ready or not blocking
  25711. */
  25712. isReadyOrNotBlocking(): boolean;
  25713. /**
  25714. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25715. * @returns true if fully ready
  25716. */
  25717. isReady(): boolean;
  25718. private _cachedSize;
  25719. /**
  25720. * Get the size of the texture.
  25721. * @returns the texture size.
  25722. */
  25723. getSize(): ISize;
  25724. /**
  25725. * Get the base size of the texture.
  25726. * It can be different from the size if the texture has been resized for POT for instance
  25727. * @returns the base size
  25728. */
  25729. getBaseSize(): ISize;
  25730. /**
  25731. * Update the sampling mode of the texture.
  25732. * Default is Trilinear mode.
  25733. *
  25734. * | Value | Type | Description |
  25735. * | ----- | ------------------ | ----------- |
  25736. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25737. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25738. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25739. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25740. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25741. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25742. * | 7 | NEAREST_LINEAR | |
  25743. * | 8 | NEAREST_NEAREST | |
  25744. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25745. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25746. * | 11 | LINEAR_LINEAR | |
  25747. * | 12 | LINEAR_NEAREST | |
  25748. *
  25749. * > _mag_: magnification filter (close to the viewer)
  25750. * > _min_: minification filter (far from the viewer)
  25751. * > _mip_: filter used between mip map levels
  25752. *@param samplingMode Define the new sampling mode of the texture
  25753. */
  25754. updateSamplingMode(samplingMode: number): void;
  25755. /**
  25756. * Scales the texture if is `canRescale()`
  25757. * @param ratio the resize factor we want to use to rescale
  25758. */
  25759. scale(ratio: number): void;
  25760. /**
  25761. * Get if the texture can rescale.
  25762. */
  25763. readonly canRescale: boolean;
  25764. /** @hidden */
  25765. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25766. /** @hidden */
  25767. _rebuild(): void;
  25768. /**
  25769. * Triggers the load sequence in delayed load mode.
  25770. */
  25771. delayLoad(): void;
  25772. /**
  25773. * Clones the texture.
  25774. * @returns the cloned texture
  25775. */
  25776. clone(): Nullable<BaseTexture>;
  25777. /**
  25778. * Get the texture underlying type (INT, FLOAT...)
  25779. */
  25780. readonly textureType: number;
  25781. /**
  25782. * Get the texture underlying format (RGB, RGBA...)
  25783. */
  25784. readonly textureFormat: number;
  25785. /**
  25786. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25787. * This will returns an RGBA array buffer containing either in values (0-255) or
  25788. * float values (0-1) depending of the underlying buffer type.
  25789. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25790. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25791. * @param buffer defines a user defined buffer to fill with data (can be null)
  25792. * @returns The Array buffer containing the pixels data.
  25793. */
  25794. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25795. /**
  25796. * Release and destroy the underlying lower level texture aka internalTexture.
  25797. */
  25798. releaseInternalTexture(): void;
  25799. /**
  25800. * Get the polynomial representation of the texture data.
  25801. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25802. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25803. */
  25804. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25805. /** @hidden */
  25806. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25807. /** @hidden */
  25808. readonly _lodTextureMid: Nullable<BaseTexture>;
  25809. /** @hidden */
  25810. readonly _lodTextureLow: Nullable<BaseTexture>;
  25811. /**
  25812. * Dispose the texture and release its associated resources.
  25813. */
  25814. dispose(): void;
  25815. /**
  25816. * Serialize the texture into a JSON representation that can be parsed later on.
  25817. * @returns the JSON representation of the texture
  25818. */
  25819. serialize(): any;
  25820. /**
  25821. * Helper function to be called back once a list of texture contains only ready textures.
  25822. * @param textures Define the list of textures to wait for
  25823. * @param callback Define the callback triggered once the entire list will be ready
  25824. */
  25825. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25826. }
  25827. }
  25828. declare module "babylonjs/Materials/uniformBuffer" {
  25829. import { Nullable, FloatArray } from "babylonjs/types";
  25830. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25831. import { Engine } from "babylonjs/Engines/engine";
  25832. import { Effect } from "babylonjs/Materials/effect";
  25833. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25834. /**
  25835. * Uniform buffer objects.
  25836. *
  25837. * Handles blocks of uniform on the GPU.
  25838. *
  25839. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25840. *
  25841. * For more information, please refer to :
  25842. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25843. */
  25844. export class UniformBuffer {
  25845. private _engine;
  25846. private _buffer;
  25847. private _data;
  25848. private _bufferData;
  25849. private _dynamic?;
  25850. private _uniformLocations;
  25851. private _uniformSizes;
  25852. private _uniformLocationPointer;
  25853. private _needSync;
  25854. private _noUBO;
  25855. private _currentEffect;
  25856. private static _MAX_UNIFORM_SIZE;
  25857. private static _tempBuffer;
  25858. /**
  25859. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25860. * This is dynamic to allow compat with webgl 1 and 2.
  25861. * You will need to pass the name of the uniform as well as the value.
  25862. */
  25863. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25864. /**
  25865. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25866. * This is dynamic to allow compat with webgl 1 and 2.
  25867. * You will need to pass the name of the uniform as well as the value.
  25868. */
  25869. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25870. /**
  25871. * Lambda to Update a single float in a uniform buffer.
  25872. * This is dynamic to allow compat with webgl 1 and 2.
  25873. * You will need to pass the name of the uniform as well as the value.
  25874. */
  25875. updateFloat: (name: string, x: number) => void;
  25876. /**
  25877. * Lambda to Update a vec2 of float in a uniform buffer.
  25878. * This is dynamic to allow compat with webgl 1 and 2.
  25879. * You will need to pass the name of the uniform as well as the value.
  25880. */
  25881. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25882. /**
  25883. * Lambda to Update a vec3 of float in a uniform buffer.
  25884. * This is dynamic to allow compat with webgl 1 and 2.
  25885. * You will need to pass the name of the uniform as well as the value.
  25886. */
  25887. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25888. /**
  25889. * Lambda to Update a vec4 of float in a uniform buffer.
  25890. * This is dynamic to allow compat with webgl 1 and 2.
  25891. * You will need to pass the name of the uniform as well as the value.
  25892. */
  25893. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25894. /**
  25895. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25896. * This is dynamic to allow compat with webgl 1 and 2.
  25897. * You will need to pass the name of the uniform as well as the value.
  25898. */
  25899. updateMatrix: (name: string, mat: Matrix) => void;
  25900. /**
  25901. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25902. * This is dynamic to allow compat with webgl 1 and 2.
  25903. * You will need to pass the name of the uniform as well as the value.
  25904. */
  25905. updateVector3: (name: string, vector: Vector3) => void;
  25906. /**
  25907. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25908. * This is dynamic to allow compat with webgl 1 and 2.
  25909. * You will need to pass the name of the uniform as well as the value.
  25910. */
  25911. updateVector4: (name: string, vector: Vector4) => void;
  25912. /**
  25913. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25914. * This is dynamic to allow compat with webgl 1 and 2.
  25915. * You will need to pass the name of the uniform as well as the value.
  25916. */
  25917. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25918. /**
  25919. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25920. * This is dynamic to allow compat with webgl 1 and 2.
  25921. * You will need to pass the name of the uniform as well as the value.
  25922. */
  25923. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25924. /**
  25925. * Instantiates a new Uniform buffer objects.
  25926. *
  25927. * Handles blocks of uniform on the GPU.
  25928. *
  25929. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25930. *
  25931. * For more information, please refer to :
  25932. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25933. * @param engine Define the engine the buffer is associated with
  25934. * @param data Define the data contained in the buffer
  25935. * @param dynamic Define if the buffer is updatable
  25936. */
  25937. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25938. /**
  25939. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25940. * or just falling back on setUniformXXX calls.
  25941. */
  25942. readonly useUbo: boolean;
  25943. /**
  25944. * Indicates if the WebGL underlying uniform buffer is in sync
  25945. * with the javascript cache data.
  25946. */
  25947. readonly isSync: boolean;
  25948. /**
  25949. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25950. * Also, a dynamic UniformBuffer will disable cache verification and always
  25951. * update the underlying WebGL uniform buffer to the GPU.
  25952. * @returns if Dynamic, otherwise false
  25953. */
  25954. isDynamic(): boolean;
  25955. /**
  25956. * The data cache on JS side.
  25957. * @returns the underlying data as a float array
  25958. */
  25959. getData(): Float32Array;
  25960. /**
  25961. * The underlying WebGL Uniform buffer.
  25962. * @returns the webgl buffer
  25963. */
  25964. getBuffer(): Nullable<WebGLBuffer>;
  25965. /**
  25966. * std140 layout specifies how to align data within an UBO structure.
  25967. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25968. * for specs.
  25969. */
  25970. private _fillAlignment;
  25971. /**
  25972. * Adds an uniform in the buffer.
  25973. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25974. * for the layout to be correct !
  25975. * @param name Name of the uniform, as used in the uniform block in the shader.
  25976. * @param size Data size, or data directly.
  25977. */
  25978. addUniform(name: string, size: number | number[]): void;
  25979. /**
  25980. * Adds a Matrix 4x4 to the uniform buffer.
  25981. * @param name Name of the uniform, as used in the uniform block in the shader.
  25982. * @param mat A 4x4 matrix.
  25983. */
  25984. addMatrix(name: string, mat: Matrix): void;
  25985. /**
  25986. * Adds a vec2 to the uniform buffer.
  25987. * @param name Name of the uniform, as used in the uniform block in the shader.
  25988. * @param x Define the x component value of the vec2
  25989. * @param y Define the y component value of the vec2
  25990. */
  25991. addFloat2(name: string, x: number, y: number): void;
  25992. /**
  25993. * Adds a vec3 to the uniform buffer.
  25994. * @param name Name of the uniform, as used in the uniform block in the shader.
  25995. * @param x Define the x component value of the vec3
  25996. * @param y Define the y component value of the vec3
  25997. * @param z Define the z component value of the vec3
  25998. */
  25999. addFloat3(name: string, x: number, y: number, z: number): void;
  26000. /**
  26001. * Adds a vec3 to the uniform buffer.
  26002. * @param name Name of the uniform, as used in the uniform block in the shader.
  26003. * @param color Define the vec3 from a Color
  26004. */
  26005. addColor3(name: string, color: Color3): void;
  26006. /**
  26007. * Adds a vec4 to the uniform buffer.
  26008. * @param name Name of the uniform, as used in the uniform block in the shader.
  26009. * @param color Define the rgb components from a Color
  26010. * @param alpha Define the a component of the vec4
  26011. */
  26012. addColor4(name: string, color: Color3, alpha: number): void;
  26013. /**
  26014. * Adds a vec3 to the uniform buffer.
  26015. * @param name Name of the uniform, as used in the uniform block in the shader.
  26016. * @param vector Define the vec3 components from a Vector
  26017. */
  26018. addVector3(name: string, vector: Vector3): void;
  26019. /**
  26020. * Adds a Matrix 3x3 to the uniform buffer.
  26021. * @param name Name of the uniform, as used in the uniform block in the shader.
  26022. */
  26023. addMatrix3x3(name: string): void;
  26024. /**
  26025. * Adds a Matrix 2x2 to the uniform buffer.
  26026. * @param name Name of the uniform, as used in the uniform block in the shader.
  26027. */
  26028. addMatrix2x2(name: string): void;
  26029. /**
  26030. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26031. */
  26032. create(): void;
  26033. /** @hidden */
  26034. _rebuild(): void;
  26035. /**
  26036. * Updates the WebGL Uniform Buffer on the GPU.
  26037. * If the `dynamic` flag is set to true, no cache comparison is done.
  26038. * Otherwise, the buffer will be updated only if the cache differs.
  26039. */
  26040. update(): void;
  26041. /**
  26042. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26043. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26044. * @param data Define the flattened data
  26045. * @param size Define the size of the data.
  26046. */
  26047. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26048. private _updateMatrix3x3ForUniform;
  26049. private _updateMatrix3x3ForEffect;
  26050. private _updateMatrix2x2ForEffect;
  26051. private _updateMatrix2x2ForUniform;
  26052. private _updateFloatForEffect;
  26053. private _updateFloatForUniform;
  26054. private _updateFloat2ForEffect;
  26055. private _updateFloat2ForUniform;
  26056. private _updateFloat3ForEffect;
  26057. private _updateFloat3ForUniform;
  26058. private _updateFloat4ForEffect;
  26059. private _updateFloat4ForUniform;
  26060. private _updateMatrixForEffect;
  26061. private _updateMatrixForUniform;
  26062. private _updateVector3ForEffect;
  26063. private _updateVector3ForUniform;
  26064. private _updateVector4ForEffect;
  26065. private _updateVector4ForUniform;
  26066. private _updateColor3ForEffect;
  26067. private _updateColor3ForUniform;
  26068. private _updateColor4ForEffect;
  26069. private _updateColor4ForUniform;
  26070. /**
  26071. * Sets a sampler uniform on the effect.
  26072. * @param name Define the name of the sampler.
  26073. * @param texture Define the texture to set in the sampler
  26074. */
  26075. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26076. /**
  26077. * Directly updates the value of the uniform in the cache AND on the GPU.
  26078. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26079. * @param data Define the flattened data
  26080. */
  26081. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26082. /**
  26083. * Binds this uniform buffer to an effect.
  26084. * @param effect Define the effect to bind the buffer to
  26085. * @param name Name of the uniform block in the shader.
  26086. */
  26087. bindToEffect(effect: Effect, name: string): void;
  26088. /**
  26089. * Disposes the uniform buffer.
  26090. */
  26091. dispose(): void;
  26092. }
  26093. }
  26094. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26095. import { Nullable } from "babylonjs/types";
  26096. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26097. /**
  26098. * This represents the required contract to create a new type of texture loader.
  26099. */
  26100. export interface IInternalTextureLoader {
  26101. /**
  26102. * Defines wether the loader supports cascade loading the different faces.
  26103. */
  26104. supportCascades: boolean;
  26105. /**
  26106. * This returns if the loader support the current file information.
  26107. * @param extension defines the file extension of the file being loaded
  26108. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26109. * @param fallback defines the fallback internal texture if any
  26110. * @param isBase64 defines whether the texture is encoded as a base64
  26111. * @param isBuffer defines whether the texture data are stored as a buffer
  26112. * @returns true if the loader can load the specified file
  26113. */
  26114. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26115. /**
  26116. * Transform the url before loading if required.
  26117. * @param rootUrl the url of the texture
  26118. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26119. * @returns the transformed texture
  26120. */
  26121. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26122. /**
  26123. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26124. * @param rootUrl the url of the texture
  26125. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26126. * @returns the fallback texture
  26127. */
  26128. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26129. /**
  26130. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26131. * @param data contains the texture data
  26132. * @param texture defines the BabylonJS internal texture
  26133. * @param createPolynomials will be true if polynomials have been requested
  26134. * @param onLoad defines the callback to trigger once the texture is ready
  26135. * @param onError defines the callback to trigger in case of error
  26136. */
  26137. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26138. /**
  26139. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26140. * @param data contains the texture data
  26141. * @param texture defines the BabylonJS internal texture
  26142. * @param callback defines the method to call once ready to upload
  26143. */
  26144. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26145. }
  26146. }
  26147. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26148. import { Scene } from "babylonjs/scene";
  26149. import { Engine } from "babylonjs/Engines/engine";
  26150. import { Texture } from "babylonjs/Materials/Textures/texture";
  26151. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26152. /**
  26153. * Creation options of the multi render target texture.
  26154. */
  26155. export interface IMultiRenderTargetOptions {
  26156. /**
  26157. * Define if the texture needs to create mip maps after render.
  26158. */
  26159. generateMipMaps?: boolean;
  26160. /**
  26161. * Define the types of all the draw buffers we want to create
  26162. */
  26163. types?: number[];
  26164. /**
  26165. * Define the sampling modes of all the draw buffers we want to create
  26166. */
  26167. samplingModes?: number[];
  26168. /**
  26169. * Define if a depth buffer is required
  26170. */
  26171. generateDepthBuffer?: boolean;
  26172. /**
  26173. * Define if a stencil buffer is required
  26174. */
  26175. generateStencilBuffer?: boolean;
  26176. /**
  26177. * Define if a depth texture is required instead of a depth buffer
  26178. */
  26179. generateDepthTexture?: boolean;
  26180. /**
  26181. * Define the number of desired draw buffers
  26182. */
  26183. textureCount?: number;
  26184. /**
  26185. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26186. */
  26187. doNotChangeAspectRatio?: boolean;
  26188. /**
  26189. * Define the default type of the buffers we are creating
  26190. */
  26191. defaultType?: number;
  26192. }
  26193. /**
  26194. * A multi render target, like a render target provides the ability to render to a texture.
  26195. * Unlike the render target, it can render to several draw buffers in one draw.
  26196. * This is specially interesting in deferred rendering or for any effects requiring more than
  26197. * just one color from a single pass.
  26198. */
  26199. export class MultiRenderTarget extends RenderTargetTexture {
  26200. private _internalTextures;
  26201. private _textures;
  26202. private _multiRenderTargetOptions;
  26203. /**
  26204. * Get if draw buffers are currently supported by the used hardware and browser.
  26205. */
  26206. readonly isSupported: boolean;
  26207. /**
  26208. * Get the list of textures generated by the multi render target.
  26209. */
  26210. readonly textures: Texture[];
  26211. /**
  26212. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26213. */
  26214. readonly depthTexture: Texture;
  26215. /**
  26216. * Set the wrapping mode on U of all the textures we are rendering to.
  26217. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26218. */
  26219. wrapU: number;
  26220. /**
  26221. * Set the wrapping mode on V of all the textures we are rendering to.
  26222. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26223. */
  26224. wrapV: number;
  26225. /**
  26226. * Instantiate a new multi render target texture.
  26227. * A multi render target, like a render target provides the ability to render to a texture.
  26228. * Unlike the render target, it can render to several draw buffers in one draw.
  26229. * This is specially interesting in deferred rendering or for any effects requiring more than
  26230. * just one color from a single pass.
  26231. * @param name Define the name of the texture
  26232. * @param size Define the size of the buffers to render to
  26233. * @param count Define the number of target we are rendering into
  26234. * @param scene Define the scene the texture belongs to
  26235. * @param options Define the options used to create the multi render target
  26236. */
  26237. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26238. /** @hidden */
  26239. _rebuild(): void;
  26240. private _createInternalTextures;
  26241. private _createTextures;
  26242. /**
  26243. * Define the number of samples used if MSAA is enabled.
  26244. */
  26245. samples: number;
  26246. /**
  26247. * Resize all the textures in the multi render target.
  26248. * Be carrefull as it will recreate all the data in the new texture.
  26249. * @param size Define the new size
  26250. */
  26251. resize(size: any): void;
  26252. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26253. /**
  26254. * Dispose the render targets and their associated resources
  26255. */
  26256. dispose(): void;
  26257. /**
  26258. * Release all the underlying texture used as draw buffers.
  26259. */
  26260. releaseInternalTextures(): void;
  26261. }
  26262. }
  26263. declare module "babylonjs/Audio/analyser" {
  26264. import { Scene } from "babylonjs/scene";
  26265. /**
  26266. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26268. */
  26269. export class Analyser {
  26270. /**
  26271. * Gets or sets the smoothing
  26272. * @ignorenaming
  26273. */
  26274. SMOOTHING: number;
  26275. /**
  26276. * Gets or sets the FFT table size
  26277. * @ignorenaming
  26278. */
  26279. FFT_SIZE: number;
  26280. /**
  26281. * Gets or sets the bar graph amplitude
  26282. * @ignorenaming
  26283. */
  26284. BARGRAPHAMPLITUDE: number;
  26285. /**
  26286. * Gets or sets the position of the debug canvas
  26287. * @ignorenaming
  26288. */
  26289. DEBUGCANVASPOS: {
  26290. x: number;
  26291. y: number;
  26292. };
  26293. /**
  26294. * Gets or sets the debug canvas size
  26295. * @ignorenaming
  26296. */
  26297. DEBUGCANVASSIZE: {
  26298. width: number;
  26299. height: number;
  26300. };
  26301. private _byteFreqs;
  26302. private _byteTime;
  26303. private _floatFreqs;
  26304. private _webAudioAnalyser;
  26305. private _debugCanvas;
  26306. private _debugCanvasContext;
  26307. private _scene;
  26308. private _registerFunc;
  26309. private _audioEngine;
  26310. /**
  26311. * Creates a new analyser
  26312. * @param scene defines hosting scene
  26313. */
  26314. constructor(scene: Scene);
  26315. /**
  26316. * Get the number of data values you will have to play with for the visualization
  26317. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26318. * @returns a number
  26319. */
  26320. getFrequencyBinCount(): number;
  26321. /**
  26322. * Gets the current frequency data as a byte array
  26323. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26324. * @returns a Uint8Array
  26325. */
  26326. getByteFrequencyData(): Uint8Array;
  26327. /**
  26328. * Gets the current waveform as a byte array
  26329. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26330. * @returns a Uint8Array
  26331. */
  26332. getByteTimeDomainData(): Uint8Array;
  26333. /**
  26334. * Gets the current frequency data as a float array
  26335. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26336. * @returns a Float32Array
  26337. */
  26338. getFloatFrequencyData(): Float32Array;
  26339. /**
  26340. * Renders the debug canvas
  26341. */
  26342. drawDebugCanvas(): void;
  26343. /**
  26344. * Stops rendering the debug canvas and removes it
  26345. */
  26346. stopDebugCanvas(): void;
  26347. /**
  26348. * Connects two audio nodes
  26349. * @param inputAudioNode defines first node to connect
  26350. * @param outputAudioNode defines second node to connect
  26351. */
  26352. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26353. /**
  26354. * Releases all associated resources
  26355. */
  26356. dispose(): void;
  26357. }
  26358. }
  26359. declare module "babylonjs/Audio/audioEngine" {
  26360. import { IDisposable } from "babylonjs/scene";
  26361. import { Analyser } from "babylonjs/Audio/analyser";
  26362. import { Nullable } from "babylonjs/types";
  26363. import { Observable } from "babylonjs/Misc/observable";
  26364. /**
  26365. * This represents an audio engine and it is responsible
  26366. * to play, synchronize and analyse sounds throughout the application.
  26367. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26368. */
  26369. export interface IAudioEngine extends IDisposable {
  26370. /**
  26371. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26372. */
  26373. readonly canUseWebAudio: boolean;
  26374. /**
  26375. * Gets the current AudioContext if available.
  26376. */
  26377. readonly audioContext: Nullable<AudioContext>;
  26378. /**
  26379. * The master gain node defines the global audio volume of your audio engine.
  26380. */
  26381. readonly masterGain: GainNode;
  26382. /**
  26383. * Gets whether or not mp3 are supported by your browser.
  26384. */
  26385. readonly isMP3supported: boolean;
  26386. /**
  26387. * Gets whether or not ogg are supported by your browser.
  26388. */
  26389. readonly isOGGsupported: boolean;
  26390. /**
  26391. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26392. * @ignoreNaming
  26393. */
  26394. WarnedWebAudioUnsupported: boolean;
  26395. /**
  26396. * Defines if the audio engine relies on a custom unlocked button.
  26397. * In this case, the embedded button will not be displayed.
  26398. */
  26399. useCustomUnlockedButton: boolean;
  26400. /**
  26401. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26402. */
  26403. readonly unlocked: boolean;
  26404. /**
  26405. * Event raised when audio has been unlocked on the browser.
  26406. */
  26407. onAudioUnlockedObservable: Observable<AudioEngine>;
  26408. /**
  26409. * Event raised when audio has been locked on the browser.
  26410. */
  26411. onAudioLockedObservable: Observable<AudioEngine>;
  26412. /**
  26413. * Flags the audio engine in Locked state.
  26414. * This happens due to new browser policies preventing audio to autoplay.
  26415. */
  26416. lock(): void;
  26417. /**
  26418. * Unlocks the audio engine once a user action has been done on the dom.
  26419. * This is helpful to resume play once browser policies have been satisfied.
  26420. */
  26421. unlock(): void;
  26422. }
  26423. /**
  26424. * This represents the default audio engine used in babylon.
  26425. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26426. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26427. */
  26428. export class AudioEngine implements IAudioEngine {
  26429. private _audioContext;
  26430. private _audioContextInitialized;
  26431. private _muteButton;
  26432. private _hostElement;
  26433. /**
  26434. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26435. */
  26436. canUseWebAudio: boolean;
  26437. /**
  26438. * The master gain node defines the global audio volume of your audio engine.
  26439. */
  26440. masterGain: GainNode;
  26441. /**
  26442. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26443. * @ignoreNaming
  26444. */
  26445. WarnedWebAudioUnsupported: boolean;
  26446. /**
  26447. * Gets whether or not mp3 are supported by your browser.
  26448. */
  26449. isMP3supported: boolean;
  26450. /**
  26451. * Gets whether or not ogg are supported by your browser.
  26452. */
  26453. isOGGsupported: boolean;
  26454. /**
  26455. * Gets whether audio has been unlocked on the device.
  26456. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26457. * a user interaction has happened.
  26458. */
  26459. unlocked: boolean;
  26460. /**
  26461. * Defines if the audio engine relies on a custom unlocked button.
  26462. * In this case, the embedded button will not be displayed.
  26463. */
  26464. useCustomUnlockedButton: boolean;
  26465. /**
  26466. * Event raised when audio has been unlocked on the browser.
  26467. */
  26468. onAudioUnlockedObservable: Observable<AudioEngine>;
  26469. /**
  26470. * Event raised when audio has been locked on the browser.
  26471. */
  26472. onAudioLockedObservable: Observable<AudioEngine>;
  26473. /**
  26474. * Gets the current AudioContext if available.
  26475. */
  26476. readonly audioContext: Nullable<AudioContext>;
  26477. private _connectedAnalyser;
  26478. /**
  26479. * Instantiates a new audio engine.
  26480. *
  26481. * There should be only one per page as some browsers restrict the number
  26482. * of audio contexts you can create.
  26483. * @param hostElement defines the host element where to display the mute icon if necessary
  26484. */
  26485. constructor(hostElement?: Nullable<HTMLElement>);
  26486. /**
  26487. * Flags the audio engine in Locked state.
  26488. * This happens due to new browser policies preventing audio to autoplay.
  26489. */
  26490. lock(): void;
  26491. /**
  26492. * Unlocks the audio engine once a user action has been done on the dom.
  26493. * This is helpful to resume play once browser policies have been satisfied.
  26494. */
  26495. unlock(): void;
  26496. private _resumeAudioContext;
  26497. private _initializeAudioContext;
  26498. private _tryToRun;
  26499. private _triggerRunningState;
  26500. private _triggerSuspendedState;
  26501. private _displayMuteButton;
  26502. private _moveButtonToTopLeft;
  26503. private _onResize;
  26504. private _hideMuteButton;
  26505. /**
  26506. * Destroy and release the resources associated with the audio ccontext.
  26507. */
  26508. dispose(): void;
  26509. /**
  26510. * Gets the global volume sets on the master gain.
  26511. * @returns the global volume if set or -1 otherwise
  26512. */
  26513. getGlobalVolume(): number;
  26514. /**
  26515. * Sets the global volume of your experience (sets on the master gain).
  26516. * @param newVolume Defines the new global volume of the application
  26517. */
  26518. setGlobalVolume(newVolume: number): void;
  26519. /**
  26520. * Connect the audio engine to an audio analyser allowing some amazing
  26521. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26522. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26523. * @param analyser The analyser to connect to the engine
  26524. */
  26525. connectToAnalyser(analyser: Analyser): void;
  26526. }
  26527. }
  26528. declare module "babylonjs/Loading/loadingScreen" {
  26529. /**
  26530. * Interface used to present a loading screen while loading a scene
  26531. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26532. */
  26533. export interface ILoadingScreen {
  26534. /**
  26535. * Function called to display the loading screen
  26536. */
  26537. displayLoadingUI: () => void;
  26538. /**
  26539. * Function called to hide the loading screen
  26540. */
  26541. hideLoadingUI: () => void;
  26542. /**
  26543. * Gets or sets the color to use for the background
  26544. */
  26545. loadingUIBackgroundColor: string;
  26546. /**
  26547. * Gets or sets the text to display while loading
  26548. */
  26549. loadingUIText: string;
  26550. }
  26551. /**
  26552. * Class used for the default loading screen
  26553. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26554. */
  26555. export class DefaultLoadingScreen implements ILoadingScreen {
  26556. private _renderingCanvas;
  26557. private _loadingText;
  26558. private _loadingDivBackgroundColor;
  26559. private _loadingDiv;
  26560. private _loadingTextDiv;
  26561. /**
  26562. * Creates a new default loading screen
  26563. * @param _renderingCanvas defines the canvas used to render the scene
  26564. * @param _loadingText defines the default text to display
  26565. * @param _loadingDivBackgroundColor defines the default background color
  26566. */
  26567. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26568. /**
  26569. * Function called to display the loading screen
  26570. */
  26571. displayLoadingUI(): void;
  26572. /**
  26573. * Function called to hide the loading screen
  26574. */
  26575. hideLoadingUI(): void;
  26576. /**
  26577. * Gets or sets the text to display while loading
  26578. */
  26579. loadingUIText: string;
  26580. /**
  26581. * Gets or sets the color to use for the background
  26582. */
  26583. loadingUIBackgroundColor: string;
  26584. private _resizeLoadingUI;
  26585. }
  26586. }
  26587. declare module "babylonjs/Materials/Textures/videoTexture" {
  26588. import { Observable } from "babylonjs/Misc/observable";
  26589. import { Nullable } from "babylonjs/types";
  26590. import { Scene } from "babylonjs/scene";
  26591. import { Texture } from "babylonjs/Materials/Textures/texture";
  26592. /**
  26593. * Settings for finer control over video usage
  26594. */
  26595. export interface VideoTextureSettings {
  26596. /**
  26597. * Applies `autoplay` to video, if specified
  26598. */
  26599. autoPlay?: boolean;
  26600. /**
  26601. * Applies `loop` to video, if specified
  26602. */
  26603. loop?: boolean;
  26604. /**
  26605. * Automatically updates internal texture from video at every frame in the render loop
  26606. */
  26607. autoUpdateTexture: boolean;
  26608. /**
  26609. * Image src displayed during the video loading or until the user interacts with the video.
  26610. */
  26611. poster?: string;
  26612. }
  26613. /**
  26614. * If you want to display a video in your scene, this is the special texture for that.
  26615. * This special texture works similar to other textures, with the exception of a few parameters.
  26616. * @see https://doc.babylonjs.com/how_to/video_texture
  26617. */
  26618. export class VideoTexture extends Texture {
  26619. /**
  26620. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26621. */
  26622. readonly autoUpdateTexture: boolean;
  26623. /**
  26624. * The video instance used by the texture internally
  26625. */
  26626. readonly video: HTMLVideoElement;
  26627. private _onUserActionRequestedObservable;
  26628. /**
  26629. * Event triggerd when a dom action is required by the user to play the video.
  26630. * This happens due to recent changes in browser policies preventing video to auto start.
  26631. */
  26632. readonly onUserActionRequestedObservable: Observable<Texture>;
  26633. private _generateMipMaps;
  26634. private _engine;
  26635. private _stillImageCaptured;
  26636. private _displayingPosterTexture;
  26637. private _settings;
  26638. private _createInternalTextureOnEvent;
  26639. /**
  26640. * Creates a video texture.
  26641. * If you want to display a video in your scene, this is the special texture for that.
  26642. * This special texture works similar to other textures, with the exception of a few parameters.
  26643. * @see https://doc.babylonjs.com/how_to/video_texture
  26644. * @param name optional name, will detect from video source, if not defined
  26645. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26646. * @param scene is obviously the current scene.
  26647. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26648. * @param invertY is false by default but can be used to invert video on Y axis
  26649. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26650. * @param settings allows finer control over video usage
  26651. */
  26652. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26653. private _getName;
  26654. private _getVideo;
  26655. private _createInternalTexture;
  26656. private reset;
  26657. /**
  26658. * @hidden Internal method to initiate `update`.
  26659. */
  26660. _rebuild(): void;
  26661. /**
  26662. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26663. */
  26664. update(): void;
  26665. /**
  26666. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26667. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26668. */
  26669. updateTexture(isVisible: boolean): void;
  26670. protected _updateInternalTexture: () => void;
  26671. /**
  26672. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26673. * @param url New url.
  26674. */
  26675. updateURL(url: string): void;
  26676. /**
  26677. * Dispose the texture and release its associated resources.
  26678. */
  26679. dispose(): void;
  26680. /**
  26681. * Creates a video texture straight from a stream.
  26682. * @param scene Define the scene the texture should be created in
  26683. * @param stream Define the stream the texture should be created from
  26684. * @returns The created video texture as a promise
  26685. */
  26686. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26687. /**
  26688. * Creates a video texture straight from your WebCam video feed.
  26689. * @param scene Define the scene the texture should be created in
  26690. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26691. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26692. * @returns The created video texture as a promise
  26693. */
  26694. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26695. minWidth: number;
  26696. maxWidth: number;
  26697. minHeight: number;
  26698. maxHeight: number;
  26699. deviceId: string;
  26700. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26701. /**
  26702. * Creates a video texture straight from your WebCam video feed.
  26703. * @param scene Define the scene the texture should be created in
  26704. * @param onReady Define a callback to triggered once the texture will be ready
  26705. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26706. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26707. */
  26708. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26709. minWidth: number;
  26710. maxWidth: number;
  26711. minHeight: number;
  26712. maxHeight: number;
  26713. deviceId: string;
  26714. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26715. }
  26716. }
  26717. declare module "babylonjs/Engines/engine" {
  26718. import { Observable } from "babylonjs/Misc/observable";
  26719. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26720. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26721. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26722. import { Camera } from "babylonjs/Cameras/camera";
  26723. import { Scene } from "babylonjs/scene";
  26724. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26725. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26726. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26727. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26728. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26729. import { Material } from "babylonjs/Materials/material";
  26730. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26731. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26732. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26733. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26734. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26735. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26736. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26737. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26738. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26739. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26740. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26741. /**
  26742. * Interface for attribute information associated with buffer instanciation
  26743. */
  26744. export class InstancingAttributeInfo {
  26745. /**
  26746. * Index/offset of the attribute in the vertex shader
  26747. */
  26748. index: number;
  26749. /**
  26750. * size of the attribute, 1, 2, 3 or 4
  26751. */
  26752. attributeSize: number;
  26753. /**
  26754. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26755. * default is FLOAT
  26756. */
  26757. attribyteType: number;
  26758. /**
  26759. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26760. */
  26761. normalized: boolean;
  26762. /**
  26763. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26764. */
  26765. offset: number;
  26766. /**
  26767. * Name of the GLSL attribute, for debugging purpose only
  26768. */
  26769. attributeName: string;
  26770. }
  26771. /**
  26772. * Define options used to create a depth texture
  26773. */
  26774. export class DepthTextureCreationOptions {
  26775. /** Specifies whether or not a stencil should be allocated in the texture */
  26776. generateStencil?: boolean;
  26777. /** Specifies whether or not bilinear filtering is enable on the texture */
  26778. bilinearFiltering?: boolean;
  26779. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26780. comparisonFunction?: number;
  26781. /** Specifies if the created texture is a cube texture */
  26782. isCube?: boolean;
  26783. }
  26784. /**
  26785. * Class used to describe the capabilities of the engine relatively to the current browser
  26786. */
  26787. export class EngineCapabilities {
  26788. /** Maximum textures units per fragment shader */
  26789. maxTexturesImageUnits: number;
  26790. /** Maximum texture units per vertex shader */
  26791. maxVertexTextureImageUnits: number;
  26792. /** Maximum textures units in the entire pipeline */
  26793. maxCombinedTexturesImageUnits: number;
  26794. /** Maximum texture size */
  26795. maxTextureSize: number;
  26796. /** Maximum cube texture size */
  26797. maxCubemapTextureSize: number;
  26798. /** Maximum render texture size */
  26799. maxRenderTextureSize: number;
  26800. /** Maximum number of vertex attributes */
  26801. maxVertexAttribs: number;
  26802. /** Maximum number of varyings */
  26803. maxVaryingVectors: number;
  26804. /** Maximum number of uniforms per vertex shader */
  26805. maxVertexUniformVectors: number;
  26806. /** Maximum number of uniforms per fragment shader */
  26807. maxFragmentUniformVectors: number;
  26808. /** Defines if standard derivates (dx/dy) are supported */
  26809. standardDerivatives: boolean;
  26810. /** Defines if s3tc texture compression is supported */
  26811. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26812. /** Defines if pvrtc texture compression is supported */
  26813. pvrtc: any;
  26814. /** Defines if etc1 texture compression is supported */
  26815. etc1: any;
  26816. /** Defines if etc2 texture compression is supported */
  26817. etc2: any;
  26818. /** Defines if astc texture compression is supported */
  26819. astc: any;
  26820. /** Defines if float textures are supported */
  26821. textureFloat: boolean;
  26822. /** Defines if vertex array objects are supported */
  26823. vertexArrayObject: boolean;
  26824. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26825. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26826. /** Gets the maximum level of anisotropy supported */
  26827. maxAnisotropy: number;
  26828. /** Defines if instancing is supported */
  26829. instancedArrays: boolean;
  26830. /** Defines if 32 bits indices are supported */
  26831. uintIndices: boolean;
  26832. /** Defines if high precision shaders are supported */
  26833. highPrecisionShaderSupported: boolean;
  26834. /** Defines if depth reading in the fragment shader is supported */
  26835. fragmentDepthSupported: boolean;
  26836. /** Defines if float texture linear filtering is supported*/
  26837. textureFloatLinearFiltering: boolean;
  26838. /** Defines if rendering to float textures is supported */
  26839. textureFloatRender: boolean;
  26840. /** Defines if half float textures are supported*/
  26841. textureHalfFloat: boolean;
  26842. /** Defines if half float texture linear filtering is supported*/
  26843. textureHalfFloatLinearFiltering: boolean;
  26844. /** Defines if rendering to half float textures is supported */
  26845. textureHalfFloatRender: boolean;
  26846. /** Defines if textureLOD shader command is supported */
  26847. textureLOD: boolean;
  26848. /** Defines if draw buffers extension is supported */
  26849. drawBuffersExtension: boolean;
  26850. /** Defines if depth textures are supported */
  26851. depthTextureExtension: boolean;
  26852. /** Defines if float color buffer are supported */
  26853. colorBufferFloat: boolean;
  26854. /** Gets disjoint timer query extension (null if not supported) */
  26855. timerQuery: EXT_disjoint_timer_query;
  26856. /** Defines if timestamp can be used with timer query */
  26857. canUseTimestampForTimerQuery: boolean;
  26858. /** Function used to let the system compiles shaders in background */
  26859. parallelShaderCompile: {
  26860. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26861. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26862. COMPLETION_STATUS_KHR: number;
  26863. };
  26864. }
  26865. /** Interface defining initialization parameters for Engine class */
  26866. export interface EngineOptions extends WebGLContextAttributes {
  26867. /**
  26868. * Defines if the engine should no exceed a specified device ratio
  26869. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26870. */
  26871. limitDeviceRatio?: number;
  26872. /**
  26873. * Defines if webvr should be enabled automatically
  26874. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26875. */
  26876. autoEnableWebVR?: boolean;
  26877. /**
  26878. * Defines if webgl2 should be turned off even if supported
  26879. * @see http://doc.babylonjs.com/features/webgl2
  26880. */
  26881. disableWebGL2Support?: boolean;
  26882. /**
  26883. * Defines if webaudio should be initialized as well
  26884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26885. */
  26886. audioEngine?: boolean;
  26887. /**
  26888. * Defines if animations should run using a deterministic lock step
  26889. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26890. */
  26891. deterministicLockstep?: boolean;
  26892. /** Defines the maximum steps to use with deterministic lock step mode */
  26893. lockstepMaxSteps?: number;
  26894. /**
  26895. * Defines that engine should ignore context lost events
  26896. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26897. */
  26898. doNotHandleContextLost?: boolean;
  26899. /**
  26900. * Defines that engine should ignore modifying touch action attribute and style
  26901. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26902. */
  26903. doNotHandleTouchAction?: boolean;
  26904. }
  26905. /**
  26906. * Defines the interface used by display changed events
  26907. */
  26908. export interface IDisplayChangedEventArgs {
  26909. /** Gets the vrDisplay object (if any) */
  26910. vrDisplay: Nullable<any>;
  26911. /** Gets a boolean indicating if webVR is supported */
  26912. vrSupported: boolean;
  26913. }
  26914. /**
  26915. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26916. */
  26917. export class Engine {
  26918. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26919. static ExceptionList: ({
  26920. key: string;
  26921. capture: string;
  26922. captureConstraint: number;
  26923. targets: string[];
  26924. } | {
  26925. key: string;
  26926. capture: null;
  26927. captureConstraint: null;
  26928. targets: string[];
  26929. })[];
  26930. /** Gets the list of created engines */
  26931. static readonly Instances: Engine[];
  26932. /**
  26933. * Gets the latest created engine
  26934. */
  26935. static readonly LastCreatedEngine: Nullable<Engine>;
  26936. /**
  26937. * Gets the latest created scene
  26938. */
  26939. static readonly LastCreatedScene: Nullable<Scene>;
  26940. /**
  26941. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26942. * @param flag defines which part of the materials must be marked as dirty
  26943. * @param predicate defines a predicate used to filter which materials should be affected
  26944. */
  26945. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26946. /**
  26947. * Hidden
  26948. */
  26949. static _TextureLoaders: IInternalTextureLoader[];
  26950. /** Defines that alpha blending is disabled */
  26951. static readonly ALPHA_DISABLE: number;
  26952. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26953. static readonly ALPHA_ADD: number;
  26954. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26955. static readonly ALPHA_COMBINE: number;
  26956. /** Defines that alpha blending to DEST - SRC * DEST */
  26957. static readonly ALPHA_SUBTRACT: number;
  26958. /** Defines that alpha blending to SRC * DEST */
  26959. static readonly ALPHA_MULTIPLY: number;
  26960. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26961. static readonly ALPHA_MAXIMIZED: number;
  26962. /** Defines that alpha blending to SRC + DEST */
  26963. static readonly ALPHA_ONEONE: number;
  26964. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26965. static readonly ALPHA_PREMULTIPLIED: number;
  26966. /**
  26967. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26968. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26969. */
  26970. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26971. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26972. static readonly ALPHA_INTERPOLATE: number;
  26973. /**
  26974. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26975. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26976. */
  26977. static readonly ALPHA_SCREENMODE: number;
  26978. /** Defines that the ressource is not delayed*/
  26979. static readonly DELAYLOADSTATE_NONE: number;
  26980. /** Defines that the ressource was successfully delay loaded */
  26981. static readonly DELAYLOADSTATE_LOADED: number;
  26982. /** Defines that the ressource is currently delay loading */
  26983. static readonly DELAYLOADSTATE_LOADING: number;
  26984. /** Defines that the ressource is delayed and has not started loading */
  26985. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26986. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26987. static readonly NEVER: number;
  26988. /** 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 */
  26989. static readonly ALWAYS: number;
  26990. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26991. static readonly LESS: number;
  26992. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26993. static readonly EQUAL: number;
  26994. /** 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 */
  26995. static readonly LEQUAL: number;
  26996. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26997. static readonly GREATER: number;
  26998. /** 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 */
  26999. static readonly GEQUAL: number;
  27000. /** 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 */
  27001. static readonly NOTEQUAL: number;
  27002. /** Passed to stencilOperation to specify that stencil value must be kept */
  27003. static readonly KEEP: number;
  27004. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27005. static readonly REPLACE: number;
  27006. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27007. static readonly INCR: number;
  27008. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27009. static readonly DECR: number;
  27010. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27011. static readonly INVERT: number;
  27012. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27013. static readonly INCR_WRAP: number;
  27014. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27015. static readonly DECR_WRAP: number;
  27016. /** Texture is not repeating outside of 0..1 UVs */
  27017. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27018. /** Texture is repeating outside of 0..1 UVs */
  27019. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27020. /** Texture is repeating and mirrored */
  27021. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27022. /** ALPHA */
  27023. static readonly TEXTUREFORMAT_ALPHA: number;
  27024. /** LUMINANCE */
  27025. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27026. /** LUMINANCE_ALPHA */
  27027. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27028. /** RGB */
  27029. static readonly TEXTUREFORMAT_RGB: number;
  27030. /** RGBA */
  27031. static readonly TEXTUREFORMAT_RGBA: number;
  27032. /** RED */
  27033. static readonly TEXTUREFORMAT_RED: number;
  27034. /** RED (2nd reference) */
  27035. static readonly TEXTUREFORMAT_R: number;
  27036. /** RG */
  27037. static readonly TEXTUREFORMAT_RG: number;
  27038. /** RED_INTEGER */
  27039. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27040. /** RED_INTEGER (2nd reference) */
  27041. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27042. /** RG_INTEGER */
  27043. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27044. /** RGB_INTEGER */
  27045. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27046. /** RGBA_INTEGER */
  27047. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27048. /** UNSIGNED_BYTE */
  27049. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27050. /** UNSIGNED_BYTE (2nd reference) */
  27051. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27052. /** FLOAT */
  27053. static readonly TEXTURETYPE_FLOAT: number;
  27054. /** HALF_FLOAT */
  27055. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27056. /** BYTE */
  27057. static readonly TEXTURETYPE_BYTE: number;
  27058. /** SHORT */
  27059. static readonly TEXTURETYPE_SHORT: number;
  27060. /** UNSIGNED_SHORT */
  27061. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27062. /** INT */
  27063. static readonly TEXTURETYPE_INT: number;
  27064. /** UNSIGNED_INT */
  27065. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27066. /** UNSIGNED_SHORT_4_4_4_4 */
  27067. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27068. /** UNSIGNED_SHORT_5_5_5_1 */
  27069. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27070. /** UNSIGNED_SHORT_5_6_5 */
  27071. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27072. /** UNSIGNED_INT_2_10_10_10_REV */
  27073. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27074. /** UNSIGNED_INT_24_8 */
  27075. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27076. /** UNSIGNED_INT_10F_11F_11F_REV */
  27077. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27078. /** UNSIGNED_INT_5_9_9_9_REV */
  27079. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27080. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27081. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27082. /** nearest is mag = nearest and min = nearest and mip = linear */
  27083. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27084. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27085. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27086. /** Trilinear is mag = linear and min = linear and mip = linear */
  27087. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27088. /** nearest is mag = nearest and min = nearest and mip = linear */
  27089. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27090. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27091. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27092. /** Trilinear is mag = linear and min = linear and mip = linear */
  27093. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27094. /** mag = nearest and min = nearest and mip = nearest */
  27095. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27096. /** mag = nearest and min = linear and mip = nearest */
  27097. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27098. /** mag = nearest and min = linear and mip = linear */
  27099. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27100. /** mag = nearest and min = linear and mip = none */
  27101. static readonly TEXTURE_NEAREST_LINEAR: number;
  27102. /** mag = nearest and min = nearest and mip = none */
  27103. static readonly TEXTURE_NEAREST_NEAREST: number;
  27104. /** mag = linear and min = nearest and mip = nearest */
  27105. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27106. /** mag = linear and min = nearest and mip = linear */
  27107. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27108. /** mag = linear and min = linear and mip = none */
  27109. static readonly TEXTURE_LINEAR_LINEAR: number;
  27110. /** mag = linear and min = nearest and mip = none */
  27111. static readonly TEXTURE_LINEAR_NEAREST: number;
  27112. /** Explicit coordinates mode */
  27113. static readonly TEXTURE_EXPLICIT_MODE: number;
  27114. /** Spherical coordinates mode */
  27115. static readonly TEXTURE_SPHERICAL_MODE: number;
  27116. /** Planar coordinates mode */
  27117. static readonly TEXTURE_PLANAR_MODE: number;
  27118. /** Cubic coordinates mode */
  27119. static readonly TEXTURE_CUBIC_MODE: number;
  27120. /** Projection coordinates mode */
  27121. static readonly TEXTURE_PROJECTION_MODE: number;
  27122. /** Skybox coordinates mode */
  27123. static readonly TEXTURE_SKYBOX_MODE: number;
  27124. /** Inverse Cubic coordinates mode */
  27125. static readonly TEXTURE_INVCUBIC_MODE: number;
  27126. /** Equirectangular coordinates mode */
  27127. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27128. /** Equirectangular Fixed coordinates mode */
  27129. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27130. /** Equirectangular Fixed Mirrored coordinates mode */
  27131. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27132. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27133. static readonly SCALEMODE_FLOOR: number;
  27134. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27135. static readonly SCALEMODE_NEAREST: number;
  27136. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27137. static readonly SCALEMODE_CEILING: number;
  27138. /**
  27139. * Returns the current version of the framework
  27140. */
  27141. static readonly Version: string;
  27142. /**
  27143. * Returns a string describing the current engine
  27144. */
  27145. readonly description: string;
  27146. /**
  27147. * Gets or sets the epsilon value used by collision engine
  27148. */
  27149. static CollisionsEpsilon: number;
  27150. /**
  27151. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27152. */
  27153. static ShadersRepository: string;
  27154. /**
  27155. * Method called to create the default loading screen.
  27156. * This can be overriden in your own app.
  27157. * @param canvas The rendering canvas element
  27158. * @returns The loading screen
  27159. */
  27160. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27161. /**
  27162. * Method called to create the default rescale post process on each engine.
  27163. */
  27164. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27165. /**
  27166. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27167. */
  27168. forcePOTTextures: boolean;
  27169. /**
  27170. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27171. */
  27172. isFullscreen: boolean;
  27173. /**
  27174. * Gets a boolean indicating if the pointer is currently locked
  27175. */
  27176. isPointerLock: boolean;
  27177. /**
  27178. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27179. */
  27180. cullBackFaces: boolean;
  27181. /**
  27182. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27183. */
  27184. renderEvenInBackground: boolean;
  27185. /**
  27186. * Gets or sets a boolean indicating that cache can be kept between frames
  27187. */
  27188. preventCacheWipeBetweenFrames: boolean;
  27189. /**
  27190. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27191. **/
  27192. enableOfflineSupport: boolean;
  27193. /**
  27194. * 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)
  27195. **/
  27196. disableManifestCheck: boolean;
  27197. /**
  27198. * Gets the list of created scenes
  27199. */
  27200. scenes: Scene[];
  27201. /**
  27202. * Event raised when a new scene is created
  27203. */
  27204. onNewSceneAddedObservable: Observable<Scene>;
  27205. /**
  27206. * Gets the list of created postprocesses
  27207. */
  27208. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27209. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27210. validateShaderPrograms: boolean;
  27211. /**
  27212. * Observable event triggered each time the rendering canvas is resized
  27213. */
  27214. onResizeObservable: Observable<Engine>;
  27215. /**
  27216. * Observable event triggered each time the canvas loses focus
  27217. */
  27218. onCanvasBlurObservable: Observable<Engine>;
  27219. /**
  27220. * Observable event triggered each time the canvas gains focus
  27221. */
  27222. onCanvasFocusObservable: Observable<Engine>;
  27223. /**
  27224. * Observable event triggered each time the canvas receives pointerout event
  27225. */
  27226. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27227. /**
  27228. * Observable event triggered before each texture is initialized
  27229. */
  27230. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27231. private _vrDisplay;
  27232. private _vrSupported;
  27233. private _oldSize;
  27234. private _oldHardwareScaleFactor;
  27235. private _vrExclusivePointerMode;
  27236. private _webVRInitPromise;
  27237. /**
  27238. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27239. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27240. */
  27241. readonly isInVRExclusivePointerMode: boolean;
  27242. /**
  27243. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27244. */
  27245. disableUniformBuffers: boolean;
  27246. /** @hidden */
  27247. _uniformBuffers: UniformBuffer[];
  27248. /**
  27249. * Gets a boolean indicating that the engine supports uniform buffers
  27250. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27251. */
  27252. readonly supportsUniformBuffers: boolean;
  27253. /**
  27254. * Observable raised when the engine begins a new frame
  27255. */
  27256. onBeginFrameObservable: Observable<Engine>;
  27257. /**
  27258. * If set, will be used to request the next animation frame for the render loop
  27259. */
  27260. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27261. /**
  27262. * Observable raised when the engine ends the current frame
  27263. */
  27264. onEndFrameObservable: Observable<Engine>;
  27265. /**
  27266. * Observable raised when the engine is about to compile a shader
  27267. */
  27268. onBeforeShaderCompilationObservable: Observable<Engine>;
  27269. /**
  27270. * Observable raised when the engine has jsut compiled a shader
  27271. */
  27272. onAfterShaderCompilationObservable: Observable<Engine>;
  27273. /** @hidden */
  27274. _gl: WebGLRenderingContext;
  27275. private _renderingCanvas;
  27276. private _windowIsBackground;
  27277. private _webGLVersion;
  27278. /**
  27279. * Gets a boolean indicating that only power of 2 textures are supported
  27280. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27281. */
  27282. readonly needPOTTextures: boolean;
  27283. /** @hidden */
  27284. _badOS: boolean;
  27285. /** @hidden */
  27286. _badDesktopOS: boolean;
  27287. /**
  27288. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27289. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27290. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27291. */
  27292. disableTextureBindingOptimization: boolean;
  27293. /**
  27294. * Gets the audio engine
  27295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27296. * @ignorenaming
  27297. */
  27298. static audioEngine: IAudioEngine;
  27299. /**
  27300. * Default AudioEngine factory responsible of creating the Audio Engine.
  27301. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27302. */
  27303. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27304. /**
  27305. * Default offline support factory responsible of creating a tool used to store data locally.
  27306. * By default, this will create a Database object if the workload has been embedded.
  27307. */
  27308. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27309. private _onFocus;
  27310. private _onBlur;
  27311. private _onCanvasPointerOut;
  27312. private _onCanvasBlur;
  27313. private _onCanvasFocus;
  27314. private _onFullscreenChange;
  27315. private _onPointerLockChange;
  27316. private _onVRDisplayPointerRestricted;
  27317. private _onVRDisplayPointerUnrestricted;
  27318. private _onVrDisplayConnect;
  27319. private _onVrDisplayDisconnect;
  27320. private _onVrDisplayPresentChange;
  27321. /**
  27322. * Observable signaled when VR display mode changes
  27323. */
  27324. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27325. /**
  27326. * Observable signaled when VR request present is complete
  27327. */
  27328. onVRRequestPresentComplete: Observable<boolean>;
  27329. /**
  27330. * Observable signaled when VR request present starts
  27331. */
  27332. onVRRequestPresentStart: Observable<Engine>;
  27333. private _hardwareScalingLevel;
  27334. /** @hidden */
  27335. protected _caps: EngineCapabilities;
  27336. private _pointerLockRequested;
  27337. private _isStencilEnable;
  27338. private _colorWrite;
  27339. private _loadingScreen;
  27340. /** @hidden */
  27341. _drawCalls: PerfCounter;
  27342. /** @hidden */
  27343. _textureCollisions: PerfCounter;
  27344. private _glVersion;
  27345. private _glRenderer;
  27346. private _glVendor;
  27347. private _videoTextureSupported;
  27348. private _renderingQueueLaunched;
  27349. private _activeRenderLoops;
  27350. private _deterministicLockstep;
  27351. private _lockstepMaxSteps;
  27352. /**
  27353. * Observable signaled when a context lost event is raised
  27354. */
  27355. onContextLostObservable: Observable<Engine>;
  27356. /**
  27357. * Observable signaled when a context restored event is raised
  27358. */
  27359. onContextRestoredObservable: Observable<Engine>;
  27360. private _onContextLost;
  27361. private _onContextRestored;
  27362. private _contextWasLost;
  27363. private _doNotHandleContextLost;
  27364. /**
  27365. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27366. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27367. */
  27368. doNotHandleContextLost: boolean;
  27369. private _performanceMonitor;
  27370. private _fps;
  27371. private _deltaTime;
  27372. /**
  27373. * Turn this value on if you want to pause FPS computation when in background
  27374. */
  27375. disablePerformanceMonitorInBackground: boolean;
  27376. /**
  27377. * Gets the performance monitor attached to this engine
  27378. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27379. */
  27380. readonly performanceMonitor: PerformanceMonitor;
  27381. /** @hidden */
  27382. protected _depthCullingState: _DepthCullingState;
  27383. /** @hidden */
  27384. protected _stencilState: _StencilState;
  27385. /** @hidden */
  27386. protected _alphaState: _AlphaState;
  27387. /** @hidden */
  27388. protected _alphaMode: number;
  27389. protected _internalTexturesCache: InternalTexture[];
  27390. /** @hidden */
  27391. protected _activeChannel: number;
  27392. private _currentTextureChannel;
  27393. /** @hidden */
  27394. protected _boundTexturesCache: {
  27395. [key: string]: Nullable<InternalTexture>;
  27396. };
  27397. /** @hidden */
  27398. protected _currentEffect: Nullable<Effect>;
  27399. /** @hidden */
  27400. protected _currentProgram: Nullable<WebGLProgram>;
  27401. private _compiledEffects;
  27402. private _vertexAttribArraysEnabled;
  27403. /** @hidden */
  27404. protected _cachedViewport: Nullable<Viewport>;
  27405. private _cachedVertexArrayObject;
  27406. /** @hidden */
  27407. protected _cachedVertexBuffers: any;
  27408. /** @hidden */
  27409. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27410. /** @hidden */
  27411. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27412. /** @hidden */
  27413. protected _currentRenderTarget: Nullable<InternalTexture>;
  27414. private _uintIndicesCurrentlySet;
  27415. private _currentBoundBuffer;
  27416. /** @hidden */
  27417. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27418. private _currentBufferPointers;
  27419. private _currentInstanceLocations;
  27420. private _currentInstanceBuffers;
  27421. private _textureUnits;
  27422. private _firstBoundInternalTextureTracker;
  27423. private _lastBoundInternalTextureTracker;
  27424. private _workingCanvas;
  27425. private _workingContext;
  27426. private _rescalePostProcess;
  27427. private _dummyFramebuffer;
  27428. private _externalData;
  27429. private _bindedRenderFunction;
  27430. private _vaoRecordInProgress;
  27431. private _mustWipeVertexAttributes;
  27432. private _emptyTexture;
  27433. private _emptyCubeTexture;
  27434. private _emptyTexture3D;
  27435. /** @hidden */
  27436. _frameHandler: number;
  27437. private _nextFreeTextureSlots;
  27438. private _maxSimultaneousTextures;
  27439. private _activeRequests;
  27440. private _texturesSupported;
  27441. private _textureFormatInUse;
  27442. /**
  27443. * Gets the list of texture formats supported
  27444. */
  27445. readonly texturesSupported: Array<string>;
  27446. /**
  27447. * Gets the list of texture formats in use
  27448. */
  27449. readonly textureFormatInUse: Nullable<string>;
  27450. /**
  27451. * Gets the current viewport
  27452. */
  27453. readonly currentViewport: Nullable<Viewport>;
  27454. /**
  27455. * Gets the default empty texture
  27456. */
  27457. readonly emptyTexture: InternalTexture;
  27458. /**
  27459. * Gets the default empty 3D texture
  27460. */
  27461. readonly emptyTexture3D: InternalTexture;
  27462. /**
  27463. * Gets the default empty cube texture
  27464. */
  27465. readonly emptyCubeTexture: InternalTexture;
  27466. /**
  27467. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27468. */
  27469. readonly premultipliedAlpha: boolean;
  27470. /**
  27471. * Creates a new engine
  27472. * @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
  27473. * @param antialias defines enable antialiasing (default: false)
  27474. * @param options defines further options to be sent to the getContext() function
  27475. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27476. */
  27477. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27478. private _disableTouchAction;
  27479. private _rebuildInternalTextures;
  27480. private _rebuildEffects;
  27481. /**
  27482. * Gets a boolean indicating if all created effects are ready
  27483. * @returns true if all effects are ready
  27484. */
  27485. areAllEffectsReady(): boolean;
  27486. private _rebuildBuffers;
  27487. private _initGLContext;
  27488. /**
  27489. * Gets version of the current webGL context
  27490. */
  27491. readonly webGLVersion: number;
  27492. /**
  27493. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27494. */
  27495. readonly isStencilEnable: boolean;
  27496. private _prepareWorkingCanvas;
  27497. /**
  27498. * Reset the texture cache to empty state
  27499. */
  27500. resetTextureCache(): void;
  27501. /**
  27502. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27503. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27504. * @returns true if engine is in deterministic lock step mode
  27505. */
  27506. isDeterministicLockStep(): boolean;
  27507. /**
  27508. * Gets the max steps when engine is running in deterministic lock step
  27509. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27510. * @returns the max steps
  27511. */
  27512. getLockstepMaxSteps(): number;
  27513. /**
  27514. * Gets an object containing information about the current webGL context
  27515. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27516. */
  27517. getGlInfo(): {
  27518. vendor: string;
  27519. renderer: string;
  27520. version: string;
  27521. };
  27522. /**
  27523. * Gets current aspect ratio
  27524. * @param camera defines the camera to use to get the aspect ratio
  27525. * @param useScreen defines if screen size must be used (or the current render target if any)
  27526. * @returns a number defining the aspect ratio
  27527. */
  27528. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27529. /**
  27530. * Gets current screen aspect ratio
  27531. * @returns a number defining the aspect ratio
  27532. */
  27533. getScreenAspectRatio(): number;
  27534. /**
  27535. * Gets the current render width
  27536. * @param useScreen defines if screen size must be used (or the current render target if any)
  27537. * @returns a number defining the current render width
  27538. */
  27539. getRenderWidth(useScreen?: boolean): number;
  27540. /**
  27541. * Gets the current render height
  27542. * @param useScreen defines if screen size must be used (or the current render target if any)
  27543. * @returns a number defining the current render height
  27544. */
  27545. getRenderHeight(useScreen?: boolean): number;
  27546. /**
  27547. * Gets the HTML canvas attached with the current webGL context
  27548. * @returns a HTML canvas
  27549. */
  27550. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27551. /**
  27552. * Gets the client rect of the HTML canvas attached with the current webGL context
  27553. * @returns a client rectanglee
  27554. */
  27555. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27556. /**
  27557. * Defines the hardware scaling level.
  27558. * By default the hardware scaling level is computed from the window device ratio.
  27559. * 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.
  27560. * @param level defines the level to use
  27561. */
  27562. setHardwareScalingLevel(level: number): void;
  27563. /**
  27564. * Gets the current hardware scaling level.
  27565. * By default the hardware scaling level is computed from the window device ratio.
  27566. * 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.
  27567. * @returns a number indicating the current hardware scaling level
  27568. */
  27569. getHardwareScalingLevel(): number;
  27570. /**
  27571. * Gets the list of loaded textures
  27572. * @returns an array containing all loaded textures
  27573. */
  27574. getLoadedTexturesCache(): InternalTexture[];
  27575. /**
  27576. * Gets the object containing all engine capabilities
  27577. * @returns the EngineCapabilities object
  27578. */
  27579. getCaps(): EngineCapabilities;
  27580. /**
  27581. * Gets the current depth function
  27582. * @returns a number defining the depth function
  27583. */
  27584. getDepthFunction(): Nullable<number>;
  27585. /**
  27586. * Sets the current depth function
  27587. * @param depthFunc defines the function to use
  27588. */
  27589. setDepthFunction(depthFunc: number): void;
  27590. /**
  27591. * Sets the current depth function to GREATER
  27592. */
  27593. setDepthFunctionToGreater(): void;
  27594. /**
  27595. * Sets the current depth function to GEQUAL
  27596. */
  27597. setDepthFunctionToGreaterOrEqual(): void;
  27598. /**
  27599. * Sets the current depth function to LESS
  27600. */
  27601. setDepthFunctionToLess(): void;
  27602. /**
  27603. * Sets the current depth function to LEQUAL
  27604. */
  27605. setDepthFunctionToLessOrEqual(): void;
  27606. /**
  27607. * Gets a boolean indicating if stencil buffer is enabled
  27608. * @returns the current stencil buffer state
  27609. */
  27610. getStencilBuffer(): boolean;
  27611. /**
  27612. * Enable or disable the stencil buffer
  27613. * @param enable defines if the stencil buffer must be enabled or disabled
  27614. */
  27615. setStencilBuffer(enable: boolean): void;
  27616. /**
  27617. * Gets the current stencil mask
  27618. * @returns a number defining the new stencil mask to use
  27619. */
  27620. getStencilMask(): number;
  27621. /**
  27622. * Sets the current stencil mask
  27623. * @param mask defines the new stencil mask to use
  27624. */
  27625. setStencilMask(mask: number): void;
  27626. /**
  27627. * Gets the current stencil function
  27628. * @returns a number defining the stencil function to use
  27629. */
  27630. getStencilFunction(): number;
  27631. /**
  27632. * Gets the current stencil reference value
  27633. * @returns a number defining the stencil reference value to use
  27634. */
  27635. getStencilFunctionReference(): number;
  27636. /**
  27637. * Gets the current stencil mask
  27638. * @returns a number defining the stencil mask to use
  27639. */
  27640. getStencilFunctionMask(): number;
  27641. /**
  27642. * Sets the current stencil function
  27643. * @param stencilFunc defines the new stencil function to use
  27644. */
  27645. setStencilFunction(stencilFunc: number): void;
  27646. /**
  27647. * Sets the current stencil reference
  27648. * @param reference defines the new stencil reference to use
  27649. */
  27650. setStencilFunctionReference(reference: number): void;
  27651. /**
  27652. * Sets the current stencil mask
  27653. * @param mask defines the new stencil mask to use
  27654. */
  27655. setStencilFunctionMask(mask: number): void;
  27656. /**
  27657. * Gets the current stencil operation when stencil fails
  27658. * @returns a number defining stencil operation to use when stencil fails
  27659. */
  27660. getStencilOperationFail(): number;
  27661. /**
  27662. * Gets the current stencil operation when depth fails
  27663. * @returns a number defining stencil operation to use when depth fails
  27664. */
  27665. getStencilOperationDepthFail(): number;
  27666. /**
  27667. * Gets the current stencil operation when stencil passes
  27668. * @returns a number defining stencil operation to use when stencil passes
  27669. */
  27670. getStencilOperationPass(): number;
  27671. /**
  27672. * Sets the stencil operation to use when stencil fails
  27673. * @param operation defines the stencil operation to use when stencil fails
  27674. */
  27675. setStencilOperationFail(operation: number): void;
  27676. /**
  27677. * Sets the stencil operation to use when depth fails
  27678. * @param operation defines the stencil operation to use when depth fails
  27679. */
  27680. setStencilOperationDepthFail(operation: number): void;
  27681. /**
  27682. * Sets the stencil operation to use when stencil passes
  27683. * @param operation defines the stencil operation to use when stencil passes
  27684. */
  27685. setStencilOperationPass(operation: number): void;
  27686. /**
  27687. * Sets a boolean indicating if the dithering state is enabled or disabled
  27688. * @param value defines the dithering state
  27689. */
  27690. setDitheringState(value: boolean): void;
  27691. /**
  27692. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27693. * @param value defines the rasterizer state
  27694. */
  27695. setRasterizerState(value: boolean): void;
  27696. /**
  27697. * stop executing a render loop function and remove it from the execution array
  27698. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27699. */
  27700. stopRenderLoop(renderFunction?: () => void): void;
  27701. /** @hidden */
  27702. _renderLoop(): void;
  27703. /**
  27704. * Register and execute a render loop. The engine can have more than one render function
  27705. * @param renderFunction defines the function to continuously execute
  27706. */
  27707. runRenderLoop(renderFunction: () => void): void;
  27708. /**
  27709. * Toggle full screen mode
  27710. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27711. */
  27712. switchFullscreen(requestPointerLock: boolean): void;
  27713. /**
  27714. * Enters full screen mode
  27715. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27716. */
  27717. enterFullscreen(requestPointerLock: boolean): void;
  27718. /**
  27719. * Exits full screen mode
  27720. */
  27721. exitFullscreen(): void;
  27722. /**
  27723. * Clear the current render buffer or the current render target (if any is set up)
  27724. * @param color defines the color to use
  27725. * @param backBuffer defines if the back buffer must be cleared
  27726. * @param depth defines if the depth buffer must be cleared
  27727. * @param stencil defines if the stencil buffer must be cleared
  27728. */
  27729. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27730. /**
  27731. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27732. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27733. * @param y defines the y-coordinate of the corner of the clear rectangle
  27734. * @param width defines the width of the clear rectangle
  27735. * @param height defines the height of the clear rectangle
  27736. * @param clearColor defines the clear color
  27737. */
  27738. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27739. /**
  27740. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27741. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27742. * @param y defines the y-coordinate of the corner of the clear rectangle
  27743. * @param width defines the width of the clear rectangle
  27744. * @param height defines the height of the clear rectangle
  27745. */
  27746. enableScissor(x: number, y: number, width: number, height: number): void;
  27747. /**
  27748. * Disable previously set scissor test rectangle
  27749. */
  27750. disableScissor(): void;
  27751. private _viewportCached;
  27752. /** @hidden */
  27753. _viewport(x: number, y: number, width: number, height: number): void;
  27754. /**
  27755. * Set the WebGL's viewport
  27756. * @param viewport defines the viewport element to be used
  27757. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27758. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27759. */
  27760. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27761. /**
  27762. * Directly set the WebGL Viewport
  27763. * @param x defines the x coordinate of the viewport (in screen space)
  27764. * @param y defines the y coordinate of the viewport (in screen space)
  27765. * @param width defines the width of the viewport (in screen space)
  27766. * @param height defines the height of the viewport (in screen space)
  27767. * @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
  27768. */
  27769. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27770. /**
  27771. * Begin a new frame
  27772. */
  27773. beginFrame(): void;
  27774. /**
  27775. * Enf the current frame
  27776. */
  27777. endFrame(): void;
  27778. /**
  27779. * Resize the view according to the canvas' size
  27780. */
  27781. resize(): void;
  27782. /**
  27783. * Force a specific size of the canvas
  27784. * @param width defines the new canvas' width
  27785. * @param height defines the new canvas' height
  27786. */
  27787. setSize(width: number, height: number): void;
  27788. /**
  27789. * Gets a boolean indicating if a webVR device was detected
  27790. * @returns true if a webVR device was detected
  27791. */
  27792. isVRDevicePresent(): boolean;
  27793. /**
  27794. * Gets the current webVR device
  27795. * @returns the current webVR device (or null)
  27796. */
  27797. getVRDevice(): any;
  27798. /**
  27799. * Initializes a webVR display and starts listening to display change events
  27800. * The onVRDisplayChangedObservable will be notified upon these changes
  27801. * @returns The onVRDisplayChangedObservable
  27802. */
  27803. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27804. /**
  27805. * Initializes a webVR display and starts listening to display change events
  27806. * The onVRDisplayChangedObservable will be notified upon these changes
  27807. * @returns A promise containing a VRDisplay and if vr is supported
  27808. */
  27809. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27810. /**
  27811. * Call this function to switch to webVR mode
  27812. * Will do nothing if webVR is not supported or if there is no webVR device
  27813. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27814. */
  27815. enableVR(): void;
  27816. /**
  27817. * Call this function to leave webVR mode
  27818. * Will do nothing if webVR is not supported or if there is no webVR device
  27819. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27820. */
  27821. disableVR(): void;
  27822. private _onVRFullScreenTriggered;
  27823. private _getVRDisplaysAsync;
  27824. /**
  27825. * Binds the frame buffer to the specified texture.
  27826. * @param texture The texture to render to or null for the default canvas
  27827. * @param faceIndex The face of the texture to render to in case of cube texture
  27828. * @param requiredWidth The width of the target to render to
  27829. * @param requiredHeight The height of the target to render to
  27830. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27831. * @param depthStencilTexture The depth stencil texture to use to render
  27832. * @param lodLevel defines le lod level to bind to the frame buffer
  27833. */
  27834. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27835. private bindUnboundFramebuffer;
  27836. /**
  27837. * Unbind the current render target texture from the webGL context
  27838. * @param texture defines the render target texture to unbind
  27839. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27840. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27841. */
  27842. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27843. /**
  27844. * Unbind a list of render target textures from the webGL context
  27845. * This is used only when drawBuffer extension or webGL2 are active
  27846. * @param textures defines the render target textures to unbind
  27847. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27848. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27849. */
  27850. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27851. /**
  27852. * Force the mipmap generation for the given render target texture
  27853. * @param texture defines the render target texture to use
  27854. */
  27855. generateMipMapsForCubemap(texture: InternalTexture): void;
  27856. /**
  27857. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27858. */
  27859. flushFramebuffer(): void;
  27860. /**
  27861. * Unbind the current render target and bind the default framebuffer
  27862. */
  27863. restoreDefaultFramebuffer(): void;
  27864. /**
  27865. * Create an uniform buffer
  27866. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27867. * @param elements defines the content of the uniform buffer
  27868. * @returns the webGL uniform buffer
  27869. */
  27870. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27871. /**
  27872. * Create a dynamic uniform buffer
  27873. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27874. * @param elements defines the content of the uniform buffer
  27875. * @returns the webGL uniform buffer
  27876. */
  27877. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27878. /**
  27879. * Update an existing uniform buffer
  27880. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27881. * @param uniformBuffer defines the target uniform buffer
  27882. * @param elements defines the content to update
  27883. * @param offset defines the offset in the uniform buffer where update should start
  27884. * @param count defines the size of the data to update
  27885. */
  27886. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27887. private _resetVertexBufferBinding;
  27888. /**
  27889. * Creates a vertex buffer
  27890. * @param data the data for the vertex buffer
  27891. * @returns the new WebGL static buffer
  27892. */
  27893. createVertexBuffer(data: DataArray): WebGLBuffer;
  27894. /**
  27895. * Creates a dynamic vertex buffer
  27896. * @param data the data for the dynamic vertex buffer
  27897. * @returns the new WebGL dynamic buffer
  27898. */
  27899. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27900. /**
  27901. * Update a dynamic index buffer
  27902. * @param indexBuffer defines the target index buffer
  27903. * @param indices defines the data to update
  27904. * @param offset defines the offset in the target index buffer where update should start
  27905. */
  27906. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27907. /**
  27908. * Updates a dynamic vertex buffer.
  27909. * @param vertexBuffer the vertex buffer to update
  27910. * @param data the data used to update the vertex buffer
  27911. * @param byteOffset the byte offset of the data
  27912. * @param byteLength the byte length of the data
  27913. */
  27914. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27915. private _resetIndexBufferBinding;
  27916. /**
  27917. * Creates a new index buffer
  27918. * @param indices defines the content of the index buffer
  27919. * @param updatable defines if the index buffer must be updatable
  27920. * @returns a new webGL buffer
  27921. */
  27922. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27923. /**
  27924. * Bind a webGL buffer to the webGL context
  27925. * @param buffer defines the buffer to bind
  27926. */
  27927. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27928. /**
  27929. * Bind an uniform buffer to the current webGL context
  27930. * @param buffer defines the buffer to bind
  27931. */
  27932. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27933. /**
  27934. * Bind a buffer to the current webGL context at a given location
  27935. * @param buffer defines the buffer to bind
  27936. * @param location defines the index where to bind the buffer
  27937. */
  27938. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27939. /**
  27940. * Bind a specific block at a given index in a specific shader program
  27941. * @param shaderProgram defines the shader program
  27942. * @param blockName defines the block name
  27943. * @param index defines the index where to bind the block
  27944. */
  27945. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27946. private bindIndexBuffer;
  27947. private bindBuffer;
  27948. /**
  27949. * update the bound buffer with the given data
  27950. * @param data defines the data to update
  27951. */
  27952. updateArrayBuffer(data: Float32Array): void;
  27953. private _vertexAttribPointer;
  27954. private _bindIndexBufferWithCache;
  27955. private _bindVertexBuffersAttributes;
  27956. /**
  27957. * Records a vertex array object
  27958. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27959. * @param vertexBuffers defines the list of vertex buffers to store
  27960. * @param indexBuffer defines the index buffer to store
  27961. * @param effect defines the effect to store
  27962. * @returns the new vertex array object
  27963. */
  27964. recordVertexArrayObject(vertexBuffers: {
  27965. [key: string]: VertexBuffer;
  27966. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27967. /**
  27968. * Bind a specific vertex array object
  27969. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27970. * @param vertexArrayObject defines the vertex array object to bind
  27971. * @param indexBuffer defines the index buffer to bind
  27972. */
  27973. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27974. /**
  27975. * Bind webGl buffers directly to the webGL context
  27976. * @param vertexBuffer defines the vertex buffer to bind
  27977. * @param indexBuffer defines the index buffer to bind
  27978. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27979. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27980. * @param effect defines the effect associated with the vertex buffer
  27981. */
  27982. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27983. private _unbindVertexArrayObject;
  27984. /**
  27985. * Bind a list of vertex buffers to the webGL context
  27986. * @param vertexBuffers defines the list of vertex buffers to bind
  27987. * @param indexBuffer defines the index buffer to bind
  27988. * @param effect defines the effect associated with the vertex buffers
  27989. */
  27990. bindBuffers(vertexBuffers: {
  27991. [key: string]: Nullable<VertexBuffer>;
  27992. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27993. /**
  27994. * Unbind all instance attributes
  27995. */
  27996. unbindInstanceAttributes(): void;
  27997. /**
  27998. * Release and free the memory of a vertex array object
  27999. * @param vao defines the vertex array object to delete
  28000. */
  28001. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28002. /** @hidden */
  28003. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28004. /**
  28005. * Creates a webGL buffer to use with instanciation
  28006. * @param capacity defines the size of the buffer
  28007. * @returns the webGL buffer
  28008. */
  28009. createInstancesBuffer(capacity: number): WebGLBuffer;
  28010. /**
  28011. * Delete a webGL buffer used with instanciation
  28012. * @param buffer defines the webGL buffer to delete
  28013. */
  28014. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28015. /**
  28016. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28017. * @param instancesBuffer defines the webGL buffer to update and bind
  28018. * @param data defines the data to store in the buffer
  28019. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28020. */
  28021. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28022. /**
  28023. * Apply all cached states (depth, culling, stencil and alpha)
  28024. */
  28025. applyStates(): void;
  28026. /**
  28027. * Send a draw order
  28028. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28029. * @param indexStart defines the starting index
  28030. * @param indexCount defines the number of index to draw
  28031. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28032. */
  28033. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28034. /**
  28035. * Draw a list of points
  28036. * @param verticesStart defines the index of first vertex to draw
  28037. * @param verticesCount defines the count of vertices to draw
  28038. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28039. */
  28040. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28041. /**
  28042. * Draw a list of unindexed primitives
  28043. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28044. * @param verticesStart defines the index of first vertex to draw
  28045. * @param verticesCount defines the count of vertices to draw
  28046. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28047. */
  28048. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28049. /**
  28050. * Draw a list of indexed primitives
  28051. * @param fillMode defines the primitive to use
  28052. * @param indexStart defines the starting index
  28053. * @param indexCount defines the number of index to draw
  28054. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28055. */
  28056. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28057. /**
  28058. * Draw a list of unindexed primitives
  28059. * @param fillMode defines the primitive to use
  28060. * @param verticesStart defines the index of first vertex to draw
  28061. * @param verticesCount defines the count of vertices to draw
  28062. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28063. */
  28064. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28065. private _drawMode;
  28066. /** @hidden */
  28067. _releaseEffect(effect: Effect): void;
  28068. /** @hidden */
  28069. _deleteProgram(program: WebGLProgram): void;
  28070. /**
  28071. * Create a new effect (used to store vertex/fragment shaders)
  28072. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28073. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28074. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28075. * @param samplers defines an array of string used to represent textures
  28076. * @param defines defines the string containing the defines to use to compile the shaders
  28077. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28078. * @param onCompiled defines a function to call when the effect creation is successful
  28079. * @param onError defines a function to call when the effect creation has failed
  28080. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28081. * @returns the new Effect
  28082. */
  28083. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  28084. private _compileShader;
  28085. private _compileRawShader;
  28086. /**
  28087. * Directly creates a webGL program
  28088. * @param vertexCode defines the vertex shader code to use
  28089. * @param fragmentCode defines the fragment shader code to use
  28090. * @param context defines the webGL context to use (if not set, the current one will be used)
  28091. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28092. * @returns the new webGL program
  28093. */
  28094. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28095. /**
  28096. * Creates a webGL program
  28097. * @param vertexCode defines the vertex shader code to use
  28098. * @param fragmentCode defines the fragment shader code to use
  28099. * @param defines defines the string containing the defines to use to compile the shaders
  28100. * @param context defines the webGL context to use (if not set, the current one will be used)
  28101. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28102. * @returns the new webGL program
  28103. */
  28104. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28105. private _createShaderProgram;
  28106. private _finalizeProgram;
  28107. /** @hidden */
  28108. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28109. /** @hidden */
  28110. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28111. /**
  28112. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28113. * @param shaderProgram defines the webGL program to use
  28114. * @param uniformsNames defines the list of uniform names
  28115. * @returns an array of webGL uniform locations
  28116. */
  28117. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28118. /**
  28119. * Gets the lsit of active attributes for a given webGL program
  28120. * @param shaderProgram defines the webGL program to use
  28121. * @param attributesNames defines the list of attribute names to get
  28122. * @returns an array of indices indicating the offset of each attribute
  28123. */
  28124. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28125. /**
  28126. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28127. * @param effect defines the effect to activate
  28128. */
  28129. enableEffect(effect: Nullable<Effect>): void;
  28130. /**
  28131. * Set the value of an uniform to an array of int32
  28132. * @param uniform defines the webGL uniform location where to store the value
  28133. * @param array defines the array of int32 to store
  28134. */
  28135. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28136. /**
  28137. * Set the value of an uniform to an array of int32 (stored as vec2)
  28138. * @param uniform defines the webGL uniform location where to store the value
  28139. * @param array defines the array of int32 to store
  28140. */
  28141. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28142. /**
  28143. * Set the value of an uniform to an array of int32 (stored as vec3)
  28144. * @param uniform defines the webGL uniform location where to store the value
  28145. * @param array defines the array of int32 to store
  28146. */
  28147. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28148. /**
  28149. * Set the value of an uniform to an array of int32 (stored as vec4)
  28150. * @param uniform defines the webGL uniform location where to store the value
  28151. * @param array defines the array of int32 to store
  28152. */
  28153. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28154. /**
  28155. * Set the value of an uniform to an array of float32
  28156. * @param uniform defines the webGL uniform location where to store the value
  28157. * @param array defines the array of float32 to store
  28158. */
  28159. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28160. /**
  28161. * Set the value of an uniform to an array of float32 (stored as vec2)
  28162. * @param uniform defines the webGL uniform location where to store the value
  28163. * @param array defines the array of float32 to store
  28164. */
  28165. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28166. /**
  28167. * Set the value of an uniform to an array of float32 (stored as vec3)
  28168. * @param uniform defines the webGL uniform location where to store the value
  28169. * @param array defines the array of float32 to store
  28170. */
  28171. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28172. /**
  28173. * Set the value of an uniform to an array of float32 (stored as vec4)
  28174. * @param uniform defines the webGL uniform location where to store the value
  28175. * @param array defines the array of float32 to store
  28176. */
  28177. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28178. /**
  28179. * Set the value of an uniform to an array of number
  28180. * @param uniform defines the webGL uniform location where to store the value
  28181. * @param array defines the array of number to store
  28182. */
  28183. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28184. /**
  28185. * Set the value of an uniform to an array of number (stored as vec2)
  28186. * @param uniform defines the webGL uniform location where to store the value
  28187. * @param array defines the array of number to store
  28188. */
  28189. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28190. /**
  28191. * Set the value of an uniform to an array of number (stored as vec3)
  28192. * @param uniform defines the webGL uniform location where to store the value
  28193. * @param array defines the array of number to store
  28194. */
  28195. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28196. /**
  28197. * Set the value of an uniform to an array of number (stored as vec4)
  28198. * @param uniform defines the webGL uniform location where to store the value
  28199. * @param array defines the array of number to store
  28200. */
  28201. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28202. /**
  28203. * Set the value of an uniform to an array of float32 (stored as matrices)
  28204. * @param uniform defines the webGL uniform location where to store the value
  28205. * @param matrices defines the array of float32 to store
  28206. */
  28207. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28208. /**
  28209. * Set the value of an uniform to a matrix
  28210. * @param uniform defines the webGL uniform location where to store the value
  28211. * @param matrix defines the matrix to store
  28212. */
  28213. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28214. /**
  28215. * Set the value of an uniform to a matrix (3x3)
  28216. * @param uniform defines the webGL uniform location where to store the value
  28217. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28218. */
  28219. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28220. /**
  28221. * Set the value of an uniform to a matrix (2x2)
  28222. * @param uniform defines the webGL uniform location where to store the value
  28223. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28224. */
  28225. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28226. /**
  28227. * Set the value of an uniform to a number (int)
  28228. * @param uniform defines the webGL uniform location where to store the value
  28229. * @param value defines the int number to store
  28230. */
  28231. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28232. /**
  28233. * Set the value of an uniform to a number (float)
  28234. * @param uniform defines the webGL uniform location where to store the value
  28235. * @param value defines the float number to store
  28236. */
  28237. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28238. /**
  28239. * Set the value of an uniform to a vec2
  28240. * @param uniform defines the webGL uniform location where to store the value
  28241. * @param x defines the 1st component of the value
  28242. * @param y defines the 2nd component of the value
  28243. */
  28244. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28245. /**
  28246. * Set the value of an uniform to a vec3
  28247. * @param uniform defines the webGL uniform location where to store the value
  28248. * @param x defines the 1st component of the value
  28249. * @param y defines the 2nd component of the value
  28250. * @param z defines the 3rd component of the value
  28251. */
  28252. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28253. /**
  28254. * Set the value of an uniform to a boolean
  28255. * @param uniform defines the webGL uniform location where to store the value
  28256. * @param bool defines the boolean to store
  28257. */
  28258. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28259. /**
  28260. * Set the value of an uniform to a vec4
  28261. * @param uniform defines the webGL uniform location where to store the value
  28262. * @param x defines the 1st component of the value
  28263. * @param y defines the 2nd component of the value
  28264. * @param z defines the 3rd component of the value
  28265. * @param w defines the 4th component of the value
  28266. */
  28267. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28268. /**
  28269. * Set the value of an uniform to a Color3
  28270. * @param uniform defines the webGL uniform location where to store the value
  28271. * @param color3 defines the color to store
  28272. */
  28273. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28274. /**
  28275. * Set the value of an uniform to a Color3 and an alpha value
  28276. * @param uniform defines the webGL uniform location where to store the value
  28277. * @param color3 defines the color to store
  28278. * @param alpha defines the alpha component to store
  28279. */
  28280. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28281. /**
  28282. * Sets a Color4 on a uniform variable
  28283. * @param uniform defines the uniform location
  28284. * @param color4 defines the value to be set
  28285. */
  28286. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28287. /**
  28288. * Set various states to the webGL context
  28289. * @param culling defines backface culling state
  28290. * @param zOffset defines the value to apply to zOffset (0 by default)
  28291. * @param force defines if states must be applied even if cache is up to date
  28292. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28293. */
  28294. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28295. /**
  28296. * Set the z offset to apply to current rendering
  28297. * @param value defines the offset to apply
  28298. */
  28299. setZOffset(value: number): void;
  28300. /**
  28301. * Gets the current value of the zOffset
  28302. * @returns the current zOffset state
  28303. */
  28304. getZOffset(): number;
  28305. /**
  28306. * Enable or disable depth buffering
  28307. * @param enable defines the state to set
  28308. */
  28309. setDepthBuffer(enable: boolean): void;
  28310. /**
  28311. * Gets a boolean indicating if depth writing is enabled
  28312. * @returns the current depth writing state
  28313. */
  28314. getDepthWrite(): boolean;
  28315. /**
  28316. * Enable or disable depth writing
  28317. * @param enable defines the state to set
  28318. */
  28319. setDepthWrite(enable: boolean): void;
  28320. /**
  28321. * Enable or disable color writing
  28322. * @param enable defines the state to set
  28323. */
  28324. setColorWrite(enable: boolean): void;
  28325. /**
  28326. * Gets a boolean indicating if color writing is enabled
  28327. * @returns the current color writing state
  28328. */
  28329. getColorWrite(): boolean;
  28330. /**
  28331. * Sets alpha constants used by some alpha blending modes
  28332. * @param r defines the red component
  28333. * @param g defines the green component
  28334. * @param b defines the blue component
  28335. * @param a defines the alpha component
  28336. */
  28337. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28338. /**
  28339. * Sets the current alpha mode
  28340. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28341. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28342. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28343. */
  28344. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28345. /**
  28346. * Gets the current alpha mode
  28347. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28348. * @returns the current alpha mode
  28349. */
  28350. getAlphaMode(): number;
  28351. /**
  28352. * Clears the list of texture accessible through engine.
  28353. * This can help preventing texture load conflict due to name collision.
  28354. */
  28355. clearInternalTexturesCache(): void;
  28356. /**
  28357. * Force the entire cache to be cleared
  28358. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28359. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28360. */
  28361. wipeCaches(bruteForce?: boolean): void;
  28362. /**
  28363. * Set the compressed texture format to use, based on the formats you have, and the formats
  28364. * supported by the hardware / browser.
  28365. *
  28366. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28367. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28368. * to API arguments needed to compressed textures. This puts the burden on the container
  28369. * generator to house the arcane code for determining these for current & future formats.
  28370. *
  28371. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28372. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28373. *
  28374. * Note: The result of this call is not taken into account when a texture is base64.
  28375. *
  28376. * @param formatsAvailable defines the list of those format families you have created
  28377. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28378. *
  28379. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28380. * @returns The extension selected.
  28381. */
  28382. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28383. private _getSamplingParameters;
  28384. private _partialLoadImg;
  28385. private _cascadeLoadImgs;
  28386. /** @hidden */
  28387. _createTexture(): WebGLTexture;
  28388. /**
  28389. * Usually called from Texture.ts.
  28390. * Passed information to create a WebGLTexture
  28391. * @param urlArg defines a value which contains one of the following:
  28392. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28393. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28394. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28395. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28396. * @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)
  28397. * @param scene needed for loading to the correct scene
  28398. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28399. * @param onLoad optional callback to be called upon successful completion
  28400. * @param onError optional callback to be called upon failure
  28401. * @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
  28402. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28403. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28404. * @param forcedExtension defines the extension to use to pick the right loader
  28405. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28406. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28407. */
  28408. 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;
  28409. private _rescaleTexture;
  28410. /**
  28411. * Update a raw texture
  28412. * @param texture defines the texture to update
  28413. * @param data defines the data to store in the texture
  28414. * @param format defines the format of the data
  28415. * @param invertY defines if data must be stored with Y axis inverted
  28416. * @param compression defines the compression used (null by default)
  28417. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28418. */
  28419. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28420. /**
  28421. * Creates a raw texture
  28422. * @param data defines the data to store in the texture
  28423. * @param width defines the width of the texture
  28424. * @param height defines the height of the texture
  28425. * @param format defines the format of the data
  28426. * @param generateMipMaps defines if the engine should generate the mip levels
  28427. * @param invertY defines if data must be stored with Y axis inverted
  28428. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28429. * @param compression defines the compression used (null by default)
  28430. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28431. * @returns the raw texture inside an InternalTexture
  28432. */
  28433. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28434. private _unpackFlipYCached;
  28435. /**
  28436. * In case you are sharing the context with other applications, it might
  28437. * be interested to not cache the unpack flip y state to ensure a consistent
  28438. * value would be set.
  28439. */
  28440. enableUnpackFlipYCached: boolean;
  28441. /** @hidden */
  28442. _unpackFlipY(value: boolean): void;
  28443. /** @hidden */
  28444. _getUnpackAlignement(): number;
  28445. /**
  28446. * Creates a dynamic texture
  28447. * @param width defines the width of the texture
  28448. * @param height defines the height of the texture
  28449. * @param generateMipMaps defines if the engine should generate the mip levels
  28450. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28451. * @returns the dynamic texture inside an InternalTexture
  28452. */
  28453. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28454. /**
  28455. * Update the sampling mode of a given texture
  28456. * @param samplingMode defines the required sampling mode
  28457. * @param texture defines the texture to update
  28458. */
  28459. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28460. /**
  28461. * Update the content of a dynamic texture
  28462. * @param texture defines the texture to update
  28463. * @param canvas defines the canvas containing the source
  28464. * @param invertY defines if data must be stored with Y axis inverted
  28465. * @param premulAlpha defines if alpha is stored as premultiplied
  28466. * @param format defines the format of the data
  28467. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28468. */
  28469. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28470. /**
  28471. * Update a video texture
  28472. * @param texture defines the texture to update
  28473. * @param video defines the video element to use
  28474. * @param invertY defines if data must be stored with Y axis inverted
  28475. */
  28476. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28477. /**
  28478. * Updates a depth texture Comparison Mode and Function.
  28479. * If the comparison Function is equal to 0, the mode will be set to none.
  28480. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28481. * @param texture The texture to set the comparison function for
  28482. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28483. */
  28484. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28485. private _setupDepthStencilTexture;
  28486. /**
  28487. * Creates a depth stencil texture.
  28488. * This is only available in WebGL 2 or with the depth texture extension available.
  28489. * @param size The size of face edge in the texture.
  28490. * @param options The options defining the texture.
  28491. * @returns The texture
  28492. */
  28493. createDepthStencilTexture(size: number | {
  28494. width: number;
  28495. height: number;
  28496. }, options: DepthTextureCreationOptions): InternalTexture;
  28497. /**
  28498. * Creates a depth stencil texture.
  28499. * This is only available in WebGL 2 or with the depth texture extension available.
  28500. * @param size The size of face edge in the texture.
  28501. * @param options The options defining the texture.
  28502. * @returns The texture
  28503. */
  28504. private _createDepthStencilTexture;
  28505. /**
  28506. * Creates a depth stencil cube texture.
  28507. * This is only available in WebGL 2.
  28508. * @param size The size of face edge in the cube texture.
  28509. * @param options The options defining the cube texture.
  28510. * @returns The cube texture
  28511. */
  28512. private _createDepthStencilCubeTexture;
  28513. /**
  28514. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28515. * @param renderTarget The render target to set the frame buffer for
  28516. */
  28517. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28518. /**
  28519. * Creates a new render target texture
  28520. * @param size defines the size of the texture
  28521. * @param options defines the options used to create the texture
  28522. * @returns a new render target texture stored in an InternalTexture
  28523. */
  28524. createRenderTargetTexture(size: number | {
  28525. width: number;
  28526. height: number;
  28527. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28528. /**
  28529. * Create a multi render target texture
  28530. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28531. * @param size defines the size of the texture
  28532. * @param options defines the creation options
  28533. * @returns the cube texture as an InternalTexture
  28534. */
  28535. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28536. private _setupFramebufferDepthAttachments;
  28537. /**
  28538. * Updates the sample count of a render target texture
  28539. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28540. * @param texture defines the texture to update
  28541. * @param samples defines the sample count to set
  28542. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28543. */
  28544. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28545. /**
  28546. * Update the sample count for a given multiple render target texture
  28547. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28548. * @param textures defines the textures to update
  28549. * @param samples defines the sample count to set
  28550. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28551. */
  28552. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28553. /** @hidden */
  28554. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28555. /** @hidden */
  28556. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28557. /** @hidden */
  28558. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28559. /** @hidden */
  28560. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28561. /**
  28562. * Creates a new render target cube texture
  28563. * @param size defines the size of the texture
  28564. * @param options defines the options used to create the texture
  28565. * @returns a new render target cube texture stored in an InternalTexture
  28566. */
  28567. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28568. /**
  28569. * Creates a cube texture
  28570. * @param rootUrl defines the url where the files to load is located
  28571. * @param scene defines the current scene
  28572. * @param files defines the list of files to load (1 per face)
  28573. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28574. * @param onLoad defines an optional callback raised when the texture is loaded
  28575. * @param onError defines an optional callback raised if there is an issue to load the texture
  28576. * @param format defines the format of the data
  28577. * @param forcedExtension defines the extension to use to pick the right loader
  28578. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28579. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28580. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28581. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28582. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28583. * @returns the cube texture as an InternalTexture
  28584. */
  28585. 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;
  28586. /**
  28587. * @hidden
  28588. */
  28589. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28590. /**
  28591. * Update a raw cube texture
  28592. * @param texture defines the texture to udpdate
  28593. * @param data defines the data to store
  28594. * @param format defines the data format
  28595. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28596. * @param invertY defines if data must be stored with Y axis inverted
  28597. * @param compression defines the compression used (null by default)
  28598. * @param level defines which level of the texture to update
  28599. */
  28600. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28601. /**
  28602. * Creates a new raw cube texture
  28603. * @param data defines the array of data to use to create each face
  28604. * @param size defines the size of the textures
  28605. * @param format defines the format of the data
  28606. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28607. * @param generateMipMaps defines if the engine should generate the mip levels
  28608. * @param invertY defines if data must be stored with Y axis inverted
  28609. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28610. * @param compression defines the compression used (null by default)
  28611. * @returns the cube texture as an InternalTexture
  28612. */
  28613. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28614. /**
  28615. * Creates a new raw cube texture from a specified url
  28616. * @param url defines the url where the data is located
  28617. * @param scene defines the current scene
  28618. * @param size defines the size of the textures
  28619. * @param format defines the format of the data
  28620. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28621. * @param noMipmap defines if the engine should avoid generating the mip levels
  28622. * @param callback defines a callback used to extract texture data from loaded data
  28623. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28624. * @param onLoad defines a callback called when texture is loaded
  28625. * @param onError defines a callback called if there is an error
  28626. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28627. * @param invertY defines if data must be stored with Y axis inverted
  28628. * @returns the cube texture as an InternalTexture
  28629. */
  28630. 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;
  28631. /**
  28632. * Update a raw 3D texture
  28633. * @param texture defines the texture to update
  28634. * @param data defines the data to store
  28635. * @param format defines the data format
  28636. * @param invertY defines if data must be stored with Y axis inverted
  28637. * @param compression defines the used compression (can be null)
  28638. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28639. */
  28640. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28641. /**
  28642. * Creates a new raw 3D texture
  28643. * @param data defines the data used to create the texture
  28644. * @param width defines the width of the texture
  28645. * @param height defines the height of the texture
  28646. * @param depth defines the depth of the texture
  28647. * @param format defines the format of the texture
  28648. * @param generateMipMaps defines if the engine must generate mip levels
  28649. * @param invertY defines if data must be stored with Y axis inverted
  28650. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28651. * @param compression defines the compressed used (can be null)
  28652. * @param textureType defines the compressed used (can be null)
  28653. * @returns a new raw 3D texture (stored in an InternalTexture)
  28654. */
  28655. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28656. private _prepareWebGLTextureContinuation;
  28657. private _prepareWebGLTexture;
  28658. private _convertRGBtoRGBATextureData;
  28659. /** @hidden */
  28660. _releaseFramebufferObjects(texture: InternalTexture): void;
  28661. /** @hidden */
  28662. _releaseTexture(texture: InternalTexture): void;
  28663. private setProgram;
  28664. private _boundUniforms;
  28665. /**
  28666. * Binds an effect to the webGL context
  28667. * @param effect defines the effect to bind
  28668. */
  28669. bindSamplers(effect: Effect): void;
  28670. private _moveBoundTextureOnTop;
  28671. private _getCorrectTextureChannel;
  28672. private _linkTrackers;
  28673. private _removeDesignatedSlot;
  28674. private _activateCurrentTexture;
  28675. /** @hidden */
  28676. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28677. /** @hidden */
  28678. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28679. /**
  28680. * Sets a texture to the webGL context from a postprocess
  28681. * @param channel defines the channel to use
  28682. * @param postProcess defines the source postprocess
  28683. */
  28684. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28685. /**
  28686. * Binds the output of the passed in post process to the texture channel specified
  28687. * @param channel The channel the texture should be bound to
  28688. * @param postProcess The post process which's output should be bound
  28689. */
  28690. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28691. /**
  28692. * Unbind all textures from the webGL context
  28693. */
  28694. unbindAllTextures(): void;
  28695. /**
  28696. * Sets a texture to the according uniform.
  28697. * @param channel The texture channel
  28698. * @param uniform The uniform to set
  28699. * @param texture The texture to apply
  28700. */
  28701. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28702. /**
  28703. * Sets a depth stencil texture from a render target to the according uniform.
  28704. * @param channel The texture channel
  28705. * @param uniform The uniform to set
  28706. * @param texture The render target texture containing the depth stencil texture to apply
  28707. */
  28708. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28709. private _bindSamplerUniformToChannel;
  28710. private _getTextureWrapMode;
  28711. private _setTexture;
  28712. /**
  28713. * Sets an array of texture to the webGL context
  28714. * @param channel defines the channel where the texture array must be set
  28715. * @param uniform defines the associated uniform location
  28716. * @param textures defines the array of textures to bind
  28717. */
  28718. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28719. /** @hidden */
  28720. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28721. private _setTextureParameterFloat;
  28722. private _setTextureParameterInteger;
  28723. /**
  28724. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28725. * @param x defines the x coordinate of the rectangle where pixels must be read
  28726. * @param y defines the y coordinate of the rectangle where pixels must be read
  28727. * @param width defines the width of the rectangle where pixels must be read
  28728. * @param height defines the height of the rectangle where pixels must be read
  28729. * @returns a Uint8Array containing RGBA colors
  28730. */
  28731. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28732. /**
  28733. * Add an externaly attached data from its key.
  28734. * This method call will fail and return false, if such key already exists.
  28735. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28736. * @param key the unique key that identifies the data
  28737. * @param data the data object to associate to the key for this Engine instance
  28738. * @return true if no such key were already present and the data was added successfully, false otherwise
  28739. */
  28740. addExternalData<T>(key: string, data: T): boolean;
  28741. /**
  28742. * Get an externaly attached data from its key
  28743. * @param key the unique key that identifies the data
  28744. * @return the associated data, if present (can be null), or undefined if not present
  28745. */
  28746. getExternalData<T>(key: string): T;
  28747. /**
  28748. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28749. * @param key the unique key that identifies the data
  28750. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28751. * @return the associated data, can be null if the factory returned null.
  28752. */
  28753. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28754. /**
  28755. * Remove an externaly attached data from the Engine instance
  28756. * @param key the unique key that identifies the data
  28757. * @return true if the data was successfully removed, false if it doesn't exist
  28758. */
  28759. removeExternalData(key: string): boolean;
  28760. /**
  28761. * Unbind all vertex attributes from the webGL context
  28762. */
  28763. unbindAllAttributes(): void;
  28764. /**
  28765. * 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
  28766. */
  28767. releaseEffects(): void;
  28768. /**
  28769. * Dispose and release all associated resources
  28770. */
  28771. dispose(): void;
  28772. /**
  28773. * Display the loading screen
  28774. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28775. */
  28776. displayLoadingUI(): void;
  28777. /**
  28778. * Hide the loading screen
  28779. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28780. */
  28781. hideLoadingUI(): void;
  28782. /**
  28783. * Gets the current loading screen object
  28784. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28785. */
  28786. /**
  28787. * Sets the current loading screen object
  28788. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28789. */
  28790. loadingScreen: ILoadingScreen;
  28791. /**
  28792. * Sets the current loading screen text
  28793. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28794. */
  28795. loadingUIText: string;
  28796. /**
  28797. * Sets the current loading screen background color
  28798. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28799. */
  28800. loadingUIBackgroundColor: string;
  28801. /**
  28802. * Attach a new callback raised when context lost event is fired
  28803. * @param callback defines the callback to call
  28804. */
  28805. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28806. /**
  28807. * Attach a new callback raised when context restored event is fired
  28808. * @param callback defines the callback to call
  28809. */
  28810. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28811. /**
  28812. * Gets the source code of the vertex shader associated with a specific webGL program
  28813. * @param program defines the program to use
  28814. * @returns a string containing the source code of the vertex shader associated with the program
  28815. */
  28816. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28817. /**
  28818. * Gets the source code of the fragment shader associated with a specific webGL program
  28819. * @param program defines the program to use
  28820. * @returns a string containing the source code of the fragment shader associated with the program
  28821. */
  28822. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28823. /**
  28824. * Get the current error code of the webGL context
  28825. * @returns the error code
  28826. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28827. */
  28828. getError(): number;
  28829. /**
  28830. * Gets the current framerate
  28831. * @returns a number representing the framerate
  28832. */
  28833. getFps(): number;
  28834. /**
  28835. * Gets the time spent between current and previous frame
  28836. * @returns a number representing the delta time in ms
  28837. */
  28838. getDeltaTime(): number;
  28839. private _measureFps;
  28840. /** @hidden */
  28841. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28842. private _canRenderToFloatFramebuffer;
  28843. private _canRenderToHalfFloatFramebuffer;
  28844. private _canRenderToFramebuffer;
  28845. /** @hidden */
  28846. _getWebGLTextureType(type: number): number;
  28847. private _getInternalFormat;
  28848. /** @hidden */
  28849. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28850. /** @hidden */
  28851. _getRGBAMultiSampleBufferFormat(type: number): number;
  28852. /** @hidden */
  28853. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  28854. /** @hidden */
  28855. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28856. private _partialLoadFile;
  28857. private _cascadeLoadFiles;
  28858. /**
  28859. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28860. * @returns true if the engine can be created
  28861. * @ignorenaming
  28862. */
  28863. static isSupported(): boolean;
  28864. }
  28865. }
  28866. declare module "babylonjs/Materials/effect" {
  28867. import { Observable } from "babylonjs/Misc/observable";
  28868. import { Nullable } from "babylonjs/types";
  28869. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28870. import { Engine } from "babylonjs/Engines/engine";
  28871. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28872. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28873. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28874. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28876. /**
  28877. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28878. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28879. */
  28880. export class EffectFallbacks {
  28881. private _defines;
  28882. private _currentRank;
  28883. private _maxRank;
  28884. private _mesh;
  28885. /**
  28886. * Removes the fallback from the bound mesh.
  28887. */
  28888. unBindMesh(): void;
  28889. /**
  28890. * Adds a fallback on the specified property.
  28891. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28892. * @param define The name of the define in the shader
  28893. */
  28894. addFallback(rank: number, define: string): void;
  28895. /**
  28896. * Sets the mesh to use CPU skinning when needing to fallback.
  28897. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28898. * @param mesh The mesh to use the fallbacks.
  28899. */
  28900. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28901. /**
  28902. * Checks to see if more fallbacks are still availible.
  28903. */
  28904. readonly isMoreFallbacks: boolean;
  28905. /**
  28906. * Removes the defines that shoould be removed when falling back.
  28907. * @param currentDefines defines the current define statements for the shader.
  28908. * @param effect defines the current effect we try to compile
  28909. * @returns The resulting defines with defines of the current rank removed.
  28910. */
  28911. reduce(currentDefines: string, effect: Effect): string;
  28912. }
  28913. /**
  28914. * Options to be used when creating an effect.
  28915. */
  28916. export class EffectCreationOptions {
  28917. /**
  28918. * Atrributes that will be used in the shader.
  28919. */
  28920. attributes: string[];
  28921. /**
  28922. * Uniform varible names that will be set in the shader.
  28923. */
  28924. uniformsNames: string[];
  28925. /**
  28926. * Uniform buffer varible names that will be set in the shader.
  28927. */
  28928. uniformBuffersNames: string[];
  28929. /**
  28930. * Sampler texture variable names that will be set in the shader.
  28931. */
  28932. samplers: string[];
  28933. /**
  28934. * Define statements that will be set in the shader.
  28935. */
  28936. defines: any;
  28937. /**
  28938. * Possible fallbacks for this effect to improve performance when needed.
  28939. */
  28940. fallbacks: Nullable<EffectFallbacks>;
  28941. /**
  28942. * Callback that will be called when the shader is compiled.
  28943. */
  28944. onCompiled: Nullable<(effect: Effect) => void>;
  28945. /**
  28946. * Callback that will be called if an error occurs during shader compilation.
  28947. */
  28948. onError: Nullable<(effect: Effect, errors: string) => void>;
  28949. /**
  28950. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28951. */
  28952. indexParameters: any;
  28953. /**
  28954. * Max number of lights that can be used in the shader.
  28955. */
  28956. maxSimultaneousLights: number;
  28957. /**
  28958. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28959. */
  28960. transformFeedbackVaryings: Nullable<string[]>;
  28961. }
  28962. /**
  28963. * Effect containing vertex and fragment shader that can be executed on an object.
  28964. */
  28965. export class Effect {
  28966. /**
  28967. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28968. */
  28969. static ShadersRepository: string;
  28970. /**
  28971. * Name of the effect.
  28972. */
  28973. name: any;
  28974. /**
  28975. * String container all the define statements that should be set on the shader.
  28976. */
  28977. defines: string;
  28978. /**
  28979. * Callback that will be called when the shader is compiled.
  28980. */
  28981. onCompiled: Nullable<(effect: Effect) => void>;
  28982. /**
  28983. * Callback that will be called if an error occurs during shader compilation.
  28984. */
  28985. onError: Nullable<(effect: Effect, errors: string) => void>;
  28986. /**
  28987. * Callback that will be called when effect is bound.
  28988. */
  28989. onBind: Nullable<(effect: Effect) => void>;
  28990. /**
  28991. * Unique ID of the effect.
  28992. */
  28993. uniqueId: number;
  28994. /**
  28995. * Observable that will be called when the shader is compiled.
  28996. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28997. */
  28998. onCompileObservable: Observable<Effect>;
  28999. /**
  29000. * Observable that will be called if an error occurs during shader compilation.
  29001. */
  29002. onErrorObservable: Observable<Effect>;
  29003. /** @hidden */
  29004. _onBindObservable: Nullable<Observable<Effect>>;
  29005. /**
  29006. * Observable that will be called when effect is bound.
  29007. */
  29008. readonly onBindObservable: Observable<Effect>;
  29009. /** @hidden */
  29010. _bonesComputationForcedToCPU: boolean;
  29011. private static _uniqueIdSeed;
  29012. private _engine;
  29013. private _uniformBuffersNames;
  29014. private _uniformsNames;
  29015. private _samplers;
  29016. private _isReady;
  29017. private _compilationError;
  29018. private _attributesNames;
  29019. private _attributes;
  29020. private _uniforms;
  29021. /**
  29022. * Key for the effect.
  29023. * @hidden
  29024. */
  29025. _key: string;
  29026. private _indexParameters;
  29027. private _fallbacks;
  29028. private _vertexSourceCode;
  29029. private _fragmentSourceCode;
  29030. private _vertexSourceCodeOverride;
  29031. private _fragmentSourceCodeOverride;
  29032. private _transformFeedbackVaryings;
  29033. /**
  29034. * Compiled shader to webGL program.
  29035. * @hidden
  29036. */
  29037. _program: WebGLProgram;
  29038. private _valueCache;
  29039. private static _baseCache;
  29040. /**
  29041. * Instantiates an effect.
  29042. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29043. * @param baseName Name of the effect.
  29044. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29045. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29046. * @param samplers List of sampler variables that will be passed to the shader.
  29047. * @param engine Engine to be used to render the effect
  29048. * @param defines Define statements to be added to the shader.
  29049. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29050. * @param onCompiled Callback that will be called when the shader is compiled.
  29051. * @param onError Callback that will be called if an error occurs during shader compilation.
  29052. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29053. */
  29054. 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);
  29055. /**
  29056. * Unique key for this effect
  29057. */
  29058. readonly key: string;
  29059. /**
  29060. * If the effect has been compiled and prepared.
  29061. * @returns if the effect is compiled and prepared.
  29062. */
  29063. isReady(): boolean;
  29064. /**
  29065. * The engine the effect was initialized with.
  29066. * @returns the engine.
  29067. */
  29068. getEngine(): Engine;
  29069. /**
  29070. * The compiled webGL program for the effect
  29071. * @returns the webGL program.
  29072. */
  29073. getProgram(): WebGLProgram;
  29074. /**
  29075. * The set of names of attribute variables for the shader.
  29076. * @returns An array of attribute names.
  29077. */
  29078. getAttributesNames(): string[];
  29079. /**
  29080. * Returns the attribute at the given index.
  29081. * @param index The index of the attribute.
  29082. * @returns The location of the attribute.
  29083. */
  29084. getAttributeLocation(index: number): number;
  29085. /**
  29086. * Returns the attribute based on the name of the variable.
  29087. * @param name of the attribute to look up.
  29088. * @returns the attribute location.
  29089. */
  29090. getAttributeLocationByName(name: string): number;
  29091. /**
  29092. * The number of attributes.
  29093. * @returns the numnber of attributes.
  29094. */
  29095. getAttributesCount(): number;
  29096. /**
  29097. * Gets the index of a uniform variable.
  29098. * @param uniformName of the uniform to look up.
  29099. * @returns the index.
  29100. */
  29101. getUniformIndex(uniformName: string): number;
  29102. /**
  29103. * Returns the attribute based on the name of the variable.
  29104. * @param uniformName of the uniform to look up.
  29105. * @returns the location of the uniform.
  29106. */
  29107. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29108. /**
  29109. * Returns an array of sampler variable names
  29110. * @returns The array of sampler variable neames.
  29111. */
  29112. getSamplers(): string[];
  29113. /**
  29114. * The error from the last compilation.
  29115. * @returns the error string.
  29116. */
  29117. getCompilationError(): string;
  29118. /**
  29119. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29120. * @param func The callback to be used.
  29121. */
  29122. executeWhenCompiled(func: (effect: Effect) => void): void;
  29123. private _checkIsReady;
  29124. /** @hidden */
  29125. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29126. /** @hidden */
  29127. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29128. /** @hidden */
  29129. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29130. private _processShaderConversion;
  29131. private _processIncludes;
  29132. private _processPrecision;
  29133. /**
  29134. * Recompiles the webGL program
  29135. * @param vertexSourceCode The source code for the vertex shader.
  29136. * @param fragmentSourceCode The source code for the fragment shader.
  29137. * @param onCompiled Callback called when completed.
  29138. * @param onError Callback called on error.
  29139. * @hidden
  29140. */
  29141. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29142. /**
  29143. * Gets the uniform locations of the the specified variable names
  29144. * @param names THe names of the variables to lookup.
  29145. * @returns Array of locations in the same order as variable names.
  29146. */
  29147. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29148. /**
  29149. * Prepares the effect
  29150. * @hidden
  29151. */
  29152. _prepareEffect(): void;
  29153. /**
  29154. * Checks if the effect is supported. (Must be called after compilation)
  29155. */
  29156. readonly isSupported: boolean;
  29157. /**
  29158. * Binds a texture to the engine to be used as output of the shader.
  29159. * @param channel Name of the output variable.
  29160. * @param texture Texture to bind.
  29161. * @hidden
  29162. */
  29163. _bindTexture(channel: string, texture: InternalTexture): void;
  29164. /**
  29165. * Sets a texture on the engine to be used in the shader.
  29166. * @param channel Name of the sampler variable.
  29167. * @param texture Texture to set.
  29168. */
  29169. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29170. /**
  29171. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29172. * @param channel Name of the sampler variable.
  29173. * @param texture Texture to set.
  29174. */
  29175. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29176. /**
  29177. * Sets an array of textures on the engine to be used in the shader.
  29178. * @param channel Name of the variable.
  29179. * @param textures Textures to set.
  29180. */
  29181. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29182. /**
  29183. * 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)
  29184. * @param channel Name of the sampler variable.
  29185. * @param postProcess Post process to get the input texture from.
  29186. */
  29187. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29188. /**
  29189. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29190. * 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)
  29191. * @param channel Name of the sampler variable.
  29192. * @param postProcess Post process to get the output texture from.
  29193. */
  29194. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29195. /** @hidden */
  29196. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29197. /** @hidden */
  29198. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29199. /** @hidden */
  29200. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29201. /** @hidden */
  29202. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29203. /**
  29204. * Binds a buffer to a uniform.
  29205. * @param buffer Buffer to bind.
  29206. * @param name Name of the uniform variable to bind to.
  29207. */
  29208. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29209. /**
  29210. * Binds block to a uniform.
  29211. * @param blockName Name of the block to bind.
  29212. * @param index Index to bind.
  29213. */
  29214. bindUniformBlock(blockName: string, index: number): void;
  29215. /**
  29216. * Sets an interger value on a uniform variable.
  29217. * @param uniformName Name of the variable.
  29218. * @param value Value to be set.
  29219. * @returns this effect.
  29220. */
  29221. setInt(uniformName: string, value: number): Effect;
  29222. /**
  29223. * Sets an int array on a uniform variable.
  29224. * @param uniformName Name of the variable.
  29225. * @param array array to be set.
  29226. * @returns this effect.
  29227. */
  29228. setIntArray(uniformName: string, array: Int32Array): Effect;
  29229. /**
  29230. * 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)
  29231. * @param uniformName Name of the variable.
  29232. * @param array array to be set.
  29233. * @returns this effect.
  29234. */
  29235. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29236. /**
  29237. * 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)
  29238. * @param uniformName Name of the variable.
  29239. * @param array array to be set.
  29240. * @returns this effect.
  29241. */
  29242. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29243. /**
  29244. * 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)
  29245. * @param uniformName Name of the variable.
  29246. * @param array array to be set.
  29247. * @returns this effect.
  29248. */
  29249. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29250. /**
  29251. * Sets an float array on a uniform variable.
  29252. * @param uniformName Name of the variable.
  29253. * @param array array to be set.
  29254. * @returns this effect.
  29255. */
  29256. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29257. /**
  29258. * 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)
  29259. * @param uniformName Name of the variable.
  29260. * @param array array to be set.
  29261. * @returns this effect.
  29262. */
  29263. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29264. /**
  29265. * 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)
  29266. * @param uniformName Name of the variable.
  29267. * @param array array to be set.
  29268. * @returns this effect.
  29269. */
  29270. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29271. /**
  29272. * 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)
  29273. * @param uniformName Name of the variable.
  29274. * @param array array to be set.
  29275. * @returns this effect.
  29276. */
  29277. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29278. /**
  29279. * Sets an array on a uniform variable.
  29280. * @param uniformName Name of the variable.
  29281. * @param array array to be set.
  29282. * @returns this effect.
  29283. */
  29284. setArray(uniformName: string, array: number[]): Effect;
  29285. /**
  29286. * 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)
  29287. * @param uniformName Name of the variable.
  29288. * @param array array to be set.
  29289. * @returns this effect.
  29290. */
  29291. setArray2(uniformName: string, array: number[]): Effect;
  29292. /**
  29293. * 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)
  29294. * @param uniformName Name of the variable.
  29295. * @param array array to be set.
  29296. * @returns this effect.
  29297. */
  29298. setArray3(uniformName: string, array: number[]): Effect;
  29299. /**
  29300. * 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)
  29301. * @param uniformName Name of the variable.
  29302. * @param array array to be set.
  29303. * @returns this effect.
  29304. */
  29305. setArray4(uniformName: string, array: number[]): Effect;
  29306. /**
  29307. * Sets matrices on a uniform variable.
  29308. * @param uniformName Name of the variable.
  29309. * @param matrices matrices to be set.
  29310. * @returns this effect.
  29311. */
  29312. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29313. /**
  29314. * Sets matrix on a uniform variable.
  29315. * @param uniformName Name of the variable.
  29316. * @param matrix matrix to be set.
  29317. * @returns this effect.
  29318. */
  29319. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29320. /**
  29321. * 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)
  29322. * @param uniformName Name of the variable.
  29323. * @param matrix matrix to be set.
  29324. * @returns this effect.
  29325. */
  29326. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29327. /**
  29328. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29329. * @param uniformName Name of the variable.
  29330. * @param matrix matrix to be set.
  29331. * @returns this effect.
  29332. */
  29333. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29334. /**
  29335. * Sets a float on a uniform variable.
  29336. * @param uniformName Name of the variable.
  29337. * @param value value to be set.
  29338. * @returns this effect.
  29339. */
  29340. setFloat(uniformName: string, value: number): Effect;
  29341. /**
  29342. * Sets a boolean on a uniform variable.
  29343. * @param uniformName Name of the variable.
  29344. * @param bool value to be set.
  29345. * @returns this effect.
  29346. */
  29347. setBool(uniformName: string, bool: boolean): Effect;
  29348. /**
  29349. * Sets a Vector2 on a uniform variable.
  29350. * @param uniformName Name of the variable.
  29351. * @param vector2 vector2 to be set.
  29352. * @returns this effect.
  29353. */
  29354. setVector2(uniformName: string, vector2: Vector2): Effect;
  29355. /**
  29356. * Sets a float2 on a uniform variable.
  29357. * @param uniformName Name of the variable.
  29358. * @param x First float in float2.
  29359. * @param y Second float in float2.
  29360. * @returns this effect.
  29361. */
  29362. setFloat2(uniformName: string, x: number, y: number): Effect;
  29363. /**
  29364. * Sets a Vector3 on a uniform variable.
  29365. * @param uniformName Name of the variable.
  29366. * @param vector3 Value to be set.
  29367. * @returns this effect.
  29368. */
  29369. setVector3(uniformName: string, vector3: Vector3): Effect;
  29370. /**
  29371. * Sets a float3 on a uniform variable.
  29372. * @param uniformName Name of the variable.
  29373. * @param x First float in float3.
  29374. * @param y Second float in float3.
  29375. * @param z Third float in float3.
  29376. * @returns this effect.
  29377. */
  29378. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29379. /**
  29380. * Sets a Vector4 on a uniform variable.
  29381. * @param uniformName Name of the variable.
  29382. * @param vector4 Value to be set.
  29383. * @returns this effect.
  29384. */
  29385. setVector4(uniformName: string, vector4: Vector4): Effect;
  29386. /**
  29387. * Sets a float4 on a uniform variable.
  29388. * @param uniformName Name of the variable.
  29389. * @param x First float in float4.
  29390. * @param y Second float in float4.
  29391. * @param z Third float in float4.
  29392. * @param w Fourth float in float4.
  29393. * @returns this effect.
  29394. */
  29395. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29396. /**
  29397. * Sets a Color3 on a uniform variable.
  29398. * @param uniformName Name of the variable.
  29399. * @param color3 Value to be set.
  29400. * @returns this effect.
  29401. */
  29402. setColor3(uniformName: string, color3: Color3): Effect;
  29403. /**
  29404. * Sets a Color4 on a uniform variable.
  29405. * @param uniformName Name of the variable.
  29406. * @param color3 Value to be set.
  29407. * @param alpha Alpha value to be set.
  29408. * @returns this effect.
  29409. */
  29410. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29411. /**
  29412. * Sets a Color4 on a uniform variable
  29413. * @param uniformName defines the name of the variable
  29414. * @param color4 defines the value to be set
  29415. * @returns this effect.
  29416. */
  29417. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29418. /**
  29419. * This function will add a new shader to the shader store
  29420. * @param name the name of the shader
  29421. * @param pixelShader optional pixel shader content
  29422. * @param vertexShader optional vertex shader content
  29423. */
  29424. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29425. /**
  29426. * Store of each shader (The can be looked up using effect.key)
  29427. */
  29428. static ShadersStore: {
  29429. [key: string]: string;
  29430. };
  29431. /**
  29432. * Store of each included file for a shader (The can be looked up using effect.key)
  29433. */
  29434. static IncludesShadersStore: {
  29435. [key: string]: string;
  29436. };
  29437. /**
  29438. * Resets the cache of effects.
  29439. */
  29440. static ResetCache(): void;
  29441. }
  29442. }
  29443. declare module "babylonjs/Materials/colorCurves" {
  29444. import { Effect } from "babylonjs/Materials/effect";
  29445. /**
  29446. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29447. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29448. * 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;
  29449. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29450. */
  29451. export class ColorCurves {
  29452. private _dirty;
  29453. private _tempColor;
  29454. private _globalCurve;
  29455. private _highlightsCurve;
  29456. private _midtonesCurve;
  29457. private _shadowsCurve;
  29458. private _positiveCurve;
  29459. private _negativeCurve;
  29460. private _globalHue;
  29461. private _globalDensity;
  29462. private _globalSaturation;
  29463. private _globalExposure;
  29464. /**
  29465. * Gets the global Hue value.
  29466. * 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).
  29467. */
  29468. /**
  29469. * Sets the global Hue value.
  29470. * 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).
  29471. */
  29472. globalHue: number;
  29473. /**
  29474. * Gets the global Density value.
  29475. * 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.
  29476. * Values less than zero provide a filter of opposite hue.
  29477. */
  29478. /**
  29479. * Sets the global Density value.
  29480. * 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.
  29481. * Values less than zero provide a filter of opposite hue.
  29482. */
  29483. globalDensity: number;
  29484. /**
  29485. * Gets the global Saturation value.
  29486. * 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.
  29487. */
  29488. /**
  29489. * Sets the global Saturation value.
  29490. * 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.
  29491. */
  29492. globalSaturation: number;
  29493. /**
  29494. * Gets the global Exposure value.
  29495. * 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.
  29496. */
  29497. /**
  29498. * Sets the global Exposure value.
  29499. * 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.
  29500. */
  29501. globalExposure: number;
  29502. private _highlightsHue;
  29503. private _highlightsDensity;
  29504. private _highlightsSaturation;
  29505. private _highlightsExposure;
  29506. /**
  29507. * Gets the highlights Hue value.
  29508. * 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).
  29509. */
  29510. /**
  29511. * Sets the highlights Hue value.
  29512. * 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).
  29513. */
  29514. highlightsHue: number;
  29515. /**
  29516. * Gets the highlights Density value.
  29517. * 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.
  29518. * Values less than zero provide a filter of opposite hue.
  29519. */
  29520. /**
  29521. * Sets the highlights Density value.
  29522. * 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.
  29523. * Values less than zero provide a filter of opposite hue.
  29524. */
  29525. highlightsDensity: number;
  29526. /**
  29527. * Gets the highlights Saturation value.
  29528. * 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.
  29529. */
  29530. /**
  29531. * Sets the highlights Saturation value.
  29532. * 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.
  29533. */
  29534. highlightsSaturation: number;
  29535. /**
  29536. * Gets the highlights Exposure value.
  29537. * 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.
  29538. */
  29539. /**
  29540. * Sets the highlights Exposure value.
  29541. * 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.
  29542. */
  29543. highlightsExposure: number;
  29544. private _midtonesHue;
  29545. private _midtonesDensity;
  29546. private _midtonesSaturation;
  29547. private _midtonesExposure;
  29548. /**
  29549. * Gets the midtones Hue value.
  29550. * 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).
  29551. */
  29552. /**
  29553. * Sets the midtones Hue value.
  29554. * 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).
  29555. */
  29556. midtonesHue: number;
  29557. /**
  29558. * Gets the midtones Density value.
  29559. * 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.
  29560. * Values less than zero provide a filter of opposite hue.
  29561. */
  29562. /**
  29563. * Sets the midtones Density value.
  29564. * 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.
  29565. * Values less than zero provide a filter of opposite hue.
  29566. */
  29567. midtonesDensity: number;
  29568. /**
  29569. * Gets the midtones Saturation value.
  29570. * 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.
  29571. */
  29572. /**
  29573. * Sets the midtones Saturation value.
  29574. * 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.
  29575. */
  29576. midtonesSaturation: number;
  29577. /**
  29578. * Gets the midtones Exposure value.
  29579. * 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.
  29580. */
  29581. /**
  29582. * Sets the midtones Exposure value.
  29583. * 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.
  29584. */
  29585. midtonesExposure: number;
  29586. private _shadowsHue;
  29587. private _shadowsDensity;
  29588. private _shadowsSaturation;
  29589. private _shadowsExposure;
  29590. /**
  29591. * Gets the shadows Hue value.
  29592. * 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).
  29593. */
  29594. /**
  29595. * Sets the shadows Hue value.
  29596. * 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).
  29597. */
  29598. shadowsHue: number;
  29599. /**
  29600. * Gets the shadows Density value.
  29601. * 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.
  29602. * Values less than zero provide a filter of opposite hue.
  29603. */
  29604. /**
  29605. * Sets the shadows Density value.
  29606. * 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.
  29607. * Values less than zero provide a filter of opposite hue.
  29608. */
  29609. shadowsDensity: number;
  29610. /**
  29611. * Gets the shadows Saturation value.
  29612. * 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.
  29613. */
  29614. /**
  29615. * Sets the shadows Saturation value.
  29616. * 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.
  29617. */
  29618. shadowsSaturation: number;
  29619. /**
  29620. * Gets the shadows Exposure value.
  29621. * 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.
  29622. */
  29623. /**
  29624. * Sets the shadows Exposure value.
  29625. * 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.
  29626. */
  29627. shadowsExposure: number;
  29628. /**
  29629. * Returns the class name
  29630. * @returns The class name
  29631. */
  29632. getClassName(): string;
  29633. /**
  29634. * Binds the color curves to the shader.
  29635. * @param colorCurves The color curve to bind
  29636. * @param effect The effect to bind to
  29637. * @param positiveUniform The positive uniform shader parameter
  29638. * @param neutralUniform The neutral uniform shader parameter
  29639. * @param negativeUniform The negative uniform shader parameter
  29640. */
  29641. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29642. /**
  29643. * Prepare the list of uniforms associated with the ColorCurves effects.
  29644. * @param uniformsList The list of uniforms used in the effect
  29645. */
  29646. static PrepareUniforms(uniformsList: string[]): void;
  29647. /**
  29648. * Returns color grading data based on a hue, density, saturation and exposure value.
  29649. * @param filterHue The hue of the color filter.
  29650. * @param filterDensity The density of the color filter.
  29651. * @param saturation The saturation.
  29652. * @param exposure The exposure.
  29653. * @param result The result data container.
  29654. */
  29655. private getColorGradingDataToRef;
  29656. /**
  29657. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29658. * @param value The input slider value in range [-100,100].
  29659. * @returns Adjusted value.
  29660. */
  29661. private static applyColorGradingSliderNonlinear;
  29662. /**
  29663. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29664. * @param hue The hue (H) input.
  29665. * @param saturation The saturation (S) input.
  29666. * @param brightness The brightness (B) input.
  29667. * @result An RGBA color represented as Vector4.
  29668. */
  29669. private static fromHSBToRef;
  29670. /**
  29671. * Returns a value clamped between min and max
  29672. * @param value The value to clamp
  29673. * @param min The minimum of value
  29674. * @param max The maximum of value
  29675. * @returns The clamped value.
  29676. */
  29677. private static clamp;
  29678. /**
  29679. * Clones the current color curve instance.
  29680. * @return The cloned curves
  29681. */
  29682. clone(): ColorCurves;
  29683. /**
  29684. * Serializes the current color curve instance to a json representation.
  29685. * @return a JSON representation
  29686. */
  29687. serialize(): any;
  29688. /**
  29689. * Parses the color curve from a json representation.
  29690. * @param source the JSON source to parse
  29691. * @return The parsed curves
  29692. */
  29693. static Parse(source: any): ColorCurves;
  29694. }
  29695. }
  29696. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29697. import { Observable } from "babylonjs/Misc/observable";
  29698. import { Nullable } from "babylonjs/types";
  29699. import { Color4 } from "babylonjs/Maths/math";
  29700. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29701. import { Effect } from "babylonjs/Materials/effect";
  29702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29703. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29704. /**
  29705. * Interface to follow in your material defines to integrate easily the
  29706. * Image proccessing functions.
  29707. * @hidden
  29708. */
  29709. export interface IImageProcessingConfigurationDefines {
  29710. IMAGEPROCESSING: boolean;
  29711. VIGNETTE: boolean;
  29712. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29713. VIGNETTEBLENDMODEOPAQUE: boolean;
  29714. TONEMAPPING: boolean;
  29715. TONEMAPPING_ACES: boolean;
  29716. CONTRAST: boolean;
  29717. EXPOSURE: boolean;
  29718. COLORCURVES: boolean;
  29719. COLORGRADING: boolean;
  29720. COLORGRADING3D: boolean;
  29721. SAMPLER3DGREENDEPTH: boolean;
  29722. SAMPLER3DBGRMAP: boolean;
  29723. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29724. }
  29725. /**
  29726. * @hidden
  29727. */
  29728. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29729. IMAGEPROCESSING: boolean;
  29730. VIGNETTE: boolean;
  29731. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29732. VIGNETTEBLENDMODEOPAQUE: boolean;
  29733. TONEMAPPING: boolean;
  29734. TONEMAPPING_ACES: boolean;
  29735. CONTRAST: boolean;
  29736. COLORCURVES: boolean;
  29737. COLORGRADING: boolean;
  29738. COLORGRADING3D: boolean;
  29739. SAMPLER3DGREENDEPTH: boolean;
  29740. SAMPLER3DBGRMAP: boolean;
  29741. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29742. EXPOSURE: boolean;
  29743. constructor();
  29744. }
  29745. /**
  29746. * This groups together the common properties used for image processing either in direct forward pass
  29747. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29748. * or not.
  29749. */
  29750. export class ImageProcessingConfiguration {
  29751. /**
  29752. * Default tone mapping applied in BabylonJS.
  29753. */
  29754. static readonly TONEMAPPING_STANDARD: number;
  29755. /**
  29756. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29757. * to other engines rendering to increase portability.
  29758. */
  29759. static readonly TONEMAPPING_ACES: number;
  29760. /**
  29761. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29762. */
  29763. colorCurves: Nullable<ColorCurves>;
  29764. private _colorCurvesEnabled;
  29765. /**
  29766. * Gets wether the color curves effect is enabled.
  29767. */
  29768. /**
  29769. * Sets wether the color curves effect is enabled.
  29770. */
  29771. colorCurvesEnabled: boolean;
  29772. private _colorGradingTexture;
  29773. /**
  29774. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29775. */
  29776. /**
  29777. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29778. */
  29779. colorGradingTexture: Nullable<BaseTexture>;
  29780. private _colorGradingEnabled;
  29781. /**
  29782. * Gets wether the color grading effect is enabled.
  29783. */
  29784. /**
  29785. * Sets wether the color grading effect is enabled.
  29786. */
  29787. colorGradingEnabled: boolean;
  29788. private _colorGradingWithGreenDepth;
  29789. /**
  29790. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29791. */
  29792. /**
  29793. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29794. */
  29795. colorGradingWithGreenDepth: boolean;
  29796. private _colorGradingBGR;
  29797. /**
  29798. * Gets wether the color grading texture contains BGR values.
  29799. */
  29800. /**
  29801. * Sets wether the color grading texture contains BGR values.
  29802. */
  29803. colorGradingBGR: boolean;
  29804. /** @hidden */
  29805. _exposure: number;
  29806. /**
  29807. * Gets the Exposure used in the effect.
  29808. */
  29809. /**
  29810. * Sets the Exposure used in the effect.
  29811. */
  29812. exposure: number;
  29813. private _toneMappingEnabled;
  29814. /**
  29815. * Gets wether the tone mapping effect is enabled.
  29816. */
  29817. /**
  29818. * Sets wether the tone mapping effect is enabled.
  29819. */
  29820. toneMappingEnabled: boolean;
  29821. private _toneMappingType;
  29822. /**
  29823. * Gets the type of tone mapping effect.
  29824. */
  29825. /**
  29826. * Sets the type of tone mapping effect used in BabylonJS.
  29827. */
  29828. toneMappingType: number;
  29829. protected _contrast: number;
  29830. /**
  29831. * Gets the contrast used in the effect.
  29832. */
  29833. /**
  29834. * Sets the contrast used in the effect.
  29835. */
  29836. contrast: number;
  29837. /**
  29838. * Vignette stretch size.
  29839. */
  29840. vignetteStretch: number;
  29841. /**
  29842. * Vignette centre X Offset.
  29843. */
  29844. vignetteCentreX: number;
  29845. /**
  29846. * Vignette centre Y Offset.
  29847. */
  29848. vignetteCentreY: number;
  29849. /**
  29850. * Vignette weight or intensity of the vignette effect.
  29851. */
  29852. vignetteWeight: number;
  29853. /**
  29854. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29855. * if vignetteEnabled is set to true.
  29856. */
  29857. vignetteColor: Color4;
  29858. /**
  29859. * Camera field of view used by the Vignette effect.
  29860. */
  29861. vignetteCameraFov: number;
  29862. private _vignetteBlendMode;
  29863. /**
  29864. * Gets the vignette blend mode allowing different kind of effect.
  29865. */
  29866. /**
  29867. * Sets the vignette blend mode allowing different kind of effect.
  29868. */
  29869. vignetteBlendMode: number;
  29870. private _vignetteEnabled;
  29871. /**
  29872. * Gets wether the vignette effect is enabled.
  29873. */
  29874. /**
  29875. * Sets wether the vignette effect is enabled.
  29876. */
  29877. vignetteEnabled: boolean;
  29878. private _applyByPostProcess;
  29879. /**
  29880. * Gets wether the image processing is applied through a post process or not.
  29881. */
  29882. /**
  29883. * Sets wether the image processing is applied through a post process or not.
  29884. */
  29885. applyByPostProcess: boolean;
  29886. private _isEnabled;
  29887. /**
  29888. * Gets wether the image processing is enabled or not.
  29889. */
  29890. /**
  29891. * Sets wether the image processing is enabled or not.
  29892. */
  29893. isEnabled: boolean;
  29894. /**
  29895. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29896. */
  29897. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29898. /**
  29899. * Method called each time the image processing information changes requires to recompile the effect.
  29900. */
  29901. protected _updateParameters(): void;
  29902. /**
  29903. * Gets the current class name.
  29904. * @return "ImageProcessingConfiguration"
  29905. */
  29906. getClassName(): string;
  29907. /**
  29908. * Prepare the list of uniforms associated with the Image Processing effects.
  29909. * @param uniforms The list of uniforms used in the effect
  29910. * @param defines the list of defines currently in use
  29911. */
  29912. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29913. /**
  29914. * Prepare the list of samplers associated with the Image Processing effects.
  29915. * @param samplersList The list of uniforms used in the effect
  29916. * @param defines the list of defines currently in use
  29917. */
  29918. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29919. /**
  29920. * Prepare the list of defines associated to the shader.
  29921. * @param defines the list of defines to complete
  29922. * @param forPostProcess Define if we are currently in post process mode or not
  29923. */
  29924. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29925. /**
  29926. * Returns true if all the image processing information are ready.
  29927. * @returns True if ready, otherwise, false
  29928. */
  29929. isReady(): boolean;
  29930. /**
  29931. * Binds the image processing to the shader.
  29932. * @param effect The effect to bind to
  29933. * @param aspectRatio Define the current aspect ratio of the effect
  29934. */
  29935. bind(effect: Effect, aspectRatio?: number): void;
  29936. /**
  29937. * Clones the current image processing instance.
  29938. * @return The cloned image processing
  29939. */
  29940. clone(): ImageProcessingConfiguration;
  29941. /**
  29942. * Serializes the current image processing instance to a json representation.
  29943. * @return a JSON representation
  29944. */
  29945. serialize(): any;
  29946. /**
  29947. * Parses the image processing from a json representation.
  29948. * @param source the JSON source to parse
  29949. * @return The parsed image processing
  29950. */
  29951. static Parse(source: any): ImageProcessingConfiguration;
  29952. private static _VIGNETTEMODE_MULTIPLY;
  29953. private static _VIGNETTEMODE_OPAQUE;
  29954. /**
  29955. * Used to apply the vignette as a mix with the pixel color.
  29956. */
  29957. static readonly VIGNETTEMODE_MULTIPLY: number;
  29958. /**
  29959. * Used to apply the vignette as a replacement of the pixel color.
  29960. */
  29961. static readonly VIGNETTEMODE_OPAQUE: number;
  29962. }
  29963. }
  29964. declare module "babylonjs/Materials/fresnelParameters" {
  29965. import { Color3 } from "babylonjs/Maths/math";
  29966. /**
  29967. * This represents all the required information to add a fresnel effect on a material:
  29968. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29969. */
  29970. export class FresnelParameters {
  29971. private _isEnabled;
  29972. /**
  29973. * Define if the fresnel effect is enable or not.
  29974. */
  29975. isEnabled: boolean;
  29976. /**
  29977. * Define the color used on edges (grazing angle)
  29978. */
  29979. leftColor: Color3;
  29980. /**
  29981. * Define the color used on center
  29982. */
  29983. rightColor: Color3;
  29984. /**
  29985. * Define bias applied to computed fresnel term
  29986. */
  29987. bias: number;
  29988. /**
  29989. * Defined the power exponent applied to fresnel term
  29990. */
  29991. power: number;
  29992. /**
  29993. * Clones the current fresnel and its valuues
  29994. * @returns a clone fresnel configuration
  29995. */
  29996. clone(): FresnelParameters;
  29997. /**
  29998. * Serializes the current fresnel parameters to a JSON representation.
  29999. * @return the JSON serialization
  30000. */
  30001. serialize(): any;
  30002. /**
  30003. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30004. * @param parsedFresnelParameters Define the JSON representation
  30005. * @returns the parsed parameters
  30006. */
  30007. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30008. }
  30009. }
  30010. declare module "babylonjs/Misc/decorators" {
  30011. import { Nullable } from "babylonjs/types";
  30012. import { Scene } from "babylonjs/scene";
  30013. import { IAnimatable } from "babylonjs/Misc/tools";
  30014. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30015. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30016. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30017. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30018. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30019. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30020. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30021. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30022. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30023. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30024. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30025. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30026. /**
  30027. * Decorator used to define property that can be serialized as reference to a camera
  30028. * @param sourceName defines the name of the property to decorate
  30029. */
  30030. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30031. /**
  30032. * Class used to help serialization objects
  30033. */
  30034. export class SerializationHelper {
  30035. /** hidden */
  30036. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30037. /** hidden */
  30038. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30039. /** hidden */
  30040. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30041. /** hidden */
  30042. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30043. /**
  30044. * Appends the serialized animations from the source animations
  30045. * @param source Source containing the animations
  30046. * @param destination Target to store the animations
  30047. */
  30048. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30049. /**
  30050. * Static function used to serialized a specific entity
  30051. * @param entity defines the entity to serialize
  30052. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30053. * @returns a JSON compatible object representing the serialization of the entity
  30054. */
  30055. static Serialize<T>(entity: T, serializationObject?: any): any;
  30056. /**
  30057. * Creates a new entity from a serialization data object
  30058. * @param creationFunction defines a function used to instanciated the new entity
  30059. * @param source defines the source serialization data
  30060. * @param scene defines the hosting scene
  30061. * @param rootUrl defines the root url for resources
  30062. * @returns a new entity
  30063. */
  30064. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30065. /**
  30066. * Clones an object
  30067. * @param creationFunction defines the function used to instanciate the new object
  30068. * @param source defines the source object
  30069. * @returns the cloned object
  30070. */
  30071. static Clone<T>(creationFunction: () => T, source: T): T;
  30072. /**
  30073. * Instanciates a new object based on a source one (some data will be shared between both object)
  30074. * @param creationFunction defines the function used to instanciate the new object
  30075. * @param source defines the source object
  30076. * @returns the new object
  30077. */
  30078. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30079. }
  30080. }
  30081. declare module "babylonjs/Cameras/camera" {
  30082. import { SmartArray } from "babylonjs/Misc/smartArray";
  30083. import { Observable } from "babylonjs/Misc/observable";
  30084. import { Nullable } from "babylonjs/types";
  30085. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30086. import { Scene } from "babylonjs/scene";
  30087. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30088. import { Node } from "babylonjs/node";
  30089. import { Mesh } from "babylonjs/Meshes/mesh";
  30090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30091. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30092. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30093. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30094. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30095. import { Ray } from "babylonjs/Culling/ray";
  30096. /**
  30097. * This is the base class of all the camera used in the application.
  30098. * @see http://doc.babylonjs.com/features/cameras
  30099. */
  30100. export class Camera extends Node {
  30101. /** @hidden */
  30102. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30103. /**
  30104. * This is the default projection mode used by the cameras.
  30105. * It helps recreating a feeling of perspective and better appreciate depth.
  30106. * This is the best way to simulate real life cameras.
  30107. */
  30108. static readonly PERSPECTIVE_CAMERA: number;
  30109. /**
  30110. * This helps creating camera with an orthographic mode.
  30111. * 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.
  30112. */
  30113. static readonly ORTHOGRAPHIC_CAMERA: number;
  30114. /**
  30115. * This is the default FOV mode for perspective cameras.
  30116. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30117. */
  30118. static readonly FOVMODE_VERTICAL_FIXED: number;
  30119. /**
  30120. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30121. */
  30122. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30123. /**
  30124. * This specifies ther is no need for a camera rig.
  30125. * Basically only one eye is rendered corresponding to the camera.
  30126. */
  30127. static readonly RIG_MODE_NONE: number;
  30128. /**
  30129. * Simulates a camera Rig with one blue eye and one red eye.
  30130. * This can be use with 3d blue and red glasses.
  30131. */
  30132. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30133. /**
  30134. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30135. */
  30136. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30137. /**
  30138. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30139. */
  30140. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30141. /**
  30142. * Defines that both eyes of the camera will be rendered over under each other.
  30143. */
  30144. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30145. /**
  30146. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30147. */
  30148. static readonly RIG_MODE_VR: number;
  30149. /**
  30150. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30151. */
  30152. static readonly RIG_MODE_WEBVR: number;
  30153. /**
  30154. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30155. */
  30156. static readonly RIG_MODE_CUSTOM: number;
  30157. /**
  30158. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30159. */
  30160. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30161. /**
  30162. * @hidden
  30163. * Might be removed once multiview will be a thing
  30164. */
  30165. static UseAlternateWebVRRendering: boolean;
  30166. /**
  30167. * Define the input manager associated with the camera.
  30168. */
  30169. inputs: CameraInputsManager<Camera>;
  30170. /** @hidden */
  30171. _position: Vector3;
  30172. /**
  30173. * Define the current local position of the camera in the scene
  30174. */
  30175. position: Vector3;
  30176. /**
  30177. * The vector the camera should consider as up.
  30178. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30179. */
  30180. upVector: Vector3;
  30181. /**
  30182. * Define the current limit on the left side for an orthographic camera
  30183. * In scene unit
  30184. */
  30185. orthoLeft: Nullable<number>;
  30186. /**
  30187. * Define the current limit on the right side for an orthographic camera
  30188. * In scene unit
  30189. */
  30190. orthoRight: Nullable<number>;
  30191. /**
  30192. * Define the current limit on the bottom side for an orthographic camera
  30193. * In scene unit
  30194. */
  30195. orthoBottom: Nullable<number>;
  30196. /**
  30197. * Define the current limit on the top side for an orthographic camera
  30198. * In scene unit
  30199. */
  30200. orthoTop: Nullable<number>;
  30201. /**
  30202. * Field Of View is set in Radians. (default is 0.8)
  30203. */
  30204. fov: number;
  30205. /**
  30206. * Define the minimum distance the camera can see from.
  30207. * This is important to note that the depth buffer are not infinite and the closer it starts
  30208. * the more your scene might encounter depth fighting issue.
  30209. */
  30210. minZ: number;
  30211. /**
  30212. * Define the maximum distance the camera can see to.
  30213. * This is important to note that the depth buffer are not infinite and the further it end
  30214. * the more your scene might encounter depth fighting issue.
  30215. */
  30216. maxZ: number;
  30217. /**
  30218. * Define the default inertia of the camera.
  30219. * This helps giving a smooth feeling to the camera movement.
  30220. */
  30221. inertia: number;
  30222. /**
  30223. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30224. */
  30225. mode: number;
  30226. /**
  30227. * Define wether the camera is intermediate.
  30228. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30229. */
  30230. isIntermediate: boolean;
  30231. /**
  30232. * Define the viewport of the camera.
  30233. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30234. */
  30235. viewport: Viewport;
  30236. /**
  30237. * Restricts the camera to viewing objects with the same layerMask.
  30238. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30239. */
  30240. layerMask: number;
  30241. /**
  30242. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30243. */
  30244. fovMode: number;
  30245. /**
  30246. * Rig mode of the camera.
  30247. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30248. * This is normally controlled byt the camera themselves as internal use.
  30249. */
  30250. cameraRigMode: number;
  30251. /**
  30252. * Defines the distance between both "eyes" in case of a RIG
  30253. */
  30254. interaxialDistance: number;
  30255. /**
  30256. * Defines if stereoscopic rendering is done side by side or over under.
  30257. */
  30258. isStereoscopicSideBySide: boolean;
  30259. /**
  30260. * 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
  30261. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30262. * else in the scene.
  30263. */
  30264. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30265. /**
  30266. * When set, the camera will render to this render target instead of the default canvas
  30267. */
  30268. outputRenderTarget: Nullable<RenderTargetTexture>;
  30269. /**
  30270. * Observable triggered when the camera view matrix has changed.
  30271. */
  30272. onViewMatrixChangedObservable: Observable<Camera>;
  30273. /**
  30274. * Observable triggered when the camera Projection matrix has changed.
  30275. */
  30276. onProjectionMatrixChangedObservable: Observable<Camera>;
  30277. /**
  30278. * Observable triggered when the inputs have been processed.
  30279. */
  30280. onAfterCheckInputsObservable: Observable<Camera>;
  30281. /**
  30282. * Observable triggered when reset has been called and applied to the camera.
  30283. */
  30284. onRestoreStateObservable: Observable<Camera>;
  30285. /** @hidden */
  30286. _cameraRigParams: any;
  30287. /** @hidden */
  30288. _rigCameras: Camera[];
  30289. /** @hidden */
  30290. _rigPostProcess: Nullable<PostProcess>;
  30291. protected _webvrViewMatrix: Matrix;
  30292. /** @hidden */
  30293. _skipRendering: boolean;
  30294. /** @hidden */
  30295. _alternateCamera: Camera;
  30296. /** @hidden */
  30297. _projectionMatrix: Matrix;
  30298. /** @hidden */
  30299. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30300. /** @hidden */
  30301. _activeMeshes: SmartArray<AbstractMesh>;
  30302. protected _globalPosition: Vector3;
  30303. /** hidden */
  30304. _computedViewMatrix: Matrix;
  30305. private _doNotComputeProjectionMatrix;
  30306. private _transformMatrix;
  30307. private _frustumPlanes;
  30308. private _refreshFrustumPlanes;
  30309. private _storedFov;
  30310. private _stateStored;
  30311. /**
  30312. * Instantiates a new camera object.
  30313. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30314. * @see http://doc.babylonjs.com/features/cameras
  30315. * @param name Defines the name of the camera in the scene
  30316. * @param position Defines the position of the camera
  30317. * @param scene Defines the scene the camera belongs too
  30318. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30319. */
  30320. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30321. /**
  30322. * Store current camera state (fov, position, etc..)
  30323. * @returns the camera
  30324. */
  30325. storeState(): Camera;
  30326. /**
  30327. * Restores the camera state values if it has been stored. You must call storeState() first
  30328. */
  30329. protected _restoreStateValues(): boolean;
  30330. /**
  30331. * Restored camera state. You must call storeState() first.
  30332. * @returns true if restored and false otherwise
  30333. */
  30334. restoreState(): boolean;
  30335. /**
  30336. * Gets the class name of the camera.
  30337. * @returns the class name
  30338. */
  30339. getClassName(): string;
  30340. /** @hidden */
  30341. readonly _isCamera: boolean;
  30342. /**
  30343. * Gets a string representation of the camera useful for debug purpose.
  30344. * @param fullDetails Defines that a more verboe level of logging is required
  30345. * @returns the string representation
  30346. */
  30347. toString(fullDetails?: boolean): string;
  30348. /**
  30349. * Gets the current world space position of the camera.
  30350. */
  30351. readonly globalPosition: Vector3;
  30352. /**
  30353. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30354. * @returns the active meshe list
  30355. */
  30356. getActiveMeshes(): SmartArray<AbstractMesh>;
  30357. /**
  30358. * Check wether a mesh is part of the current active mesh list of the camera
  30359. * @param mesh Defines the mesh to check
  30360. * @returns true if active, false otherwise
  30361. */
  30362. isActiveMesh(mesh: Mesh): boolean;
  30363. /**
  30364. * Is this camera ready to be used/rendered
  30365. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30366. * @return true if the camera is ready
  30367. */
  30368. isReady(completeCheck?: boolean): boolean;
  30369. /** @hidden */
  30370. _initCache(): void;
  30371. /** @hidden */
  30372. _updateCache(ignoreParentClass?: boolean): void;
  30373. /** @hidden */
  30374. _isSynchronized(): boolean;
  30375. /** @hidden */
  30376. _isSynchronizedViewMatrix(): boolean;
  30377. /** @hidden */
  30378. _isSynchronizedProjectionMatrix(): boolean;
  30379. /**
  30380. * Attach the input controls to a specific dom element to get the input from.
  30381. * @param element Defines the element the controls should be listened from
  30382. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30383. */
  30384. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30385. /**
  30386. * Detach the current controls from the specified dom element.
  30387. * @param element Defines the element to stop listening the inputs from
  30388. */
  30389. detachControl(element: HTMLElement): void;
  30390. /**
  30391. * Update the camera state according to the different inputs gathered during the frame.
  30392. */
  30393. update(): void;
  30394. /** @hidden */
  30395. _checkInputs(): void;
  30396. /** @hidden */
  30397. readonly rigCameras: Camera[];
  30398. /**
  30399. * Gets the post process used by the rig cameras
  30400. */
  30401. readonly rigPostProcess: Nullable<PostProcess>;
  30402. /**
  30403. * Internal, gets the first post proces.
  30404. * @returns the first post process to be run on this camera.
  30405. */
  30406. _getFirstPostProcess(): Nullable<PostProcess>;
  30407. private _cascadePostProcessesToRigCams;
  30408. /**
  30409. * Attach a post process to the camera.
  30410. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30411. * @param postProcess The post process to attach to the camera
  30412. * @param insertAt The position of the post process in case several of them are in use in the scene
  30413. * @returns the position the post process has been inserted at
  30414. */
  30415. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30416. /**
  30417. * Detach a post process to the camera.
  30418. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30419. * @param postProcess The post process to detach from the camera
  30420. */
  30421. detachPostProcess(postProcess: PostProcess): void;
  30422. /**
  30423. * Gets the current world matrix of the camera
  30424. */
  30425. getWorldMatrix(): Matrix;
  30426. /** @hidden */
  30427. _getViewMatrix(): Matrix;
  30428. /**
  30429. * Gets the current view matrix of the camera.
  30430. * @param force forces the camera to recompute the matrix without looking at the cached state
  30431. * @returns the view matrix
  30432. */
  30433. getViewMatrix(force?: boolean): Matrix;
  30434. /**
  30435. * Freeze the projection matrix.
  30436. * It will prevent the cache check of the camera projection compute and can speed up perf
  30437. * if no parameter of the camera are meant to change
  30438. * @param projection Defines manually a projection if necessary
  30439. */
  30440. freezeProjectionMatrix(projection?: Matrix): void;
  30441. /**
  30442. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30443. */
  30444. unfreezeProjectionMatrix(): void;
  30445. /**
  30446. * Gets the current projection matrix of the camera.
  30447. * @param force forces the camera to recompute the matrix without looking at the cached state
  30448. * @returns the projection matrix
  30449. */
  30450. getProjectionMatrix(force?: boolean): Matrix;
  30451. /**
  30452. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30453. * @returns a Matrix
  30454. */
  30455. getTransformationMatrix(): Matrix;
  30456. private _updateFrustumPlanes;
  30457. /**
  30458. * Checks if a cullable object (mesh...) is in the camera frustum
  30459. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30460. * @param target The object to check
  30461. * @returns true if the object is in frustum otherwise false
  30462. */
  30463. isInFrustum(target: ICullable): boolean;
  30464. /**
  30465. * Checks if a cullable object (mesh...) is in the camera frustum
  30466. * Unlike isInFrustum this cheks the full bounding box
  30467. * @param target The object to check
  30468. * @returns true if the object is in frustum otherwise false
  30469. */
  30470. isCompletelyInFrustum(target: ICullable): boolean;
  30471. /**
  30472. * Gets a ray in the forward direction from the camera.
  30473. * @param length Defines the length of the ray to create
  30474. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30475. * @param origin Defines the start point of the ray which defaults to the camera position
  30476. * @returns the forward ray
  30477. */
  30478. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30479. /**
  30480. * Releases resources associated with this node.
  30481. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30482. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30483. */
  30484. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30485. /** @hidden */
  30486. _isLeftCamera: boolean;
  30487. /**
  30488. * Gets the left camera of a rig setup in case of Rigged Camera
  30489. */
  30490. readonly isLeftCamera: boolean;
  30491. /** @hidden */
  30492. _isRightCamera: boolean;
  30493. /**
  30494. * Gets the right camera of a rig setup in case of Rigged Camera
  30495. */
  30496. readonly isRightCamera: boolean;
  30497. /**
  30498. * Gets the left camera of a rig setup in case of Rigged Camera
  30499. */
  30500. readonly leftCamera: Nullable<FreeCamera>;
  30501. /**
  30502. * Gets the right camera of a rig setup in case of Rigged Camera
  30503. */
  30504. readonly rightCamera: Nullable<FreeCamera>;
  30505. /**
  30506. * Gets the left camera target of a rig setup in case of Rigged Camera
  30507. * @returns the target position
  30508. */
  30509. getLeftTarget(): Nullable<Vector3>;
  30510. /**
  30511. * Gets the right camera target of a rig setup in case of Rigged Camera
  30512. * @returns the target position
  30513. */
  30514. getRightTarget(): Nullable<Vector3>;
  30515. /**
  30516. * @hidden
  30517. */
  30518. setCameraRigMode(mode: number, rigParams: any): void;
  30519. /** @hidden */
  30520. static _setStereoscopicRigMode(camera: Camera): void;
  30521. /** @hidden */
  30522. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30523. /** @hidden */
  30524. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30525. /** @hidden */
  30526. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30527. /** @hidden */
  30528. _getVRProjectionMatrix(): Matrix;
  30529. protected _updateCameraRotationMatrix(): void;
  30530. protected _updateWebVRCameraRotationMatrix(): void;
  30531. /**
  30532. * This function MUST be overwritten by the different WebVR cameras available.
  30533. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30534. * @hidden
  30535. */
  30536. _getWebVRProjectionMatrix(): Matrix;
  30537. /**
  30538. * This function MUST be overwritten by the different WebVR cameras available.
  30539. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30540. * @hidden
  30541. */
  30542. _getWebVRViewMatrix(): Matrix;
  30543. /** @hidden */
  30544. setCameraRigParameter(name: string, value: any): void;
  30545. /**
  30546. * needs to be overridden by children so sub has required properties to be copied
  30547. * @hidden
  30548. */
  30549. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30550. /**
  30551. * May need to be overridden by children
  30552. * @hidden
  30553. */
  30554. _updateRigCameras(): void;
  30555. /** @hidden */
  30556. _setupInputs(): void;
  30557. /**
  30558. * Serialiaze the camera setup to a json represention
  30559. * @returns the JSON representation
  30560. */
  30561. serialize(): any;
  30562. /**
  30563. * Clones the current camera.
  30564. * @param name The cloned camera name
  30565. * @returns the cloned camera
  30566. */
  30567. clone(name: string): Camera;
  30568. /**
  30569. * Gets the direction of the camera relative to a given local axis.
  30570. * @param localAxis Defines the reference axis to provide a relative direction.
  30571. * @return the direction
  30572. */
  30573. getDirection(localAxis: Vector3): Vector3;
  30574. /**
  30575. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30576. * @param localAxis Defines the reference axis to provide a relative direction.
  30577. * @param result Defines the vector to store the result in
  30578. */
  30579. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30580. /**
  30581. * Gets a camera constructor for a given camera type
  30582. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30583. * @param name The name of the camera the result will be able to instantiate
  30584. * @param scene The scene the result will construct the camera in
  30585. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30586. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30587. * @returns a factory method to construc the camera
  30588. */
  30589. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30590. /**
  30591. * Compute the world matrix of the camera.
  30592. * @returns the camera workd matrix
  30593. */
  30594. computeWorldMatrix(): Matrix;
  30595. /**
  30596. * Parse a JSON and creates the camera from the parsed information
  30597. * @param parsedCamera The JSON to parse
  30598. * @param scene The scene to instantiate the camera in
  30599. * @returns the newly constructed camera
  30600. */
  30601. static Parse(parsedCamera: any, scene: Scene): Camera;
  30602. }
  30603. }
  30604. declare module "babylonjs/Misc/tools" {
  30605. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30606. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30607. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30608. import { Observable } from "babylonjs/Misc/observable";
  30609. import { DomManagement } from "babylonjs/Misc/domManagement";
  30610. import { Camera } from "babylonjs/Cameras/camera";
  30611. import { Engine } from "babylonjs/Engines/engine";
  30612. import { Animation } from "babylonjs/Animations/animation";
  30613. /**
  30614. * Interface for any object that can request an animation frame
  30615. */
  30616. export interface ICustomAnimationFrameRequester {
  30617. /**
  30618. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30619. */
  30620. renderFunction?: Function;
  30621. /**
  30622. * Called to request the next frame to render to
  30623. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30624. */
  30625. requestAnimationFrame: Function;
  30626. /**
  30627. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30628. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30629. */
  30630. requestID?: number;
  30631. }
  30632. /**
  30633. * Interface containing an array of animations
  30634. */
  30635. export interface IAnimatable {
  30636. /**
  30637. * Array of animations
  30638. */
  30639. animations: Array<Animation>;
  30640. }
  30641. /** Interface used by value gradients (color, factor, ...) */
  30642. export interface IValueGradient {
  30643. /**
  30644. * Gets or sets the gradient value (between 0 and 1)
  30645. */
  30646. gradient: number;
  30647. }
  30648. /** Class used to store color4 gradient */
  30649. export class ColorGradient implements IValueGradient {
  30650. /**
  30651. * Gets or sets the gradient value (between 0 and 1)
  30652. */
  30653. gradient: number;
  30654. /**
  30655. * Gets or sets first associated color
  30656. */
  30657. color1: Color4;
  30658. /**
  30659. * Gets or sets second associated color
  30660. */
  30661. color2?: Color4;
  30662. /**
  30663. * Will get a color picked randomly between color1 and color2.
  30664. * If color2 is undefined then color1 will be used
  30665. * @param result defines the target Color4 to store the result in
  30666. */
  30667. getColorToRef(result: Color4): void;
  30668. }
  30669. /** Class used to store color 3 gradient */
  30670. export class Color3Gradient implements IValueGradient {
  30671. /**
  30672. * Gets or sets the gradient value (between 0 and 1)
  30673. */
  30674. gradient: number;
  30675. /**
  30676. * Gets or sets the associated color
  30677. */
  30678. color: Color3;
  30679. }
  30680. /** Class used to store factor gradient */
  30681. export class FactorGradient implements IValueGradient {
  30682. /**
  30683. * Gets or sets the gradient value (between 0 and 1)
  30684. */
  30685. gradient: number;
  30686. /**
  30687. * Gets or sets first associated factor
  30688. */
  30689. factor1: number;
  30690. /**
  30691. * Gets or sets second associated factor
  30692. */
  30693. factor2?: number;
  30694. /**
  30695. * Will get a number picked randomly between factor1 and factor2.
  30696. * If factor2 is undefined then factor1 will be used
  30697. * @returns the picked number
  30698. */
  30699. getFactor(): number;
  30700. }
  30701. /**
  30702. * @ignore
  30703. * Application error to support additional information when loading a file
  30704. */
  30705. export class LoadFileError extends Error {
  30706. /** defines the optional XHR request */
  30707. request?: XMLHttpRequest | undefined;
  30708. private static _setPrototypeOf;
  30709. /**
  30710. * Creates a new LoadFileError
  30711. * @param message defines the message of the error
  30712. * @param request defines the optional XHR request
  30713. */
  30714. constructor(message: string,
  30715. /** defines the optional XHR request */
  30716. request?: XMLHttpRequest | undefined);
  30717. }
  30718. /**
  30719. * Class used to define a retry strategy when error happens while loading assets
  30720. */
  30721. export class RetryStrategy {
  30722. /**
  30723. * Function used to defines an exponential back off strategy
  30724. * @param maxRetries defines the maximum number of retries (3 by default)
  30725. * @param baseInterval defines the interval between retries
  30726. * @returns the strategy function to use
  30727. */
  30728. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30729. }
  30730. /**
  30731. * File request interface
  30732. */
  30733. export interface IFileRequest {
  30734. /**
  30735. * Raised when the request is complete (success or error).
  30736. */
  30737. onCompleteObservable: Observable<IFileRequest>;
  30738. /**
  30739. * Aborts the request for a file.
  30740. */
  30741. abort: () => void;
  30742. }
  30743. /**
  30744. * Class containing a set of static utilities functions
  30745. */
  30746. export class Tools {
  30747. /**
  30748. * Gets or sets the base URL to use to load assets
  30749. */
  30750. static BaseUrl: string;
  30751. /**
  30752. * Enable/Disable Custom HTTP Request Headers globally.
  30753. * default = false
  30754. * @see CustomRequestHeaders
  30755. */
  30756. static UseCustomRequestHeaders: boolean;
  30757. /**
  30758. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30759. * i.e. when loading files, where the server/service expects an Authorization header.
  30760. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30761. */
  30762. static CustomRequestHeaders: {
  30763. [key: string]: string;
  30764. };
  30765. /**
  30766. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30767. */
  30768. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30769. /**
  30770. * Default behaviour for cors in the application.
  30771. * It can be a string if the expected behavior is identical in the entire app.
  30772. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30773. */
  30774. static CorsBehavior: string | ((url: string | string[]) => string);
  30775. /**
  30776. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30777. * @ignorenaming
  30778. */
  30779. static UseFallbackTexture: boolean;
  30780. /**
  30781. * Use this object to register external classes like custom textures or material
  30782. * to allow the laoders to instantiate them
  30783. */
  30784. static RegisteredExternalClasses: {
  30785. [key: string]: Object;
  30786. };
  30787. /**
  30788. * Texture content used if a texture cannot loaded
  30789. * @ignorenaming
  30790. */
  30791. static fallbackTexture: string;
  30792. /**
  30793. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30794. * @param u defines the coordinate on X axis
  30795. * @param v defines the coordinate on Y axis
  30796. * @param width defines the width of the source data
  30797. * @param height defines the height of the source data
  30798. * @param pixels defines the source byte array
  30799. * @param color defines the output color
  30800. */
  30801. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30802. /**
  30803. * Interpolates between a and b via alpha
  30804. * @param a The lower value (returned when alpha = 0)
  30805. * @param b The upper value (returned when alpha = 1)
  30806. * @param alpha The interpolation-factor
  30807. * @return The mixed value
  30808. */
  30809. static Mix(a: number, b: number, alpha: number): number;
  30810. /**
  30811. * Tries to instantiate a new object from a given class name
  30812. * @param className defines the class name to instantiate
  30813. * @returns the new object or null if the system was not able to do the instantiation
  30814. */
  30815. static Instantiate(className: string): any;
  30816. /**
  30817. * Provides a slice function that will work even on IE
  30818. * @param data defines the array to slice
  30819. * @param start defines the start of the data (optional)
  30820. * @param end defines the end of the data (optional)
  30821. * @returns the new sliced array
  30822. */
  30823. static Slice<T>(data: T, start?: number, end?: number): T;
  30824. /**
  30825. * Polyfill for setImmediate
  30826. * @param action defines the action to execute after the current execution block
  30827. */
  30828. static SetImmediate(action: () => void): void;
  30829. /**
  30830. * Function indicating if a number is an exponent of 2
  30831. * @param value defines the value to test
  30832. * @returns true if the value is an exponent of 2
  30833. */
  30834. static IsExponentOfTwo(value: number): boolean;
  30835. private static _tmpFloatArray;
  30836. /**
  30837. * Returns the nearest 32-bit single precision float representation of a Number
  30838. * @param value A Number. If the parameter is of a different type, it will get converted
  30839. * to a number or to NaN if it cannot be converted
  30840. * @returns number
  30841. */
  30842. static FloatRound(value: number): number;
  30843. /**
  30844. * Find the next highest power of two.
  30845. * @param x Number to start search from.
  30846. * @return Next highest power of two.
  30847. */
  30848. static CeilingPOT(x: number): number;
  30849. /**
  30850. * Find the next lowest power of two.
  30851. * @param x Number to start search from.
  30852. * @return Next lowest power of two.
  30853. */
  30854. static FloorPOT(x: number): number;
  30855. /**
  30856. * Find the nearest power of two.
  30857. * @param x Number to start search from.
  30858. * @return Next nearest power of two.
  30859. */
  30860. static NearestPOT(x: number): number;
  30861. /**
  30862. * Get the closest exponent of two
  30863. * @param value defines the value to approximate
  30864. * @param max defines the maximum value to return
  30865. * @param mode defines how to define the closest value
  30866. * @returns closest exponent of two of the given value
  30867. */
  30868. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30869. /**
  30870. * Extracts the filename from a path
  30871. * @param path defines the path to use
  30872. * @returns the filename
  30873. */
  30874. static GetFilename(path: string): string;
  30875. /**
  30876. * Extracts the "folder" part of a path (everything before the filename).
  30877. * @param uri The URI to extract the info from
  30878. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30879. * @returns The "folder" part of the path
  30880. */
  30881. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30882. /**
  30883. * Extracts text content from a DOM element hierarchy
  30884. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30885. */
  30886. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30887. /**
  30888. * Convert an angle in radians to degrees
  30889. * @param angle defines the angle to convert
  30890. * @returns the angle in degrees
  30891. */
  30892. static ToDegrees(angle: number): number;
  30893. /**
  30894. * Convert an angle in degrees to radians
  30895. * @param angle defines the angle to convert
  30896. * @returns the angle in radians
  30897. */
  30898. static ToRadians(angle: number): number;
  30899. /**
  30900. * Encode a buffer to a base64 string
  30901. * @param buffer defines the buffer to encode
  30902. * @returns the encoded string
  30903. */
  30904. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30905. /**
  30906. * Extracts minimum and maximum values from a list of indexed positions
  30907. * @param positions defines the positions to use
  30908. * @param indices defines the indices to the positions
  30909. * @param indexStart defines the start index
  30910. * @param indexCount defines the end index
  30911. * @param bias defines bias value to add to the result
  30912. * @return minimum and maximum values
  30913. */
  30914. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30915. minimum: Vector3;
  30916. maximum: Vector3;
  30917. };
  30918. /**
  30919. * Extracts minimum and maximum values from a list of positions
  30920. * @param positions defines the positions to use
  30921. * @param start defines the start index in the positions array
  30922. * @param count defines the number of positions to handle
  30923. * @param bias defines bias value to add to the result
  30924. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30925. * @return minimum and maximum values
  30926. */
  30927. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30928. minimum: Vector3;
  30929. maximum: Vector3;
  30930. };
  30931. /**
  30932. * Returns an array if obj is not an array
  30933. * @param obj defines the object to evaluate as an array
  30934. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30935. * @returns either obj directly if obj is an array or a new array containing obj
  30936. */
  30937. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30938. /**
  30939. * Gets the pointer prefix to use
  30940. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30941. */
  30942. static GetPointerPrefix(): string;
  30943. /**
  30944. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30945. * @param func - the function to be called
  30946. * @param requester - the object that will request the next frame. Falls back to window.
  30947. * @returns frame number
  30948. */
  30949. static QueueNewFrame(func: () => void, requester?: any): number;
  30950. /**
  30951. * Ask the browser to promote the current element to fullscreen rendering mode
  30952. * @param element defines the DOM element to promote
  30953. */
  30954. static RequestFullscreen(element: HTMLElement): void;
  30955. /**
  30956. * Asks the browser to exit fullscreen mode
  30957. */
  30958. static ExitFullscreen(): void;
  30959. /**
  30960. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30961. * @param url define the url we are trying
  30962. * @param element define the dom element where to configure the cors policy
  30963. */
  30964. static SetCorsBehavior(url: string | string[], element: {
  30965. crossOrigin: string | null;
  30966. }): void;
  30967. /**
  30968. * Removes unwanted characters from an url
  30969. * @param url defines the url to clean
  30970. * @returns the cleaned url
  30971. */
  30972. static CleanUrl(url: string): string;
  30973. /**
  30974. * Gets or sets a function used to pre-process url before using them to load assets
  30975. */
  30976. static PreprocessUrl: (url: string) => string;
  30977. /**
  30978. * Loads an image as an HTMLImageElement.
  30979. * @param input url string, ArrayBuffer, or Blob to load
  30980. * @param onLoad callback called when the image successfully loads
  30981. * @param onError callback called when the image fails to load
  30982. * @param offlineProvider offline provider for caching
  30983. * @returns the HTMLImageElement of the loaded image
  30984. */
  30985. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30986. /**
  30987. * Loads a file
  30988. * @param url url string, ArrayBuffer, or Blob to load
  30989. * @param onSuccess callback called when the file successfully loads
  30990. * @param onProgress callback called while file is loading (if the server supports this mode)
  30991. * @param offlineProvider defines the offline provider for caching
  30992. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30993. * @param onError callback called when the file fails to load
  30994. * @returns a file request object
  30995. */
  30996. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  30997. /**
  30998. * Load a script (identified by an url). When the url returns, the
  30999. * content of this file is added into a new script element, attached to the DOM (body element)
  31000. * @param scriptUrl defines the url of the script to laod
  31001. * @param onSuccess defines the callback called when the script is loaded
  31002. * @param onError defines the callback to call if an error occurs
  31003. */
  31004. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31005. /**
  31006. * Loads a file from a blob
  31007. * @param fileToLoad defines the blob to use
  31008. * @param callback defines the callback to call when data is loaded
  31009. * @param progressCallback defines the callback to call during loading process
  31010. * @returns a file request object
  31011. */
  31012. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31013. /**
  31014. * Loads a file
  31015. * @param fileToLoad defines the file to load
  31016. * @param callback defines the callback to call when data is loaded
  31017. * @param progressCallBack defines the callback to call during loading process
  31018. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31019. * @returns a file request object
  31020. */
  31021. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31022. /**
  31023. * Creates a data url from a given string content
  31024. * @param content defines the content to convert
  31025. * @returns the new data url link
  31026. */
  31027. static FileAsURL(content: string): string;
  31028. /**
  31029. * Format the given number to a specific decimal format
  31030. * @param value defines the number to format
  31031. * @param decimals defines the number of decimals to use
  31032. * @returns the formatted string
  31033. */
  31034. static Format(value: number, decimals?: number): string;
  31035. /**
  31036. * Checks if a given vector is inside a specific range
  31037. * @param v defines the vector to test
  31038. * @param min defines the minimum range
  31039. * @param max defines the maximum range
  31040. */
  31041. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31042. /**
  31043. * Tries to copy an object by duplicating every property
  31044. * @param source defines the source object
  31045. * @param destination defines the target object
  31046. * @param doNotCopyList defines a list of properties to avoid
  31047. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31048. */
  31049. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31050. /**
  31051. * Gets a boolean indicating if the given object has no own property
  31052. * @param obj defines the object to test
  31053. * @returns true if object has no own property
  31054. */
  31055. static IsEmpty(obj: any): boolean;
  31056. /**
  31057. * Function used to register events at window level
  31058. * @param events defines the events to register
  31059. */
  31060. static RegisterTopRootEvents(events: {
  31061. name: string;
  31062. handler: Nullable<(e: FocusEvent) => any>;
  31063. }[]): void;
  31064. /**
  31065. * Function used to unregister events from window level
  31066. * @param events defines the events to unregister
  31067. */
  31068. static UnregisterTopRootEvents(events: {
  31069. name: string;
  31070. handler: Nullable<(e: FocusEvent) => any>;
  31071. }[]): void;
  31072. /**
  31073. * @ignore
  31074. */
  31075. static _ScreenshotCanvas: HTMLCanvasElement;
  31076. /**
  31077. * Dumps the current bound framebuffer
  31078. * @param width defines the rendering width
  31079. * @param height defines the rendering height
  31080. * @param engine defines the hosting engine
  31081. * @param successCallback defines the callback triggered once the data are available
  31082. * @param mimeType defines the mime type of the result
  31083. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31084. */
  31085. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31086. /**
  31087. * Converts the canvas data to blob.
  31088. * This acts as a polyfill for browsers not supporting the to blob function.
  31089. * @param canvas Defines the canvas to extract the data from
  31090. * @param successCallback Defines the callback triggered once the data are available
  31091. * @param mimeType Defines the mime type of the result
  31092. */
  31093. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31094. /**
  31095. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31096. * @param successCallback defines the callback triggered once the data are available
  31097. * @param mimeType defines the mime type of the result
  31098. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31099. */
  31100. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31101. /**
  31102. * Downloads a blob in the browser
  31103. * @param blob defines the blob to download
  31104. * @param fileName defines the name of the downloaded file
  31105. */
  31106. static Download(blob: Blob, fileName: string): void;
  31107. /**
  31108. * Captures a screenshot of the current rendering
  31109. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31110. * @param engine defines the rendering engine
  31111. * @param camera defines the source camera
  31112. * @param size This parameter can be set to a single number or to an object with the
  31113. * following (optional) properties: precision, width, height. If a single number is passed,
  31114. * it will be used for both width and height. If an object is passed, the screenshot size
  31115. * will be derived from the parameters. The precision property is a multiplier allowing
  31116. * rendering at a higher or lower resolution
  31117. * @param successCallback defines the callback receives a single parameter which contains the
  31118. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31119. * src parameter of an <img> to display it
  31120. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31121. * Check your browser for supported MIME types
  31122. */
  31123. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31124. /**
  31125. * Generates an image screenshot from the specified camera.
  31126. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31127. * @param engine The engine to use for rendering
  31128. * @param camera The camera to use for rendering
  31129. * @param size This parameter can be set to a single number or to an object with the
  31130. * following (optional) properties: precision, width, height. If a single number is passed,
  31131. * it will be used for both width and height. If an object is passed, the screenshot size
  31132. * will be derived from the parameters. The precision property is a multiplier allowing
  31133. * rendering at a higher or lower resolution
  31134. * @param successCallback The callback receives a single parameter which contains the
  31135. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31136. * src parameter of an <img> to display it
  31137. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31138. * Check your browser for supported MIME types
  31139. * @param samples Texture samples (default: 1)
  31140. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31141. * @param fileName A name for for the downloaded file.
  31142. */
  31143. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31144. /**
  31145. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31146. * Be aware Math.random() could cause collisions, but:
  31147. * "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"
  31148. * @returns a pseudo random id
  31149. */
  31150. static RandomId(): string;
  31151. /**
  31152. * Test if the given uri is a base64 string
  31153. * @param uri The uri to test
  31154. * @return True if the uri is a base64 string or false otherwise
  31155. */
  31156. static IsBase64(uri: string): boolean;
  31157. /**
  31158. * Decode the given base64 uri.
  31159. * @param uri The uri to decode
  31160. * @return The decoded base64 data.
  31161. */
  31162. static DecodeBase64(uri: string): ArrayBuffer;
  31163. /**
  31164. * No log
  31165. */
  31166. static readonly NoneLogLevel: number;
  31167. /**
  31168. * Only message logs
  31169. */
  31170. static readonly MessageLogLevel: number;
  31171. /**
  31172. * Only warning logs
  31173. */
  31174. static readonly WarningLogLevel: number;
  31175. /**
  31176. * Only error logs
  31177. */
  31178. static readonly ErrorLogLevel: number;
  31179. /**
  31180. * All logs
  31181. */
  31182. static readonly AllLogLevel: number;
  31183. /**
  31184. * Gets a value indicating the number of loading errors
  31185. * @ignorenaming
  31186. */
  31187. static readonly errorsCount: number;
  31188. /**
  31189. * Callback called when a new log is added
  31190. */
  31191. static OnNewCacheEntry: (entry: string) => void;
  31192. /**
  31193. * Log a message to the console
  31194. * @param message defines the message to log
  31195. */
  31196. static Log(message: string): void;
  31197. /**
  31198. * Write a warning message to the console
  31199. * @param message defines the message to log
  31200. */
  31201. static Warn(message: string): void;
  31202. /**
  31203. * Write an error message to the console
  31204. * @param message defines the message to log
  31205. */
  31206. static Error(message: string): void;
  31207. /**
  31208. * Gets current log cache (list of logs)
  31209. */
  31210. static readonly LogCache: string;
  31211. /**
  31212. * Clears the log cache
  31213. */
  31214. static ClearLogCache(): void;
  31215. /**
  31216. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31217. */
  31218. static LogLevels: number;
  31219. /**
  31220. * Checks if the loaded document was accessed via `file:`-Protocol.
  31221. * @returns boolean
  31222. */
  31223. static IsFileURL(): boolean;
  31224. /**
  31225. * Checks if the window object exists
  31226. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31227. */
  31228. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31229. /**
  31230. * No performance log
  31231. */
  31232. static readonly PerformanceNoneLogLevel: number;
  31233. /**
  31234. * Use user marks to log performance
  31235. */
  31236. static readonly PerformanceUserMarkLogLevel: number;
  31237. /**
  31238. * Log performance to the console
  31239. */
  31240. static readonly PerformanceConsoleLogLevel: number;
  31241. private static _performance;
  31242. /**
  31243. * Sets the current performance log level
  31244. */
  31245. static PerformanceLogLevel: number;
  31246. private static _StartPerformanceCounterDisabled;
  31247. private static _EndPerformanceCounterDisabled;
  31248. private static _StartUserMark;
  31249. private static _EndUserMark;
  31250. private static _StartPerformanceConsole;
  31251. private static _EndPerformanceConsole;
  31252. /**
  31253. * Injects the @see CustomRequestHeaders into the given request
  31254. * @param request the request that should be used for injection
  31255. */
  31256. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31257. /**
  31258. * Starts a performance counter
  31259. */
  31260. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31261. /**
  31262. * Ends a specific performance coutner
  31263. */
  31264. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31265. /**
  31266. * Gets either window.performance.now() if supported or Date.now() else
  31267. */
  31268. static readonly Now: number;
  31269. /**
  31270. * This method will return the name of the class used to create the instance of the given object.
  31271. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31272. * @param object the object to get the class name from
  31273. * @param isType defines if the object is actually a type
  31274. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31275. */
  31276. static GetClassName(object: any, isType?: boolean): string;
  31277. /**
  31278. * Gets the first element of an array satisfying a given predicate
  31279. * @param array defines the array to browse
  31280. * @param predicate defines the predicate to use
  31281. * @returns null if not found or the element
  31282. */
  31283. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31284. /**
  31285. * This method will return the name of the full name of the class, including its owning module (if any).
  31286. * 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).
  31287. * @param object the object to get the class name from
  31288. * @param isType defines if the object is actually a type
  31289. * @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.
  31290. * @ignorenaming
  31291. */
  31292. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31293. /**
  31294. * Returns a promise that resolves after the given amount of time.
  31295. * @param delay Number of milliseconds to delay
  31296. * @returns Promise that resolves after the given amount of time
  31297. */
  31298. static DelayAsync(delay: number): Promise<void>;
  31299. /**
  31300. * Gets the current gradient from an array of IValueGradient
  31301. * @param ratio defines the current ratio to get
  31302. * @param gradients defines the array of IValueGradient
  31303. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31304. */
  31305. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31306. }
  31307. /**
  31308. * This class is used to track a performance counter which is number based.
  31309. * The user has access to many properties which give statistics of different nature.
  31310. *
  31311. * The implementer can track two kinds of Performance Counter: time and count.
  31312. * 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.
  31313. * 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.
  31314. */
  31315. export class PerfCounter {
  31316. /**
  31317. * Gets or sets a global boolean to turn on and off all the counters
  31318. */
  31319. static Enabled: boolean;
  31320. /**
  31321. * Returns the smallest value ever
  31322. */
  31323. readonly min: number;
  31324. /**
  31325. * Returns the biggest value ever
  31326. */
  31327. readonly max: number;
  31328. /**
  31329. * Returns the average value since the performance counter is running
  31330. */
  31331. readonly average: number;
  31332. /**
  31333. * Returns the average value of the last second the counter was monitored
  31334. */
  31335. readonly lastSecAverage: number;
  31336. /**
  31337. * Returns the current value
  31338. */
  31339. readonly current: number;
  31340. /**
  31341. * Gets the accumulated total
  31342. */
  31343. readonly total: number;
  31344. /**
  31345. * Gets the total value count
  31346. */
  31347. readonly count: number;
  31348. /**
  31349. * Creates a new counter
  31350. */
  31351. constructor();
  31352. /**
  31353. * Call this method to start monitoring a new frame.
  31354. * 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.
  31355. */
  31356. fetchNewFrame(): void;
  31357. /**
  31358. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31359. * @param newCount the count value to add to the monitored count
  31360. * @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.
  31361. */
  31362. addCount(newCount: number, fetchResult: boolean): void;
  31363. /**
  31364. * Start monitoring this performance counter
  31365. */
  31366. beginMonitoring(): void;
  31367. /**
  31368. * Compute the time lapsed since the previous beginMonitoring() call.
  31369. * @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
  31370. */
  31371. endMonitoring(newFrame?: boolean): void;
  31372. private _fetchResult;
  31373. private _startMonitoringTime;
  31374. private _min;
  31375. private _max;
  31376. private _average;
  31377. private _current;
  31378. private _totalValueCount;
  31379. private _totalAccumulated;
  31380. private _lastSecAverage;
  31381. private _lastSecAccumulated;
  31382. private _lastSecTime;
  31383. private _lastSecValueCount;
  31384. }
  31385. /**
  31386. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31387. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31388. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31389. * @param name The name of the class, case should be preserved
  31390. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31391. */
  31392. export function className(name: string, module?: string): (target: Object) => void;
  31393. /**
  31394. * An implementation of a loop for asynchronous functions.
  31395. */
  31396. export class AsyncLoop {
  31397. /**
  31398. * Defines the number of iterations for the loop
  31399. */
  31400. iterations: number;
  31401. /**
  31402. * Defines the current index of the loop.
  31403. */
  31404. index: number;
  31405. private _done;
  31406. private _fn;
  31407. private _successCallback;
  31408. /**
  31409. * Constructor.
  31410. * @param iterations the number of iterations.
  31411. * @param func the function to run each iteration
  31412. * @param successCallback the callback that will be called upon succesful execution
  31413. * @param offset starting offset.
  31414. */
  31415. constructor(
  31416. /**
  31417. * Defines the number of iterations for the loop
  31418. */
  31419. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31420. /**
  31421. * Execute the next iteration. Must be called after the last iteration was finished.
  31422. */
  31423. executeNext(): void;
  31424. /**
  31425. * Break the loop and run the success callback.
  31426. */
  31427. breakLoop(): void;
  31428. /**
  31429. * Create and run an async loop.
  31430. * @param iterations the number of iterations.
  31431. * @param fn the function to run each iteration
  31432. * @param successCallback the callback that will be called upon succesful execution
  31433. * @param offset starting offset.
  31434. * @returns the created async loop object
  31435. */
  31436. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31437. /**
  31438. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31439. * @param iterations total number of iterations
  31440. * @param syncedIterations number of synchronous iterations in each async iteration.
  31441. * @param fn the function to call each iteration.
  31442. * @param callback a success call back that will be called when iterating stops.
  31443. * @param breakFunction a break condition (optional)
  31444. * @param timeout timeout settings for the setTimeout function. default - 0.
  31445. * @returns the created async loop object
  31446. */
  31447. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31448. }
  31449. }
  31450. declare module "babylonjs/Collisions/collisionCoordinator" {
  31451. import { Nullable } from "babylonjs/types";
  31452. import { Scene } from "babylonjs/scene";
  31453. import { Vector3 } from "babylonjs/Maths/math";
  31454. import { Collider } from "babylonjs/Collisions/collider";
  31455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31456. /** @hidden */
  31457. export interface ICollisionCoordinator {
  31458. createCollider(): Collider;
  31459. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31460. init(scene: Scene): void;
  31461. }
  31462. /** @hidden */
  31463. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31464. private _scene;
  31465. private _scaledPosition;
  31466. private _scaledVelocity;
  31467. private _finalPosition;
  31468. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31469. createCollider(): Collider;
  31470. init(scene: Scene): void;
  31471. private _collideWithWorld;
  31472. }
  31473. }
  31474. declare module "babylonjs/Animations/animationGroup" {
  31475. import { Animatable } from "babylonjs/Animations/animatable";
  31476. import { Animation } from "babylonjs/Animations/animation";
  31477. import { Scene, IDisposable } from "babylonjs/scene";
  31478. import { Observable } from "babylonjs/Misc/observable";
  31479. import { Nullable } from "babylonjs/types";
  31480. /**
  31481. * This class defines the direct association between an animation and a target
  31482. */
  31483. export class TargetedAnimation {
  31484. /**
  31485. * Animation to perform
  31486. */
  31487. animation: Animation;
  31488. /**
  31489. * Target to animate
  31490. */
  31491. target: any;
  31492. }
  31493. /**
  31494. * Use this class to create coordinated animations on multiple targets
  31495. */
  31496. export class AnimationGroup implements IDisposable {
  31497. /** The name of the animation group */
  31498. name: string;
  31499. private _scene;
  31500. private _targetedAnimations;
  31501. private _animatables;
  31502. private _from;
  31503. private _to;
  31504. private _isStarted;
  31505. private _isPaused;
  31506. private _speedRatio;
  31507. /**
  31508. * Gets or sets the unique id of the node
  31509. */
  31510. uniqueId: number;
  31511. /**
  31512. * This observable will notify when one animation have ended
  31513. */
  31514. onAnimationEndObservable: Observable<TargetedAnimation>;
  31515. /**
  31516. * Observer raised when one animation loops
  31517. */
  31518. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31519. /**
  31520. * This observable will notify when all animations have ended.
  31521. */
  31522. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31523. /**
  31524. * This observable will notify when all animations have paused.
  31525. */
  31526. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31527. /**
  31528. * This observable will notify when all animations are playing.
  31529. */
  31530. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31531. /**
  31532. * Gets the first frame
  31533. */
  31534. readonly from: number;
  31535. /**
  31536. * Gets the last frame
  31537. */
  31538. readonly to: number;
  31539. /**
  31540. * Define if the animations are started
  31541. */
  31542. readonly isStarted: boolean;
  31543. /**
  31544. * Gets a value indicating that the current group is playing
  31545. */
  31546. readonly isPlaying: boolean;
  31547. /**
  31548. * Gets or sets the speed ratio to use for all animations
  31549. */
  31550. /**
  31551. * Gets or sets the speed ratio to use for all animations
  31552. */
  31553. speedRatio: number;
  31554. /**
  31555. * Gets the targeted animations for this animation group
  31556. */
  31557. readonly targetedAnimations: Array<TargetedAnimation>;
  31558. /**
  31559. * returning the list of animatables controlled by this animation group.
  31560. */
  31561. readonly animatables: Array<Animatable>;
  31562. /**
  31563. * Instantiates a new Animation Group.
  31564. * This helps managing several animations at once.
  31565. * @see http://doc.babylonjs.com/how_to/group
  31566. * @param name Defines the name of the group
  31567. * @param scene Defines the scene the group belongs to
  31568. */
  31569. constructor(
  31570. /** The name of the animation group */
  31571. name: string, scene?: Nullable<Scene>);
  31572. /**
  31573. * Add an animation (with its target) in the group
  31574. * @param animation defines the animation we want to add
  31575. * @param target defines the target of the animation
  31576. * @returns the TargetedAnimation object
  31577. */
  31578. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31579. /**
  31580. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31581. * It can add constant keys at begin or end
  31582. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31583. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31584. * @returns the animation group
  31585. */
  31586. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31587. /**
  31588. * Start all animations on given targets
  31589. * @param loop defines if animations must loop
  31590. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31591. * @param from defines the from key (optional)
  31592. * @param to defines the to key (optional)
  31593. * @returns the current animation group
  31594. */
  31595. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31596. /**
  31597. * Pause all animations
  31598. * @returns the animation group
  31599. */
  31600. pause(): AnimationGroup;
  31601. /**
  31602. * Play all animations to initial state
  31603. * This function will start() the animations if they were not started or will restart() them if they were paused
  31604. * @param loop defines if animations must loop
  31605. * @returns the animation group
  31606. */
  31607. play(loop?: boolean): AnimationGroup;
  31608. /**
  31609. * Reset all animations to initial state
  31610. * @returns the animation group
  31611. */
  31612. reset(): AnimationGroup;
  31613. /**
  31614. * Restart animations from key 0
  31615. * @returns the animation group
  31616. */
  31617. restart(): AnimationGroup;
  31618. /**
  31619. * Stop all animations
  31620. * @returns the animation group
  31621. */
  31622. stop(): AnimationGroup;
  31623. /**
  31624. * Set animation weight for all animatables
  31625. * @param weight defines the weight to use
  31626. * @return the animationGroup
  31627. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31628. */
  31629. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31630. /**
  31631. * Synchronize and normalize all animatables with a source animatable
  31632. * @param root defines the root animatable to synchronize with
  31633. * @return the animationGroup
  31634. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31635. */
  31636. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31637. /**
  31638. * Goes to a specific frame in this animation group
  31639. * @param frame the frame number to go to
  31640. * @return the animationGroup
  31641. */
  31642. goToFrame(frame: number): AnimationGroup;
  31643. /**
  31644. * Dispose all associated resources
  31645. */
  31646. dispose(): void;
  31647. private _checkAnimationGroupEnded;
  31648. /**
  31649. * Clone the current animation group and returns a copy
  31650. * @param newName defines the name of the new group
  31651. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31652. * @returns the new aniamtion group
  31653. */
  31654. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31655. /**
  31656. * Returns a new AnimationGroup object parsed from the source provided.
  31657. * @param parsedAnimationGroup defines the source
  31658. * @param scene defines the scene that will receive the animationGroup
  31659. * @returns a new AnimationGroup
  31660. */
  31661. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31662. /**
  31663. * Returns the string "AnimationGroup"
  31664. * @returns "AnimationGroup"
  31665. */
  31666. getClassName(): string;
  31667. /**
  31668. * Creates a detailled string about the object
  31669. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31670. * @returns a string representing the object
  31671. */
  31672. toString(fullDetails?: boolean): string;
  31673. }
  31674. }
  31675. declare module "babylonjs/scene" {
  31676. import { Nullable } from "babylonjs/types";
  31677. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31678. import { Observable } from "babylonjs/Misc/observable";
  31679. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31680. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31681. import { Geometry } from "babylonjs/Meshes/geometry";
  31682. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31683. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31685. import { Mesh } from "babylonjs/Meshes/mesh";
  31686. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31687. import { Bone } from "babylonjs/Bones/bone";
  31688. import { Skeleton } from "babylonjs/Bones/skeleton";
  31689. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31690. import { Camera } from "babylonjs/Cameras/camera";
  31691. import { AbstractScene } from "babylonjs/abstractScene";
  31692. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31693. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31694. import { Material } from "babylonjs/Materials/material";
  31695. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31696. import { Effect } from "babylonjs/Materials/effect";
  31697. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31698. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31699. import { Light } from "babylonjs/Lights/light";
  31700. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31701. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31702. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31703. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31704. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31705. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31706. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31707. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31708. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31709. import { Engine } from "babylonjs/Engines/engine";
  31710. import { Node } from "babylonjs/node";
  31711. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31712. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31713. import { Ray } from "babylonjs/Culling/ray";
  31714. import { Animation } from "babylonjs/Animations/animation";
  31715. import { Animatable } from "babylonjs/Animations/animatable";
  31716. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31717. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31718. import { Collider } from "babylonjs/Collisions/collider";
  31719. /**
  31720. * Define an interface for all classes that will hold resources
  31721. */
  31722. export interface IDisposable {
  31723. /**
  31724. * Releases all held resources
  31725. */
  31726. dispose(): void;
  31727. }
  31728. /** Interface defining initialization parameters for Scene class */
  31729. export interface SceneOptions {
  31730. /**
  31731. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31732. * It will improve performance when the number of geometries becomes important.
  31733. */
  31734. useGeometryUniqueIdsMap?: boolean;
  31735. /**
  31736. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31737. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31738. */
  31739. useMaterialMeshMap?: boolean;
  31740. /**
  31741. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31742. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31743. */
  31744. useClonedMeshhMap?: boolean;
  31745. }
  31746. /**
  31747. * Represents a scene to be rendered by the engine.
  31748. * @see http://doc.babylonjs.com/features/scene
  31749. */
  31750. export class Scene extends AbstractScene implements IAnimatable {
  31751. private static _uniqueIdCounter;
  31752. /** The fog is deactivated */
  31753. static readonly FOGMODE_NONE: number;
  31754. /** The fog density is following an exponential function */
  31755. static readonly FOGMODE_EXP: number;
  31756. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31757. static readonly FOGMODE_EXP2: number;
  31758. /** The fog density is following a linear function. */
  31759. static readonly FOGMODE_LINEAR: number;
  31760. /**
  31761. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31762. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31763. */
  31764. static MinDeltaTime: number;
  31765. /**
  31766. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31767. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31768. */
  31769. static MaxDeltaTime: number;
  31770. /**
  31771. * Factory used to create the default material.
  31772. * @param name The name of the material to create
  31773. * @param scene The scene to create the material for
  31774. * @returns The default material
  31775. */
  31776. static DefaultMaterialFactory(scene: Scene): Material;
  31777. /**
  31778. * Factory used to create the a collision coordinator.
  31779. * @returns The collision coordinator
  31780. */
  31781. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31782. /** @hidden */
  31783. readonly _isScene: boolean;
  31784. /**
  31785. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31786. */
  31787. autoClear: boolean;
  31788. /**
  31789. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31790. */
  31791. autoClearDepthAndStencil: boolean;
  31792. /**
  31793. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31794. */
  31795. clearColor: Color4;
  31796. /**
  31797. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31798. */
  31799. ambientColor: Color3;
  31800. /** @hidden */
  31801. _environmentBRDFTexture: BaseTexture;
  31802. /** @hidden */
  31803. protected _environmentTexture: Nullable<BaseTexture>;
  31804. /**
  31805. * Texture used in all pbr material as the reflection texture.
  31806. * As in the majority of the scene they are the same (exception for multi room and so on),
  31807. * this is easier to reference from here than from all the materials.
  31808. */
  31809. /**
  31810. * Texture used in all pbr material as the reflection texture.
  31811. * As in the majority of the scene they are the same (exception for multi room and so on),
  31812. * this is easier to set here than in all the materials.
  31813. */
  31814. environmentTexture: Nullable<BaseTexture>;
  31815. /** @hidden */
  31816. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31817. /**
  31818. * Default image processing configuration used either in the rendering
  31819. * Forward main pass or through the imageProcessingPostProcess if present.
  31820. * As in the majority of the scene they are the same (exception for multi camera),
  31821. * this is easier to reference from here than from all the materials and post process.
  31822. *
  31823. * No setter as we it is a shared configuration, you can set the values instead.
  31824. */
  31825. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31826. private _forceWireframe;
  31827. /**
  31828. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31829. */
  31830. forceWireframe: boolean;
  31831. private _forcePointsCloud;
  31832. /**
  31833. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31834. */
  31835. forcePointsCloud: boolean;
  31836. /**
  31837. * Gets or sets the active clipplane 1
  31838. */
  31839. clipPlane: Nullable<Plane>;
  31840. /**
  31841. * Gets or sets the active clipplane 2
  31842. */
  31843. clipPlane2: Nullable<Plane>;
  31844. /**
  31845. * Gets or sets the active clipplane 3
  31846. */
  31847. clipPlane3: Nullable<Plane>;
  31848. /**
  31849. * Gets or sets the active clipplane 4
  31850. */
  31851. clipPlane4: Nullable<Plane>;
  31852. /**
  31853. * Gets or sets a boolean indicating if animations are enabled
  31854. */
  31855. animationsEnabled: boolean;
  31856. private _animationPropertiesOverride;
  31857. /**
  31858. * Gets or sets the animation properties override
  31859. */
  31860. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31861. /**
  31862. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31863. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31864. */
  31865. useConstantAnimationDeltaTime: boolean;
  31866. /**
  31867. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31868. * Please note that it requires to run a ray cast through the scene on every frame
  31869. */
  31870. constantlyUpdateMeshUnderPointer: boolean;
  31871. /**
  31872. * Defines the HTML cursor to use when hovering over interactive elements
  31873. */
  31874. hoverCursor: string;
  31875. /**
  31876. * Defines the HTML default cursor to use (empty by default)
  31877. */
  31878. defaultCursor: string;
  31879. /**
  31880. * This is used to call preventDefault() on pointer down
  31881. * in order to block unwanted artifacts like system double clicks
  31882. */
  31883. preventDefaultOnPointerDown: boolean;
  31884. /**
  31885. * This is used to call preventDefault() on pointer up
  31886. * in order to block unwanted artifacts like system double clicks
  31887. */
  31888. preventDefaultOnPointerUp: boolean;
  31889. /**
  31890. * Gets or sets user defined metadata
  31891. */
  31892. metadata: any;
  31893. /**
  31894. * For internal use only. Please do not use.
  31895. */
  31896. reservedDataStore: any;
  31897. /**
  31898. * Gets the name of the plugin used to load this scene (null by default)
  31899. */
  31900. loadingPluginName: string;
  31901. /**
  31902. * Use this array to add regular expressions used to disable offline support for specific urls
  31903. */
  31904. disableOfflineSupportExceptionRules: RegExp[];
  31905. /**
  31906. * An event triggered when the scene is disposed.
  31907. */
  31908. onDisposeObservable: Observable<Scene>;
  31909. private _onDisposeObserver;
  31910. /** Sets a function to be executed when this scene is disposed. */
  31911. onDispose: () => void;
  31912. /**
  31913. * An event triggered before rendering the scene (right after animations and physics)
  31914. */
  31915. onBeforeRenderObservable: Observable<Scene>;
  31916. private _onBeforeRenderObserver;
  31917. /** Sets a function to be executed before rendering this scene */
  31918. beforeRender: Nullable<() => void>;
  31919. /**
  31920. * An event triggered after rendering the scene
  31921. */
  31922. onAfterRenderObservable: Observable<Scene>;
  31923. private _onAfterRenderObserver;
  31924. /** Sets a function to be executed after rendering this scene */
  31925. afterRender: Nullable<() => void>;
  31926. /**
  31927. * An event triggered before animating the scene
  31928. */
  31929. onBeforeAnimationsObservable: Observable<Scene>;
  31930. /**
  31931. * An event triggered after animations processing
  31932. */
  31933. onAfterAnimationsObservable: Observable<Scene>;
  31934. /**
  31935. * An event triggered before draw calls are ready to be sent
  31936. */
  31937. onBeforeDrawPhaseObservable: Observable<Scene>;
  31938. /**
  31939. * An event triggered after draw calls have been sent
  31940. */
  31941. onAfterDrawPhaseObservable: Observable<Scene>;
  31942. /**
  31943. * An event triggered when the scene is ready
  31944. */
  31945. onReadyObservable: Observable<Scene>;
  31946. /**
  31947. * An event triggered before rendering a camera
  31948. */
  31949. onBeforeCameraRenderObservable: Observable<Camera>;
  31950. private _onBeforeCameraRenderObserver;
  31951. /** Sets a function to be executed before rendering a camera*/
  31952. beforeCameraRender: () => void;
  31953. /**
  31954. * An event triggered after rendering a camera
  31955. */
  31956. onAfterCameraRenderObservable: Observable<Camera>;
  31957. private _onAfterCameraRenderObserver;
  31958. /** Sets a function to be executed after rendering a camera*/
  31959. afterCameraRender: () => void;
  31960. /**
  31961. * An event triggered when active meshes evaluation is about to start
  31962. */
  31963. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31964. /**
  31965. * An event triggered when active meshes evaluation is done
  31966. */
  31967. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31968. /**
  31969. * An event triggered when particles rendering is about to start
  31970. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31971. */
  31972. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31973. /**
  31974. * An event triggered when particles rendering is done
  31975. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31976. */
  31977. onAfterParticlesRenderingObservable: Observable<Scene>;
  31978. /**
  31979. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31980. */
  31981. onDataLoadedObservable: Observable<Scene>;
  31982. /**
  31983. * An event triggered when a camera is created
  31984. */
  31985. onNewCameraAddedObservable: Observable<Camera>;
  31986. /**
  31987. * An event triggered when a camera is removed
  31988. */
  31989. onCameraRemovedObservable: Observable<Camera>;
  31990. /**
  31991. * An event triggered when a light is created
  31992. */
  31993. onNewLightAddedObservable: Observable<Light>;
  31994. /**
  31995. * An event triggered when a light is removed
  31996. */
  31997. onLightRemovedObservable: Observable<Light>;
  31998. /**
  31999. * An event triggered when a geometry is created
  32000. */
  32001. onNewGeometryAddedObservable: Observable<Geometry>;
  32002. /**
  32003. * An event triggered when a geometry is removed
  32004. */
  32005. onGeometryRemovedObservable: Observable<Geometry>;
  32006. /**
  32007. * An event triggered when a transform node is created
  32008. */
  32009. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32010. /**
  32011. * An event triggered when a transform node is removed
  32012. */
  32013. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32014. /**
  32015. * An event triggered when a mesh is created
  32016. */
  32017. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32018. /**
  32019. * An event triggered when a mesh is removed
  32020. */
  32021. onMeshRemovedObservable: Observable<AbstractMesh>;
  32022. /**
  32023. * An event triggered when a material is created
  32024. */
  32025. onNewMaterialAddedObservable: Observable<Material>;
  32026. /**
  32027. * An event triggered when a material is removed
  32028. */
  32029. onMaterialRemovedObservable: Observable<Material>;
  32030. /**
  32031. * An event triggered when a texture is created
  32032. */
  32033. onNewTextureAddedObservable: Observable<BaseTexture>;
  32034. /**
  32035. * An event triggered when a texture is removed
  32036. */
  32037. onTextureRemovedObservable: Observable<BaseTexture>;
  32038. /**
  32039. * An event triggered when render targets are about to be rendered
  32040. * Can happen multiple times per frame.
  32041. */
  32042. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32043. /**
  32044. * An event triggered when render targets were rendered.
  32045. * Can happen multiple times per frame.
  32046. */
  32047. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32048. /**
  32049. * An event triggered before calculating deterministic simulation step
  32050. */
  32051. onBeforeStepObservable: Observable<Scene>;
  32052. /**
  32053. * An event triggered after calculating deterministic simulation step
  32054. */
  32055. onAfterStepObservable: Observable<Scene>;
  32056. /**
  32057. * An event triggered when the activeCamera property is updated
  32058. */
  32059. onActiveCameraChanged: Observable<Scene>;
  32060. /**
  32061. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32062. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32063. * 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)
  32064. */
  32065. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32066. /**
  32067. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32068. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32069. * 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)
  32070. */
  32071. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32072. /**
  32073. * This Observable will when a mesh has been imported into the scene.
  32074. */
  32075. onMeshImportedObservable: Observable<AbstractMesh>;
  32076. /**
  32077. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32078. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32079. */
  32080. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32081. /** @hidden */
  32082. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32083. /**
  32084. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32085. */
  32086. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32087. /**
  32088. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32089. */
  32090. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32091. /**
  32092. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32093. */
  32094. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32095. private _onPointerMove;
  32096. private _onPointerDown;
  32097. private _onPointerUp;
  32098. /** Callback called when a pointer move is detected */
  32099. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32100. /** Callback called when a pointer down is detected */
  32101. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32102. /** Callback called when a pointer up is detected */
  32103. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32104. /** Callback called when a pointer pick is detected */
  32105. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32106. /**
  32107. * 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).
  32108. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32109. */
  32110. onPrePointerObservable: Observable<PointerInfoPre>;
  32111. /**
  32112. * Observable event triggered each time an input event is received from the rendering canvas
  32113. */
  32114. onPointerObservable: Observable<PointerInfo>;
  32115. /**
  32116. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32117. */
  32118. readonly unTranslatedPointer: Vector2;
  32119. /** The distance in pixel that you have to move to prevent some events */
  32120. static DragMovementThreshold: number;
  32121. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32122. static LongPressDelay: number;
  32123. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32124. static DoubleClickDelay: number;
  32125. /** If you need to check double click without raising a single click at first click, enable this flag */
  32126. static ExclusiveDoubleClickMode: boolean;
  32127. private _initClickEvent;
  32128. private _initActionManager;
  32129. private _delayedSimpleClick;
  32130. private _delayedSimpleClickTimeout;
  32131. private _previousDelayedSimpleClickTimeout;
  32132. private _meshPickProceed;
  32133. private _previousButtonPressed;
  32134. private _currentPickResult;
  32135. private _previousPickResult;
  32136. private _totalPointersPressed;
  32137. private _doubleClickOccured;
  32138. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32139. cameraToUseForPointers: Nullable<Camera>;
  32140. private _pointerX;
  32141. private _pointerY;
  32142. private _unTranslatedPointerX;
  32143. private _unTranslatedPointerY;
  32144. private _startingPointerPosition;
  32145. private _previousStartingPointerPosition;
  32146. private _startingPointerTime;
  32147. private _previousStartingPointerTime;
  32148. private _pointerCaptures;
  32149. private _timeAccumulator;
  32150. private _currentStepId;
  32151. private _currentInternalStep;
  32152. /** @hidden */
  32153. _mirroredCameraPosition: Nullable<Vector3>;
  32154. /**
  32155. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32156. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32157. */
  32158. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32159. /**
  32160. * Observable event triggered each time an keyboard event is received from the hosting window
  32161. */
  32162. onKeyboardObservable: Observable<KeyboardInfo>;
  32163. private _onKeyDown;
  32164. private _onKeyUp;
  32165. private _onCanvasFocusObserver;
  32166. private _onCanvasBlurObserver;
  32167. private _useRightHandedSystem;
  32168. /**
  32169. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32170. */
  32171. useRightHandedSystem: boolean;
  32172. /**
  32173. * Sets the step Id used by deterministic lock step
  32174. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32175. * @param newStepId defines the step Id
  32176. */
  32177. setStepId(newStepId: number): void;
  32178. /**
  32179. * Gets the step Id used by deterministic lock step
  32180. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32181. * @returns the step Id
  32182. */
  32183. getStepId(): number;
  32184. /**
  32185. * Gets the internal step used by deterministic lock step
  32186. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32187. * @returns the internal step
  32188. */
  32189. getInternalStep(): number;
  32190. private _fogEnabled;
  32191. /**
  32192. * Gets or sets a boolean indicating if fog is enabled on this scene
  32193. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32194. * (Default is true)
  32195. */
  32196. fogEnabled: boolean;
  32197. private _fogMode;
  32198. /**
  32199. * Gets or sets the fog mode to use
  32200. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32201. * | mode | value |
  32202. * | --- | --- |
  32203. * | FOGMODE_NONE | 0 |
  32204. * | FOGMODE_EXP | 1 |
  32205. * | FOGMODE_EXP2 | 2 |
  32206. * | FOGMODE_LINEAR | 3 |
  32207. */
  32208. fogMode: number;
  32209. /**
  32210. * Gets or sets the fog color to use
  32211. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32212. * (Default is Color3(0.2, 0.2, 0.3))
  32213. */
  32214. fogColor: Color3;
  32215. /**
  32216. * Gets or sets the fog density to use
  32217. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32218. * (Default is 0.1)
  32219. */
  32220. fogDensity: number;
  32221. /**
  32222. * Gets or sets the fog start distance to use
  32223. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32224. * (Default is 0)
  32225. */
  32226. fogStart: number;
  32227. /**
  32228. * Gets or sets the fog end distance to use
  32229. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32230. * (Default is 1000)
  32231. */
  32232. fogEnd: number;
  32233. private _shadowsEnabled;
  32234. /**
  32235. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32236. */
  32237. shadowsEnabled: boolean;
  32238. private _lightsEnabled;
  32239. /**
  32240. * Gets or sets a boolean indicating if lights are enabled on this scene
  32241. */
  32242. lightsEnabled: boolean;
  32243. /** All of the active cameras added to this scene. */
  32244. activeCameras: Camera[];
  32245. private _activeCamera;
  32246. /** Gets or sets the current active camera */
  32247. activeCamera: Nullable<Camera>;
  32248. private _defaultMaterial;
  32249. /** The default material used on meshes when no material is affected */
  32250. /** The default material used on meshes when no material is affected */
  32251. defaultMaterial: Material;
  32252. private _texturesEnabled;
  32253. /**
  32254. * Gets or sets a boolean indicating if textures are enabled on this scene
  32255. */
  32256. texturesEnabled: boolean;
  32257. /**
  32258. * Gets or sets a boolean indicating if particles are enabled on this scene
  32259. */
  32260. particlesEnabled: boolean;
  32261. /**
  32262. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32263. */
  32264. spritesEnabled: boolean;
  32265. private _skeletonsEnabled;
  32266. /**
  32267. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32268. */
  32269. skeletonsEnabled: boolean;
  32270. /**
  32271. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32272. */
  32273. lensFlaresEnabled: boolean;
  32274. /**
  32275. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32276. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32277. */
  32278. collisionsEnabled: boolean;
  32279. private _collisionCoordinator;
  32280. /** @hidden */
  32281. readonly collisionCoordinator: ICollisionCoordinator;
  32282. /**
  32283. * Defines the gravity applied to this scene (used only for collisions)
  32284. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32285. */
  32286. gravity: Vector3;
  32287. /**
  32288. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32289. */
  32290. postProcessesEnabled: boolean;
  32291. /**
  32292. * The list of postprocesses added to the scene
  32293. */
  32294. postProcesses: PostProcess[];
  32295. /**
  32296. * Gets the current postprocess manager
  32297. */
  32298. postProcessManager: PostProcessManager;
  32299. /**
  32300. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32301. */
  32302. renderTargetsEnabled: boolean;
  32303. /**
  32304. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32305. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32306. */
  32307. dumpNextRenderTargets: boolean;
  32308. /**
  32309. * The list of user defined render targets added to the scene
  32310. */
  32311. customRenderTargets: RenderTargetTexture[];
  32312. /**
  32313. * Defines if texture loading must be delayed
  32314. * If true, textures will only be loaded when they need to be rendered
  32315. */
  32316. useDelayedTextureLoading: boolean;
  32317. /**
  32318. * Gets the list of meshes imported to the scene through SceneLoader
  32319. */
  32320. importedMeshesFiles: String[];
  32321. /**
  32322. * Gets or sets a boolean indicating if probes are enabled on this scene
  32323. */
  32324. probesEnabled: boolean;
  32325. /**
  32326. * Gets or sets the current offline provider to use to store scene data
  32327. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32328. */
  32329. offlineProvider: IOfflineProvider;
  32330. /**
  32331. * Gets or sets the action manager associated with the scene
  32332. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32333. */
  32334. actionManager: AbstractActionManager;
  32335. private _meshesForIntersections;
  32336. /**
  32337. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32338. */
  32339. proceduralTexturesEnabled: boolean;
  32340. private _engine;
  32341. private _totalVertices;
  32342. /** @hidden */
  32343. _activeIndices: PerfCounter;
  32344. /** @hidden */
  32345. _activeParticles: PerfCounter;
  32346. /** @hidden */
  32347. _activeBones: PerfCounter;
  32348. private _animationRatio;
  32349. /** @hidden */
  32350. _animationTimeLast: number;
  32351. /** @hidden */
  32352. _animationTime: number;
  32353. /**
  32354. * Gets or sets a general scale for animation speed
  32355. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32356. */
  32357. animationTimeScale: number;
  32358. /** @hidden */
  32359. _cachedMaterial: Nullable<Material>;
  32360. /** @hidden */
  32361. _cachedEffect: Nullable<Effect>;
  32362. /** @hidden */
  32363. _cachedVisibility: Nullable<number>;
  32364. private _renderId;
  32365. private _frameId;
  32366. private _executeWhenReadyTimeoutId;
  32367. private _intermediateRendering;
  32368. private _viewUpdateFlag;
  32369. private _projectionUpdateFlag;
  32370. private _alternateViewUpdateFlag;
  32371. private _alternateProjectionUpdateFlag;
  32372. /** @hidden */
  32373. _toBeDisposed: Nullable<IDisposable>[];
  32374. private _activeRequests;
  32375. /** @hidden */
  32376. _pendingData: any[];
  32377. private _isDisposed;
  32378. /**
  32379. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32380. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32381. */
  32382. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32383. private _activeMeshes;
  32384. private _processedMaterials;
  32385. private _renderTargets;
  32386. /** @hidden */
  32387. _activeParticleSystems: SmartArray<IParticleSystem>;
  32388. private _activeSkeletons;
  32389. private _softwareSkinnedMeshes;
  32390. private _renderingManager;
  32391. /** @hidden */
  32392. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32393. private _transformMatrix;
  32394. private _sceneUbo;
  32395. private _alternateSceneUbo;
  32396. private _viewMatrix;
  32397. private _projectionMatrix;
  32398. private _alternateViewMatrix;
  32399. private _alternateProjectionMatrix;
  32400. private _alternateTransformMatrix;
  32401. private _useAlternateCameraConfiguration;
  32402. private _alternateRendering;
  32403. private _wheelEventName;
  32404. /** @hidden */
  32405. _forcedViewPosition: Nullable<Vector3>;
  32406. /** @hidden */
  32407. readonly _isAlternateRenderingEnabled: boolean;
  32408. private _frustumPlanes;
  32409. /**
  32410. * Gets the list of frustum planes (built from the active camera)
  32411. */
  32412. readonly frustumPlanes: Plane[];
  32413. /**
  32414. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32415. * This is useful if there are more lights that the maximum simulteanous authorized
  32416. */
  32417. requireLightSorting: boolean;
  32418. /** @hidden */
  32419. readonly useMaterialMeshMap: boolean;
  32420. /** @hidden */
  32421. readonly useClonedMeshhMap: boolean;
  32422. private _pointerOverMesh;
  32423. private _pickedDownMesh;
  32424. private _pickedUpMesh;
  32425. private _externalData;
  32426. private _uid;
  32427. /**
  32428. * @hidden
  32429. * Backing store of defined scene components.
  32430. */
  32431. _components: ISceneComponent[];
  32432. /**
  32433. * @hidden
  32434. * Backing store of defined scene components.
  32435. */
  32436. _serializableComponents: ISceneSerializableComponent[];
  32437. /**
  32438. * List of components to register on the next registration step.
  32439. */
  32440. private _transientComponents;
  32441. /**
  32442. * Registers the transient components if needed.
  32443. */
  32444. private _registerTransientComponents;
  32445. /**
  32446. * @hidden
  32447. * Add a component to the scene.
  32448. * Note that the ccomponent could be registered on th next frame if this is called after
  32449. * the register component stage.
  32450. * @param component Defines the component to add to the scene
  32451. */
  32452. _addComponent(component: ISceneComponent): void;
  32453. /**
  32454. * @hidden
  32455. * Gets a component from the scene.
  32456. * @param name defines the name of the component to retrieve
  32457. * @returns the component or null if not present
  32458. */
  32459. _getComponent(name: string): Nullable<ISceneComponent>;
  32460. /**
  32461. * @hidden
  32462. * Defines the actions happening before camera updates.
  32463. */
  32464. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32465. /**
  32466. * @hidden
  32467. * Defines the actions happening before clear the canvas.
  32468. */
  32469. _beforeClearStage: Stage<SimpleStageAction>;
  32470. /**
  32471. * @hidden
  32472. * Defines the actions when collecting render targets for the frame.
  32473. */
  32474. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32475. /**
  32476. * @hidden
  32477. * Defines the actions happening for one camera in the frame.
  32478. */
  32479. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32480. /**
  32481. * @hidden
  32482. * Defines the actions happening during the per mesh ready checks.
  32483. */
  32484. _isReadyForMeshStage: Stage<MeshStageAction>;
  32485. /**
  32486. * @hidden
  32487. * Defines the actions happening before evaluate active mesh checks.
  32488. */
  32489. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32490. /**
  32491. * @hidden
  32492. * Defines the actions happening during the evaluate sub mesh checks.
  32493. */
  32494. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32495. /**
  32496. * @hidden
  32497. * Defines the actions happening during the active mesh stage.
  32498. */
  32499. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32500. /**
  32501. * @hidden
  32502. * Defines the actions happening during the per camera render target step.
  32503. */
  32504. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32505. /**
  32506. * @hidden
  32507. * Defines the actions happening just before the active camera is drawing.
  32508. */
  32509. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32510. /**
  32511. * @hidden
  32512. * Defines the actions happening just before a render target is drawing.
  32513. */
  32514. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32515. /**
  32516. * @hidden
  32517. * Defines the actions happening just before a rendering group is drawing.
  32518. */
  32519. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32520. /**
  32521. * @hidden
  32522. * Defines the actions happening just before a mesh is drawing.
  32523. */
  32524. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32525. /**
  32526. * @hidden
  32527. * Defines the actions happening just after a mesh has been drawn.
  32528. */
  32529. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32530. /**
  32531. * @hidden
  32532. * Defines the actions happening just after a rendering group has been drawn.
  32533. */
  32534. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32535. /**
  32536. * @hidden
  32537. * Defines the actions happening just after the active camera has been drawn.
  32538. */
  32539. _afterCameraDrawStage: Stage<CameraStageAction>;
  32540. /**
  32541. * @hidden
  32542. * Defines the actions happening just after a render target has been drawn.
  32543. */
  32544. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32545. /**
  32546. * @hidden
  32547. * Defines the actions happening just after rendering all cameras and computing intersections.
  32548. */
  32549. _afterRenderStage: Stage<SimpleStageAction>;
  32550. /**
  32551. * @hidden
  32552. * Defines the actions happening when a pointer move event happens.
  32553. */
  32554. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32555. /**
  32556. * @hidden
  32557. * Defines the actions happening when a pointer down event happens.
  32558. */
  32559. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32560. /**
  32561. * @hidden
  32562. * Defines the actions happening when a pointer up event happens.
  32563. */
  32564. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32565. /**
  32566. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32567. */
  32568. private geometriesByUniqueId;
  32569. /**
  32570. * Creates a new Scene
  32571. * @param engine defines the engine to use to render this scene
  32572. * @param options defines the scene options
  32573. */
  32574. constructor(engine: Engine, options?: SceneOptions);
  32575. private _defaultMeshCandidates;
  32576. /**
  32577. * @hidden
  32578. */
  32579. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32580. private _defaultSubMeshCandidates;
  32581. /**
  32582. * @hidden
  32583. */
  32584. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32585. /**
  32586. * Sets the default candidate providers for the scene.
  32587. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32588. * and getCollidingSubMeshCandidates to their default function
  32589. */
  32590. setDefaultCandidateProviders(): void;
  32591. /**
  32592. * Gets the mesh that is currently under the pointer
  32593. */
  32594. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32595. /**
  32596. * Gets or sets the current on-screen X position of the pointer
  32597. */
  32598. pointerX: number;
  32599. /**
  32600. * Gets or sets the current on-screen Y position of the pointer
  32601. */
  32602. pointerY: number;
  32603. /**
  32604. * Gets the cached material (ie. the latest rendered one)
  32605. * @returns the cached material
  32606. */
  32607. getCachedMaterial(): Nullable<Material>;
  32608. /**
  32609. * Gets the cached effect (ie. the latest rendered one)
  32610. * @returns the cached effect
  32611. */
  32612. getCachedEffect(): Nullable<Effect>;
  32613. /**
  32614. * Gets the cached visibility state (ie. the latest rendered one)
  32615. * @returns the cached visibility state
  32616. */
  32617. getCachedVisibility(): Nullable<number>;
  32618. /**
  32619. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32620. * @param material defines the current material
  32621. * @param effect defines the current effect
  32622. * @param visibility defines the current visibility state
  32623. * @returns true if one parameter is not cached
  32624. */
  32625. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32626. /**
  32627. * Gets the engine associated with the scene
  32628. * @returns an Engine
  32629. */
  32630. getEngine(): Engine;
  32631. /**
  32632. * Gets the total number of vertices rendered per frame
  32633. * @returns the total number of vertices rendered per frame
  32634. */
  32635. getTotalVertices(): number;
  32636. /**
  32637. * Gets the performance counter for total vertices
  32638. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32639. */
  32640. readonly totalVerticesPerfCounter: PerfCounter;
  32641. /**
  32642. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32643. * @returns the total number of active indices rendered per frame
  32644. */
  32645. getActiveIndices(): number;
  32646. /**
  32647. * Gets the performance counter for active indices
  32648. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32649. */
  32650. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32651. /**
  32652. * Gets the total number of active particles rendered per frame
  32653. * @returns the total number of active particles rendered per frame
  32654. */
  32655. getActiveParticles(): number;
  32656. /**
  32657. * Gets the performance counter for active particles
  32658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32659. */
  32660. readonly activeParticlesPerfCounter: PerfCounter;
  32661. /**
  32662. * Gets the total number of active bones rendered per frame
  32663. * @returns the total number of active bones rendered per frame
  32664. */
  32665. getActiveBones(): number;
  32666. /**
  32667. * Gets the performance counter for active bones
  32668. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32669. */
  32670. readonly activeBonesPerfCounter: PerfCounter;
  32671. /**
  32672. * Gets the array of active meshes
  32673. * @returns an array of AbstractMesh
  32674. */
  32675. getActiveMeshes(): SmartArray<AbstractMesh>;
  32676. /**
  32677. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32678. * @returns a number
  32679. */
  32680. getAnimationRatio(): number;
  32681. /**
  32682. * Gets an unique Id for the current render phase
  32683. * @returns a number
  32684. */
  32685. getRenderId(): number;
  32686. /**
  32687. * Gets an unique Id for the current frame
  32688. * @returns a number
  32689. */
  32690. getFrameId(): number;
  32691. /** Call this function if you want to manually increment the render Id*/
  32692. incrementRenderId(): void;
  32693. private _updatePointerPosition;
  32694. private _createUbo;
  32695. private _createAlternateUbo;
  32696. private _setRayOnPointerInfo;
  32697. /**
  32698. * Use this method to simulate a pointer move on a mesh
  32699. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32700. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32701. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32702. * @returns the current scene
  32703. */
  32704. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32705. private _processPointerMove;
  32706. private _checkPrePointerObservable;
  32707. /**
  32708. * Use this method to simulate a pointer down on a mesh
  32709. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32710. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32711. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32712. * @returns the current scene
  32713. */
  32714. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32715. private _processPointerDown;
  32716. /**
  32717. * Use this method to simulate a pointer up on a mesh
  32718. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32719. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32720. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32721. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32722. * @returns the current scene
  32723. */
  32724. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32725. private _processPointerUp;
  32726. /**
  32727. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32728. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32729. * @returns true if the pointer was captured
  32730. */
  32731. isPointerCaptured(pointerId?: number): boolean;
  32732. /** @hidden */
  32733. _isPointerSwiping(): boolean;
  32734. /**
  32735. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32736. * @param attachUp defines if you want to attach events to pointerup
  32737. * @param attachDown defines if you want to attach events to pointerdown
  32738. * @param attachMove defines if you want to attach events to pointermove
  32739. */
  32740. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32741. /** Detaches all event handlers*/
  32742. detachControl(): void;
  32743. /**
  32744. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32745. * Delay loaded resources are not taking in account
  32746. * @return true if all required resources are ready
  32747. */
  32748. isReady(): boolean;
  32749. /** Resets all cached information relative to material (including effect and visibility) */
  32750. resetCachedMaterial(): void;
  32751. /**
  32752. * Registers a function to be called before every frame render
  32753. * @param func defines the function to register
  32754. */
  32755. registerBeforeRender(func: () => void): void;
  32756. /**
  32757. * Unregisters a function called before every frame render
  32758. * @param func defines the function to unregister
  32759. */
  32760. unregisterBeforeRender(func: () => void): void;
  32761. /**
  32762. * Registers a function to be called after every frame render
  32763. * @param func defines the function to register
  32764. */
  32765. registerAfterRender(func: () => void): void;
  32766. /**
  32767. * Unregisters a function called after every frame render
  32768. * @param func defines the function to unregister
  32769. */
  32770. unregisterAfterRender(func: () => void): void;
  32771. private _executeOnceBeforeRender;
  32772. /**
  32773. * The provided function will run before render once and will be disposed afterwards.
  32774. * A timeout delay can be provided so that the function will be executed in N ms.
  32775. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32776. * @param func The function to be executed.
  32777. * @param timeout optional delay in ms
  32778. */
  32779. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32780. /** @hidden */
  32781. _addPendingData(data: any): void;
  32782. /** @hidden */
  32783. _removePendingData(data: any): void;
  32784. /**
  32785. * Returns the number of items waiting to be loaded
  32786. * @returns the number of items waiting to be loaded
  32787. */
  32788. getWaitingItemsCount(): number;
  32789. /**
  32790. * Returns a boolean indicating if the scene is still loading data
  32791. */
  32792. readonly isLoading: boolean;
  32793. /**
  32794. * Registers a function to be executed when the scene is ready
  32795. * @param {Function} func - the function to be executed
  32796. */
  32797. executeWhenReady(func: () => void): void;
  32798. /**
  32799. * Returns a promise that resolves when the scene is ready
  32800. * @returns A promise that resolves when the scene is ready
  32801. */
  32802. whenReadyAsync(): Promise<void>;
  32803. /** @hidden */
  32804. _checkIsReady(): void;
  32805. /**
  32806. * Gets all animatable attached to the scene
  32807. */
  32808. readonly animatables: Animatable[];
  32809. /**
  32810. * Resets the last animation time frame.
  32811. * Useful to override when animations start running when loading a scene for the first time.
  32812. */
  32813. resetLastAnimationTimeFrame(): void;
  32814. /** @hidden */
  32815. _switchToAlternateCameraConfiguration(active: boolean): void;
  32816. /**
  32817. * Gets the current view matrix
  32818. * @returns a Matrix
  32819. */
  32820. getViewMatrix(): Matrix;
  32821. /**
  32822. * Gets the current projection matrix
  32823. * @returns a Matrix
  32824. */
  32825. getProjectionMatrix(): Matrix;
  32826. /**
  32827. * Gets the current transform matrix
  32828. * @returns a Matrix made of View * Projection
  32829. */
  32830. getTransformMatrix(): Matrix;
  32831. /**
  32832. * Sets the current transform matrix
  32833. * @param view defines the View matrix to use
  32834. * @param projection defines the Projection matrix to use
  32835. */
  32836. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32837. /** @hidden */
  32838. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32839. /**
  32840. * Gets the uniform buffer used to store scene data
  32841. * @returns a UniformBuffer
  32842. */
  32843. getSceneUniformBuffer(): UniformBuffer;
  32844. /**
  32845. * Gets an unique (relatively to the current scene) Id
  32846. * @returns an unique number for the scene
  32847. */
  32848. getUniqueId(): number;
  32849. /**
  32850. * Add a mesh to the list of scene's meshes
  32851. * @param newMesh defines the mesh to add
  32852. * @param recursive if all child meshes should also be added to the scene
  32853. */
  32854. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32855. /**
  32856. * Remove a mesh for the list of scene's meshes
  32857. * @param toRemove defines the mesh to remove
  32858. * @param recursive if all child meshes should also be removed from the scene
  32859. * @returns the index where the mesh was in the mesh list
  32860. */
  32861. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32862. /**
  32863. * Add a transform node to the list of scene's transform nodes
  32864. * @param newTransformNode defines the transform node to add
  32865. */
  32866. addTransformNode(newTransformNode: TransformNode): void;
  32867. /**
  32868. * Remove a transform node for the list of scene's transform nodes
  32869. * @param toRemove defines the transform node to remove
  32870. * @returns the index where the transform node was in the transform node list
  32871. */
  32872. removeTransformNode(toRemove: TransformNode): number;
  32873. /**
  32874. * Remove a skeleton for the list of scene's skeletons
  32875. * @param toRemove defines the skeleton to remove
  32876. * @returns the index where the skeleton was in the skeleton list
  32877. */
  32878. removeSkeleton(toRemove: Skeleton): number;
  32879. /**
  32880. * Remove a morph target for the list of scene's morph targets
  32881. * @param toRemove defines the morph target to remove
  32882. * @returns the index where the morph target was in the morph target list
  32883. */
  32884. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32885. /**
  32886. * Remove a light for the list of scene's lights
  32887. * @param toRemove defines the light to remove
  32888. * @returns the index where the light was in the light list
  32889. */
  32890. removeLight(toRemove: Light): number;
  32891. /**
  32892. * Remove a camera for the list of scene's cameras
  32893. * @param toRemove defines the camera to remove
  32894. * @returns the index where the camera was in the camera list
  32895. */
  32896. removeCamera(toRemove: Camera): number;
  32897. /**
  32898. * Remove a particle system for the list of scene's particle systems
  32899. * @param toRemove defines the particle system to remove
  32900. * @returns the index where the particle system was in the particle system list
  32901. */
  32902. removeParticleSystem(toRemove: IParticleSystem): number;
  32903. /**
  32904. * Remove a animation for the list of scene's animations
  32905. * @param toRemove defines the animation to remove
  32906. * @returns the index where the animation was in the animation list
  32907. */
  32908. removeAnimation(toRemove: Animation): number;
  32909. /**
  32910. * Removes the given animation group from this scene.
  32911. * @param toRemove The animation group to remove
  32912. * @returns The index of the removed animation group
  32913. */
  32914. removeAnimationGroup(toRemove: AnimationGroup): number;
  32915. /**
  32916. * Removes the given multi-material from this scene.
  32917. * @param toRemove The multi-material to remove
  32918. * @returns The index of the removed multi-material
  32919. */
  32920. removeMultiMaterial(toRemove: MultiMaterial): number;
  32921. /**
  32922. * Removes the given material from this scene.
  32923. * @param toRemove The material to remove
  32924. * @returns The index of the removed material
  32925. */
  32926. removeMaterial(toRemove: Material): number;
  32927. /**
  32928. * Removes the given action manager from this scene.
  32929. * @param toRemove The action manager to remove
  32930. * @returns The index of the removed action manager
  32931. */
  32932. removeActionManager(toRemove: AbstractActionManager): number;
  32933. /**
  32934. * Removes the given texture from this scene.
  32935. * @param toRemove The texture to remove
  32936. * @returns The index of the removed texture
  32937. */
  32938. removeTexture(toRemove: BaseTexture): number;
  32939. /**
  32940. * Adds the given light to this scene
  32941. * @param newLight The light to add
  32942. */
  32943. addLight(newLight: Light): void;
  32944. /**
  32945. * Sorts the list list based on light priorities
  32946. */
  32947. sortLightsByPriority(): void;
  32948. /**
  32949. * Adds the given camera to this scene
  32950. * @param newCamera The camera to add
  32951. */
  32952. addCamera(newCamera: Camera): void;
  32953. /**
  32954. * Adds the given skeleton to this scene
  32955. * @param newSkeleton The skeleton to add
  32956. */
  32957. addSkeleton(newSkeleton: Skeleton): void;
  32958. /**
  32959. * Adds the given particle system to this scene
  32960. * @param newParticleSystem The particle system to add
  32961. */
  32962. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32963. /**
  32964. * Adds the given animation to this scene
  32965. * @param newAnimation The animation to add
  32966. */
  32967. addAnimation(newAnimation: Animation): void;
  32968. /**
  32969. * Adds the given animation group to this scene.
  32970. * @param newAnimationGroup The animation group to add
  32971. */
  32972. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32973. /**
  32974. * Adds the given multi-material to this scene
  32975. * @param newMultiMaterial The multi-material to add
  32976. */
  32977. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32978. /**
  32979. * Adds the given material to this scene
  32980. * @param newMaterial The material to add
  32981. */
  32982. addMaterial(newMaterial: Material): void;
  32983. /**
  32984. * Adds the given morph target to this scene
  32985. * @param newMorphTargetManager The morph target to add
  32986. */
  32987. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32988. /**
  32989. * Adds the given geometry to this scene
  32990. * @param newGeometry The geometry to add
  32991. */
  32992. addGeometry(newGeometry: Geometry): void;
  32993. /**
  32994. * Adds the given action manager to this scene
  32995. * @param newActionManager The action manager to add
  32996. */
  32997. addActionManager(newActionManager: AbstractActionManager): void;
  32998. /**
  32999. * Adds the given texture to this scene.
  33000. * @param newTexture The texture to add
  33001. */
  33002. addTexture(newTexture: BaseTexture): void;
  33003. /**
  33004. * Switch active camera
  33005. * @param newCamera defines the new active camera
  33006. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33007. */
  33008. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33009. /**
  33010. * sets the active camera of the scene using its ID
  33011. * @param id defines the camera's ID
  33012. * @return the new active camera or null if none found.
  33013. */
  33014. setActiveCameraByID(id: string): Nullable<Camera>;
  33015. /**
  33016. * sets the active camera of the scene using its name
  33017. * @param name defines the camera's name
  33018. * @returns the new active camera or null if none found.
  33019. */
  33020. setActiveCameraByName(name: string): Nullable<Camera>;
  33021. /**
  33022. * get an animation group using its name
  33023. * @param name defines the material's name
  33024. * @return the animation group or null if none found.
  33025. */
  33026. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33027. /**
  33028. * get a material using its id
  33029. * @param id defines the material's ID
  33030. * @return the material or null if none found.
  33031. */
  33032. getMaterialByID(id: string): Nullable<Material>;
  33033. /**
  33034. * Gets a material using its name
  33035. * @param name defines the material's name
  33036. * @return the material or null if none found.
  33037. */
  33038. getMaterialByName(name: string): Nullable<Material>;
  33039. /**
  33040. * Gets a camera using its id
  33041. * @param id defines the id to look for
  33042. * @returns the camera or null if not found
  33043. */
  33044. getCameraByID(id: string): Nullable<Camera>;
  33045. /**
  33046. * Gets a camera using its unique id
  33047. * @param uniqueId defines the unique id to look for
  33048. * @returns the camera or null if not found
  33049. */
  33050. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33051. /**
  33052. * Gets a camera using its name
  33053. * @param name defines the camera's name
  33054. * @return the camera or null if none found.
  33055. */
  33056. getCameraByName(name: string): Nullable<Camera>;
  33057. /**
  33058. * Gets a bone using its id
  33059. * @param id defines the bone's id
  33060. * @return the bone or null if not found
  33061. */
  33062. getBoneByID(id: string): Nullable<Bone>;
  33063. /**
  33064. * Gets a bone using its id
  33065. * @param name defines the bone's name
  33066. * @return the bone or null if not found
  33067. */
  33068. getBoneByName(name: string): Nullable<Bone>;
  33069. /**
  33070. * Gets a light node using its name
  33071. * @param name defines the the light's name
  33072. * @return the light or null if none found.
  33073. */
  33074. getLightByName(name: string): Nullable<Light>;
  33075. /**
  33076. * Gets a light node using its id
  33077. * @param id defines the light's id
  33078. * @return the light or null if none found.
  33079. */
  33080. getLightByID(id: string): Nullable<Light>;
  33081. /**
  33082. * Gets a light node using its scene-generated unique ID
  33083. * @param uniqueId defines the light's unique id
  33084. * @return the light or null if none found.
  33085. */
  33086. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33087. /**
  33088. * Gets a particle system by id
  33089. * @param id defines the particle system id
  33090. * @return the corresponding system or null if none found
  33091. */
  33092. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33093. /**
  33094. * Gets a geometry using its ID
  33095. * @param id defines the geometry's id
  33096. * @return the geometry or null if none found.
  33097. */
  33098. getGeometryByID(id: string): Nullable<Geometry>;
  33099. private _getGeometryByUniqueID;
  33100. /**
  33101. * Add a new geometry to this scene
  33102. * @param geometry defines the geometry to be added to the scene.
  33103. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33104. * @return a boolean defining if the geometry was added or not
  33105. */
  33106. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33107. /**
  33108. * Removes an existing geometry
  33109. * @param geometry defines the geometry to be removed from the scene
  33110. * @return a boolean defining if the geometry was removed or not
  33111. */
  33112. removeGeometry(geometry: Geometry): boolean;
  33113. /**
  33114. * Gets the list of geometries attached to the scene
  33115. * @returns an array of Geometry
  33116. */
  33117. getGeometries(): Geometry[];
  33118. /**
  33119. * Gets the first added mesh found of a given ID
  33120. * @param id defines the id to search for
  33121. * @return the mesh found or null if not found at all
  33122. */
  33123. getMeshByID(id: string): Nullable<AbstractMesh>;
  33124. /**
  33125. * Gets a list of meshes using their id
  33126. * @param id defines the id to search for
  33127. * @returns a list of meshes
  33128. */
  33129. getMeshesByID(id: string): Array<AbstractMesh>;
  33130. /**
  33131. * Gets the first added transform node found of a given ID
  33132. * @param id defines the id to search for
  33133. * @return the found transform node or null if not found at all.
  33134. */
  33135. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33136. /**
  33137. * Gets a list of transform nodes using their id
  33138. * @param id defines the id to search for
  33139. * @returns a list of transform nodes
  33140. */
  33141. getTransformNodesByID(id: string): Array<TransformNode>;
  33142. /**
  33143. * Gets a mesh with its auto-generated unique id
  33144. * @param uniqueId defines the unique id to search for
  33145. * @return the found mesh or null if not found at all.
  33146. */
  33147. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33148. /**
  33149. * Gets a the last added mesh using a given id
  33150. * @param id defines the id to search for
  33151. * @return the found mesh or null if not found at all.
  33152. */
  33153. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33154. /**
  33155. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33156. * @param id defines the id to search for
  33157. * @return the found node or null if not found at all
  33158. */
  33159. getLastEntryByID(id: string): Nullable<Node>;
  33160. /**
  33161. * Gets a node (Mesh, Camera, Light) using a given id
  33162. * @param id defines the id to search for
  33163. * @return the found node or null if not found at all
  33164. */
  33165. getNodeByID(id: string): Nullable<Node>;
  33166. /**
  33167. * Gets a node (Mesh, Camera, Light) using a given name
  33168. * @param name defines the name to search for
  33169. * @return the found node or null if not found at all.
  33170. */
  33171. getNodeByName(name: string): Nullable<Node>;
  33172. /**
  33173. * Gets a mesh using a given name
  33174. * @param name defines the name to search for
  33175. * @return the found mesh or null if not found at all.
  33176. */
  33177. getMeshByName(name: string): Nullable<AbstractMesh>;
  33178. /**
  33179. * Gets a transform node using a given name
  33180. * @param name defines the name to search for
  33181. * @return the found transform node or null if not found at all.
  33182. */
  33183. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33184. /**
  33185. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33186. * @param id defines the id to search for
  33187. * @return the found skeleton or null if not found at all.
  33188. */
  33189. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33190. /**
  33191. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33192. * @param id defines the id to search for
  33193. * @return the found skeleton or null if not found at all.
  33194. */
  33195. getSkeletonById(id: string): Nullable<Skeleton>;
  33196. /**
  33197. * Gets a skeleton using a given name
  33198. * @param name defines the name to search for
  33199. * @return the found skeleton or null if not found at all.
  33200. */
  33201. getSkeletonByName(name: string): Nullable<Skeleton>;
  33202. /**
  33203. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33204. * @param id defines the id to search for
  33205. * @return the found morph target manager or null if not found at all.
  33206. */
  33207. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33208. /**
  33209. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33210. * @param id defines the id to search for
  33211. * @return the found morph target or null if not found at all.
  33212. */
  33213. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33214. /**
  33215. * Gets a boolean indicating if the given mesh is active
  33216. * @param mesh defines the mesh to look for
  33217. * @returns true if the mesh is in the active list
  33218. */
  33219. isActiveMesh(mesh: AbstractMesh): boolean;
  33220. /**
  33221. * Return a unique id as a string which can serve as an identifier for the scene
  33222. */
  33223. readonly uid: string;
  33224. /**
  33225. * Add an externaly attached data from its key.
  33226. * This method call will fail and return false, if such key already exists.
  33227. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33228. * @param key the unique key that identifies the data
  33229. * @param data the data object to associate to the key for this Engine instance
  33230. * @return true if no such key were already present and the data was added successfully, false otherwise
  33231. */
  33232. addExternalData<T>(key: string, data: T): boolean;
  33233. /**
  33234. * Get an externaly attached data from its key
  33235. * @param key the unique key that identifies the data
  33236. * @return the associated data, if present (can be null), or undefined if not present
  33237. */
  33238. getExternalData<T>(key: string): Nullable<T>;
  33239. /**
  33240. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33241. * @param key the unique key that identifies the data
  33242. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33243. * @return the associated data, can be null if the factory returned null.
  33244. */
  33245. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33246. /**
  33247. * Remove an externaly attached data from the Engine instance
  33248. * @param key the unique key that identifies the data
  33249. * @return true if the data was successfully removed, false if it doesn't exist
  33250. */
  33251. removeExternalData(key: string): boolean;
  33252. private _evaluateSubMesh;
  33253. /**
  33254. * Clear the processed materials smart array preventing retention point in material dispose.
  33255. */
  33256. freeProcessedMaterials(): void;
  33257. private _preventFreeActiveMeshesAndRenderingGroups;
  33258. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33259. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33260. * when disposing several meshes in a row or a hierarchy of meshes.
  33261. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33262. */
  33263. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33264. /**
  33265. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33266. */
  33267. freeActiveMeshes(): void;
  33268. /**
  33269. * Clear the info related to rendering groups preventing retention points during dispose.
  33270. */
  33271. freeRenderingGroups(): void;
  33272. /** @hidden */
  33273. _isInIntermediateRendering(): boolean;
  33274. /**
  33275. * Lambda returning the list of potentially active meshes.
  33276. */
  33277. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33278. /**
  33279. * Lambda returning the list of potentially active sub meshes.
  33280. */
  33281. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33282. /**
  33283. * Lambda returning the list of potentially intersecting sub meshes.
  33284. */
  33285. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33286. /**
  33287. * Lambda returning the list of potentially colliding sub meshes.
  33288. */
  33289. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33290. private _activeMeshesFrozen;
  33291. /**
  33292. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33293. * @returns the current scene
  33294. */
  33295. freezeActiveMeshes(): Scene;
  33296. /**
  33297. * Use this function to restart evaluating active meshes on every frame
  33298. * @returns the current scene
  33299. */
  33300. unfreezeActiveMeshes(): Scene;
  33301. private _evaluateActiveMeshes;
  33302. private _activeMesh;
  33303. /**
  33304. * Update the transform matrix to update from the current active camera
  33305. * @param force defines a boolean used to force the update even if cache is up to date
  33306. */
  33307. updateTransformMatrix(force?: boolean): void;
  33308. /**
  33309. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  33310. * @param alternateCamera defines the camera to use
  33311. */
  33312. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33313. /** @hidden */
  33314. _allowPostProcessClearColor: boolean;
  33315. private _renderForCamera;
  33316. private _processSubCameras;
  33317. private _checkIntersections;
  33318. /** @hidden */
  33319. _advancePhysicsEngineStep(step: number): void;
  33320. /**
  33321. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33322. */
  33323. getDeterministicFrameTime: () => number;
  33324. /** @hidden */
  33325. _animate(): void;
  33326. /**
  33327. * Render the scene
  33328. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33329. */
  33330. render(updateCameras?: boolean): void;
  33331. /**
  33332. * Freeze all materials
  33333. * A frozen material will not be updatable but should be faster to render
  33334. */
  33335. freezeMaterials(): void;
  33336. /**
  33337. * Unfreeze all materials
  33338. * A frozen material will not be updatable but should be faster to render
  33339. */
  33340. unfreezeMaterials(): void;
  33341. /**
  33342. * Releases all held ressources
  33343. */
  33344. dispose(): void;
  33345. /**
  33346. * Gets if the scene is already disposed
  33347. */
  33348. readonly isDisposed: boolean;
  33349. /**
  33350. * Call this function to reduce memory footprint of the scene.
  33351. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33352. */
  33353. clearCachedVertexData(): void;
  33354. /**
  33355. * This function will remove the local cached buffer data from texture.
  33356. * It will save memory but will prevent the texture from being rebuilt
  33357. */
  33358. cleanCachedTextureBuffer(): void;
  33359. /**
  33360. * Get the world extend vectors with an optional filter
  33361. *
  33362. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33363. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33364. */
  33365. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33366. min: Vector3;
  33367. max: Vector3;
  33368. };
  33369. /**
  33370. * Creates a ray that can be used to pick in the scene
  33371. * @param x defines the x coordinate of the origin (on-screen)
  33372. * @param y defines the y coordinate of the origin (on-screen)
  33373. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33374. * @param camera defines the camera to use for the picking
  33375. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33376. * @returns a Ray
  33377. */
  33378. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33379. /**
  33380. * Creates a ray that can be used to pick in the scene
  33381. * @param x defines the x coordinate of the origin (on-screen)
  33382. * @param y defines the y coordinate of the origin (on-screen)
  33383. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33384. * @param result defines the ray where to store the picking ray
  33385. * @param camera defines the camera to use for the picking
  33386. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33387. * @returns the current scene
  33388. */
  33389. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33390. /**
  33391. * Creates a ray that can be used to pick in the scene
  33392. * @param x defines the x coordinate of the origin (on-screen)
  33393. * @param y defines the y coordinate of the origin (on-screen)
  33394. * @param camera defines the camera to use for the picking
  33395. * @returns a Ray
  33396. */
  33397. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33398. /**
  33399. * Creates a ray that can be used to pick in the scene
  33400. * @param x defines the x coordinate of the origin (on-screen)
  33401. * @param y defines the y coordinate of the origin (on-screen)
  33402. * @param result defines the ray where to store the picking ray
  33403. * @param camera defines the camera to use for the picking
  33404. * @returns the current scene
  33405. */
  33406. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33407. /** Launch a ray to try to pick a mesh in the scene
  33408. * @param x position on screen
  33409. * @param y position on screen
  33410. * @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
  33411. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33412. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33413. * @returns a PickingInfo
  33414. */
  33415. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  33416. /** Use the given ray to pick a mesh in the scene
  33417. * @param ray The ray to use to pick meshes
  33418. * @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
  33419. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33420. * @returns a PickingInfo
  33421. */
  33422. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  33423. /**
  33424. * Launch a ray to try to pick a mesh in the scene
  33425. * @param x X position on screen
  33426. * @param y Y position on screen
  33427. * @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
  33428. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33429. * @returns an array of PickingInfo
  33430. */
  33431. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  33432. /**
  33433. * Launch a ray to try to pick a mesh in the scene
  33434. * @param ray Ray to use
  33435. * @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
  33436. * @returns an array of PickingInfo
  33437. */
  33438. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  33439. /**
  33440. * Force the value of meshUnderPointer
  33441. * @param mesh defines the mesh to use
  33442. */
  33443. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33444. /**
  33445. * Gets the mesh under the pointer
  33446. * @returns a Mesh or null if no mesh is under the pointer
  33447. */
  33448. getPointerOverMesh(): Nullable<AbstractMesh>;
  33449. /** @hidden */
  33450. _rebuildGeometries(): void;
  33451. /** @hidden */
  33452. _rebuildTextures(): void;
  33453. private _getByTags;
  33454. /**
  33455. * Get a list of meshes by tags
  33456. * @param tagsQuery defines the tags query to use
  33457. * @param forEach defines a predicate used to filter results
  33458. * @returns an array of Mesh
  33459. */
  33460. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33461. /**
  33462. * Get a list of cameras by tags
  33463. * @param tagsQuery defines the tags query to use
  33464. * @param forEach defines a predicate used to filter results
  33465. * @returns an array of Camera
  33466. */
  33467. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33468. /**
  33469. * Get a list of lights by tags
  33470. * @param tagsQuery defines the tags query to use
  33471. * @param forEach defines a predicate used to filter results
  33472. * @returns an array of Light
  33473. */
  33474. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33475. /**
  33476. * Get a list of materials by tags
  33477. * @param tagsQuery defines the tags query to use
  33478. * @param forEach defines a predicate used to filter results
  33479. * @returns an array of Material
  33480. */
  33481. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33482. /**
  33483. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33484. * This allowed control for front to back rendering or reversly depending of the special needs.
  33485. *
  33486. * @param renderingGroupId The rendering group id corresponding to its index
  33487. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33488. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33489. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33490. */
  33491. 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;
  33492. /**
  33493. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33494. *
  33495. * @param renderingGroupId The rendering group id corresponding to its index
  33496. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33497. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33498. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33499. */
  33500. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33501. /**
  33502. * Gets the current auto clear configuration for one rendering group of the rendering
  33503. * manager.
  33504. * @param index the rendering group index to get the information for
  33505. * @returns The auto clear setup for the requested rendering group
  33506. */
  33507. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33508. private _blockMaterialDirtyMechanism;
  33509. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33510. blockMaterialDirtyMechanism: boolean;
  33511. /**
  33512. * Will flag all materials as dirty to trigger new shader compilation
  33513. * @param flag defines the flag used to specify which material part must be marked as dirty
  33514. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33515. */
  33516. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33517. /** @hidden */
  33518. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  33519. /** @hidden */
  33520. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33521. }
  33522. }
  33523. declare module "babylonjs/assetContainer" {
  33524. import { AbstractScene } from "babylonjs/abstractScene";
  33525. import { Scene } from "babylonjs/scene";
  33526. import { Mesh } from "babylonjs/Meshes/mesh";
  33527. /**
  33528. * Set of assets to keep when moving a scene into an asset container.
  33529. */
  33530. export class KeepAssets extends AbstractScene {
  33531. }
  33532. /**
  33533. * Container with a set of assets that can be added or removed from a scene.
  33534. */
  33535. export class AssetContainer extends AbstractScene {
  33536. /**
  33537. * The scene the AssetContainer belongs to.
  33538. */
  33539. scene: Scene;
  33540. /**
  33541. * Instantiates an AssetContainer.
  33542. * @param scene The scene the AssetContainer belongs to.
  33543. */
  33544. constructor(scene: Scene);
  33545. /**
  33546. * Adds all the assets from the container to the scene.
  33547. */
  33548. addAllToScene(): void;
  33549. /**
  33550. * Removes all the assets in the container from the scene
  33551. */
  33552. removeAllFromScene(): void;
  33553. /**
  33554. * Disposes all the assets in the container
  33555. */
  33556. dispose(): void;
  33557. private _moveAssets;
  33558. /**
  33559. * Removes all the assets contained in the scene and adds them to the container.
  33560. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33561. */
  33562. moveAllFromScene(keepAssets?: KeepAssets): void;
  33563. /**
  33564. * 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.
  33565. * @returns the root mesh
  33566. */
  33567. createRootMesh(): Mesh;
  33568. }
  33569. }
  33570. declare module "babylonjs/abstractScene" {
  33571. import { Scene } from "babylonjs/scene";
  33572. import { Nullable } from "babylonjs/types";
  33573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33574. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33575. import { Geometry } from "babylonjs/Meshes/geometry";
  33576. import { Skeleton } from "babylonjs/Bones/skeleton";
  33577. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33578. import { AssetContainer } from "babylonjs/assetContainer";
  33579. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33580. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33581. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33582. import { Material } from "babylonjs/Materials/material";
  33583. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33584. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33585. import { Camera } from "babylonjs/Cameras/camera";
  33586. import { Light } from "babylonjs/Lights/light";
  33587. import { Node } from "babylonjs/node";
  33588. import { Animation } from "babylonjs/Animations/animation";
  33589. /**
  33590. * Defines how the parser contract is defined.
  33591. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33592. */
  33593. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33594. /**
  33595. * Defines how the individual parser contract is defined.
  33596. * These parser can parse an individual asset
  33597. */
  33598. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33599. /**
  33600. * Base class of the scene acting as a container for the different elements composing a scene.
  33601. * This class is dynamically extended by the different components of the scene increasing
  33602. * flexibility and reducing coupling
  33603. */
  33604. export abstract class AbstractScene {
  33605. /**
  33606. * Stores the list of available parsers in the application.
  33607. */
  33608. private static _BabylonFileParsers;
  33609. /**
  33610. * Stores the list of available individual parsers in the application.
  33611. */
  33612. private static _IndividualBabylonFileParsers;
  33613. /**
  33614. * Adds a parser in the list of available ones
  33615. * @param name Defines the name of the parser
  33616. * @param parser Defines the parser to add
  33617. */
  33618. static AddParser(name: string, parser: BabylonFileParser): void;
  33619. /**
  33620. * Gets a general parser from the list of avaialble ones
  33621. * @param name Defines the name of the parser
  33622. * @returns the requested parser or null
  33623. */
  33624. static GetParser(name: string): Nullable<BabylonFileParser>;
  33625. /**
  33626. * Adds n individual parser in the list of available ones
  33627. * @param name Defines the name of the parser
  33628. * @param parser Defines the parser to add
  33629. */
  33630. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33631. /**
  33632. * Gets an individual parser from the list of avaialble ones
  33633. * @param name Defines the name of the parser
  33634. * @returns the requested parser or null
  33635. */
  33636. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33637. /**
  33638. * Parser json data and populate both a scene and its associated container object
  33639. * @param jsonData Defines the data to parse
  33640. * @param scene Defines the scene to parse the data for
  33641. * @param container Defines the container attached to the parsing sequence
  33642. * @param rootUrl Defines the root url of the data
  33643. */
  33644. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33645. /**
  33646. * Gets the list of root nodes (ie. nodes with no parent)
  33647. */
  33648. rootNodes: Node[];
  33649. /** All of the cameras added to this scene
  33650. * @see http://doc.babylonjs.com/babylon101/cameras
  33651. */
  33652. cameras: Camera[];
  33653. /**
  33654. * All of the lights added to this scene
  33655. * @see http://doc.babylonjs.com/babylon101/lights
  33656. */
  33657. lights: Light[];
  33658. /**
  33659. * All of the (abstract) meshes added to this scene
  33660. */
  33661. meshes: AbstractMesh[];
  33662. /**
  33663. * The list of skeletons added to the scene
  33664. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33665. */
  33666. skeletons: Skeleton[];
  33667. /**
  33668. * All of the particle systems added to this scene
  33669. * @see http://doc.babylonjs.com/babylon101/particles
  33670. */
  33671. particleSystems: IParticleSystem[];
  33672. /**
  33673. * Gets a list of Animations associated with the scene
  33674. */
  33675. animations: Animation[];
  33676. /**
  33677. * All of the animation groups added to this scene
  33678. * @see http://doc.babylonjs.com/how_to/group
  33679. */
  33680. animationGroups: AnimationGroup[];
  33681. /**
  33682. * All of the multi-materials added to this scene
  33683. * @see http://doc.babylonjs.com/how_to/multi_materials
  33684. */
  33685. multiMaterials: MultiMaterial[];
  33686. /**
  33687. * All of the materials added to this scene
  33688. * In the context of a Scene, it is not supposed to be modified manually.
  33689. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33690. * Note also that the order of the Material wihin the array is not significant and might change.
  33691. * @see http://doc.babylonjs.com/babylon101/materials
  33692. */
  33693. materials: Material[];
  33694. /**
  33695. * The list of morph target managers added to the scene
  33696. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33697. */
  33698. morphTargetManagers: MorphTargetManager[];
  33699. /**
  33700. * The list of geometries used in the scene.
  33701. */
  33702. geometries: Geometry[];
  33703. /**
  33704. * All of the tranform nodes added to this scene
  33705. * In the context of a Scene, it is not supposed to be modified manually.
  33706. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33707. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33708. * @see http://doc.babylonjs.com/how_to/transformnode
  33709. */
  33710. transformNodes: TransformNode[];
  33711. /**
  33712. * ActionManagers available on the scene.
  33713. */
  33714. actionManagers: AbstractActionManager[];
  33715. /**
  33716. * Textures to keep.
  33717. */
  33718. textures: BaseTexture[];
  33719. }
  33720. }
  33721. declare module "babylonjs/Audio/sound" {
  33722. import { Observable } from "babylonjs/Misc/observable";
  33723. import { Vector3 } from "babylonjs/Maths/math";
  33724. import { Nullable } from "babylonjs/types";
  33725. import { Scene } from "babylonjs/scene";
  33726. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33727. /**
  33728. * Defines a sound that can be played in the application.
  33729. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33730. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33731. */
  33732. export class Sound {
  33733. /**
  33734. * The name of the sound in the scene.
  33735. */
  33736. name: string;
  33737. /**
  33738. * Does the sound autoplay once loaded.
  33739. */
  33740. autoplay: boolean;
  33741. /**
  33742. * Does the sound loop after it finishes playing once.
  33743. */
  33744. loop: boolean;
  33745. /**
  33746. * Does the sound use a custom attenuation curve to simulate the falloff
  33747. * happening when the source gets further away from the camera.
  33748. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33749. */
  33750. useCustomAttenuation: boolean;
  33751. /**
  33752. * The sound track id this sound belongs to.
  33753. */
  33754. soundTrackId: number;
  33755. /**
  33756. * Is this sound currently played.
  33757. */
  33758. isPlaying: boolean;
  33759. /**
  33760. * Is this sound currently paused.
  33761. */
  33762. isPaused: boolean;
  33763. /**
  33764. * Does this sound enables spatial sound.
  33765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33766. */
  33767. spatialSound: boolean;
  33768. /**
  33769. * Define the reference distance the sound should be heard perfectly.
  33770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33771. */
  33772. refDistance: number;
  33773. /**
  33774. * Define the roll off factor of spatial sounds.
  33775. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33776. */
  33777. rolloffFactor: number;
  33778. /**
  33779. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33780. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33781. */
  33782. maxDistance: number;
  33783. /**
  33784. * Define the distance attenuation model the sound will follow.
  33785. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33786. */
  33787. distanceModel: string;
  33788. /**
  33789. * @hidden
  33790. * Back Compat
  33791. **/
  33792. onended: () => any;
  33793. /**
  33794. * Observable event when the current playing sound finishes.
  33795. */
  33796. onEndedObservable: Observable<Sound>;
  33797. private _panningModel;
  33798. private _playbackRate;
  33799. private _streaming;
  33800. private _startTime;
  33801. private _startOffset;
  33802. private _position;
  33803. /** @hidden */
  33804. _positionInEmitterSpace: boolean;
  33805. private _localDirection;
  33806. private _volume;
  33807. private _isReadyToPlay;
  33808. private _isDirectional;
  33809. private _readyToPlayCallback;
  33810. private _audioBuffer;
  33811. private _soundSource;
  33812. private _streamingSource;
  33813. private _soundPanner;
  33814. private _soundGain;
  33815. private _inputAudioNode;
  33816. private _outputAudioNode;
  33817. private _coneInnerAngle;
  33818. private _coneOuterAngle;
  33819. private _coneOuterGain;
  33820. private _scene;
  33821. private _connectedTransformNode;
  33822. private _customAttenuationFunction;
  33823. private _registerFunc;
  33824. private _isOutputConnected;
  33825. private _htmlAudioElement;
  33826. private _urlType;
  33827. /** @hidden */
  33828. static _SceneComponentInitialization: (scene: Scene) => void;
  33829. /**
  33830. * Create a sound and attach it to a scene
  33831. * @param name Name of your sound
  33832. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33833. * @param scene defines the scene the sound belongs to
  33834. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33835. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33836. */
  33837. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33838. /**
  33839. * Release the sound and its associated resources
  33840. */
  33841. dispose(): void;
  33842. /**
  33843. * Gets if the sounds is ready to be played or not.
  33844. * @returns true if ready, otherwise false
  33845. */
  33846. isReady(): boolean;
  33847. private _soundLoaded;
  33848. /**
  33849. * Sets the data of the sound from an audiobuffer
  33850. * @param audioBuffer The audioBuffer containing the data
  33851. */
  33852. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33853. /**
  33854. * Updates the current sounds options such as maxdistance, loop...
  33855. * @param options A JSON object containing values named as the object properties
  33856. */
  33857. updateOptions(options: any): void;
  33858. private _createSpatialParameters;
  33859. private _updateSpatialParameters;
  33860. /**
  33861. * Switch the panning model to HRTF:
  33862. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33864. */
  33865. switchPanningModelToHRTF(): void;
  33866. /**
  33867. * Switch the panning model to Equal Power:
  33868. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33870. */
  33871. switchPanningModelToEqualPower(): void;
  33872. private _switchPanningModel;
  33873. /**
  33874. * Connect this sound to a sound track audio node like gain...
  33875. * @param soundTrackAudioNode the sound track audio node to connect to
  33876. */
  33877. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33878. /**
  33879. * Transform this sound into a directional source
  33880. * @param coneInnerAngle Size of the inner cone in degree
  33881. * @param coneOuterAngle Size of the outer cone in degree
  33882. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33883. */
  33884. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33885. /**
  33886. * Gets or sets the inner angle for the directional cone.
  33887. */
  33888. /**
  33889. * Gets or sets the inner angle for the directional cone.
  33890. */
  33891. directionalConeInnerAngle: number;
  33892. /**
  33893. * Gets or sets the outer angle for the directional cone.
  33894. */
  33895. /**
  33896. * Gets or sets the outer angle for the directional cone.
  33897. */
  33898. directionalConeOuterAngle: number;
  33899. /**
  33900. * Sets the position of the emitter if spatial sound is enabled
  33901. * @param newPosition Defines the new posisiton
  33902. */
  33903. setPosition(newPosition: Vector3): void;
  33904. /**
  33905. * Sets the local direction of the emitter if spatial sound is enabled
  33906. * @param newLocalDirection Defines the new local direction
  33907. */
  33908. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33909. private _updateDirection;
  33910. /** @hidden */
  33911. updateDistanceFromListener(): void;
  33912. /**
  33913. * Sets a new custom attenuation function for the sound.
  33914. * @param callback Defines the function used for the attenuation
  33915. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33916. */
  33917. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33918. /**
  33919. * Play the sound
  33920. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33921. * @param offset (optional) Start the sound setting it at a specific time
  33922. */
  33923. play(time?: number, offset?: number): void;
  33924. private _onended;
  33925. /**
  33926. * Stop the sound
  33927. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33928. */
  33929. stop(time?: number): void;
  33930. /**
  33931. * Put the sound in pause
  33932. */
  33933. pause(): void;
  33934. /**
  33935. * Sets a dedicated volume for this sounds
  33936. * @param newVolume Define the new volume of the sound
  33937. * @param time Define in how long the sound should be at this value
  33938. */
  33939. setVolume(newVolume: number, time?: number): void;
  33940. /**
  33941. * Set the sound play back rate
  33942. * @param newPlaybackRate Define the playback rate the sound should be played at
  33943. */
  33944. setPlaybackRate(newPlaybackRate: number): void;
  33945. /**
  33946. * Gets the volume of the sound.
  33947. * @returns the volume of the sound
  33948. */
  33949. getVolume(): number;
  33950. /**
  33951. * Attach the sound to a dedicated mesh
  33952. * @param transformNode The transform node to connect the sound with
  33953. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33954. */
  33955. attachToMesh(transformNode: TransformNode): void;
  33956. /**
  33957. * Detach the sound from the previously attached mesh
  33958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33959. */
  33960. detachFromMesh(): void;
  33961. private _onRegisterAfterWorldMatrixUpdate;
  33962. /**
  33963. * Clone the current sound in the scene.
  33964. * @returns the new sound clone
  33965. */
  33966. clone(): Nullable<Sound>;
  33967. /**
  33968. * Gets the current underlying audio buffer containing the data
  33969. * @returns the audio buffer
  33970. */
  33971. getAudioBuffer(): Nullable<AudioBuffer>;
  33972. /**
  33973. * Serializes the Sound in a JSON representation
  33974. * @returns the JSON representation of the sound
  33975. */
  33976. serialize(): any;
  33977. /**
  33978. * Parse a JSON representation of a sound to innstantiate in a given scene
  33979. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33980. * @param scene Define the scene the new parsed sound should be created in
  33981. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33982. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33983. * @returns the newly parsed sound
  33984. */
  33985. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33986. }
  33987. }
  33988. declare module "babylonjs/Actions/directAudioActions" {
  33989. import { Action } from "babylonjs/Actions/action";
  33990. import { Condition } from "babylonjs/Actions/condition";
  33991. import { Sound } from "babylonjs/Audio/sound";
  33992. /**
  33993. * This defines an action helpful to play a defined sound on a triggered action.
  33994. */
  33995. export class PlaySoundAction extends Action {
  33996. private _sound;
  33997. /**
  33998. * Instantiate the action
  33999. * @param triggerOptions defines the trigger options
  34000. * @param sound defines the sound to play
  34001. * @param condition defines the trigger related conditions
  34002. */
  34003. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34004. /** @hidden */
  34005. _prepare(): void;
  34006. /**
  34007. * Execute the action and play the sound.
  34008. */
  34009. execute(): void;
  34010. /**
  34011. * Serializes the actions and its related information.
  34012. * @param parent defines the object to serialize in
  34013. * @returns the serialized object
  34014. */
  34015. serialize(parent: any): any;
  34016. }
  34017. /**
  34018. * This defines an action helpful to stop a defined sound on a triggered action.
  34019. */
  34020. export class StopSoundAction extends Action {
  34021. private _sound;
  34022. /**
  34023. * Instantiate the action
  34024. * @param triggerOptions defines the trigger options
  34025. * @param sound defines the sound to stop
  34026. * @param condition defines the trigger related conditions
  34027. */
  34028. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34029. /** @hidden */
  34030. _prepare(): void;
  34031. /**
  34032. * Execute the action and stop the sound.
  34033. */
  34034. execute(): void;
  34035. /**
  34036. * Serializes the actions and its related information.
  34037. * @param parent defines the object to serialize in
  34038. * @returns the serialized object
  34039. */
  34040. serialize(parent: any): any;
  34041. }
  34042. }
  34043. declare module "babylonjs/Actions/interpolateValueAction" {
  34044. import { Action } from "babylonjs/Actions/action";
  34045. import { Condition } from "babylonjs/Actions/condition";
  34046. import { Observable } from "babylonjs/Misc/observable";
  34047. /**
  34048. * This defines an action responsible to change the value of a property
  34049. * by interpolating between its current value and the newly set one once triggered.
  34050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34051. */
  34052. export class InterpolateValueAction extends Action {
  34053. /**
  34054. * Defines the path of the property where the value should be interpolated
  34055. */
  34056. propertyPath: string;
  34057. /**
  34058. * Defines the target value at the end of the interpolation.
  34059. */
  34060. value: any;
  34061. /**
  34062. * Defines the time it will take for the property to interpolate to the value.
  34063. */
  34064. duration: number;
  34065. /**
  34066. * Defines if the other scene animations should be stopped when the action has been triggered
  34067. */
  34068. stopOtherAnimations?: boolean;
  34069. /**
  34070. * Defines a callback raised once the interpolation animation has been done.
  34071. */
  34072. onInterpolationDone?: () => void;
  34073. /**
  34074. * Observable triggered once the interpolation animation has been done.
  34075. */
  34076. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34077. private _target;
  34078. private _effectiveTarget;
  34079. private _property;
  34080. /**
  34081. * Instantiate the action
  34082. * @param triggerOptions defines the trigger options
  34083. * @param target defines the object containing the value to interpolate
  34084. * @param propertyPath defines the path to the property in the target object
  34085. * @param value defines the target value at the end of the interpolation
  34086. * @param duration deines the time it will take for the property to interpolate to the value.
  34087. * @param condition defines the trigger related conditions
  34088. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34089. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34090. */
  34091. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34092. /** @hidden */
  34093. _prepare(): void;
  34094. /**
  34095. * Execute the action starts the value interpolation.
  34096. */
  34097. execute(): void;
  34098. /**
  34099. * Serializes the actions and its related information.
  34100. * @param parent defines the object to serialize in
  34101. * @returns the serialized object
  34102. */
  34103. serialize(parent: any): any;
  34104. }
  34105. }
  34106. declare module "babylonjs/Actions/index" {
  34107. export * from "babylonjs/Actions/action";
  34108. export * from "babylonjs/Actions/actionEvent";
  34109. export * from "babylonjs/Actions/actionManager";
  34110. export * from "babylonjs/Actions/condition";
  34111. export * from "babylonjs/Actions/directActions";
  34112. export * from "babylonjs/Actions/directAudioActions";
  34113. export * from "babylonjs/Actions/interpolateValueAction";
  34114. }
  34115. declare module "babylonjs/Animations/index" {
  34116. export * from "babylonjs/Animations/animatable";
  34117. export * from "babylonjs/Animations/animation";
  34118. export * from "babylonjs/Animations/animationGroup";
  34119. export * from "babylonjs/Animations/animationPropertiesOverride";
  34120. export * from "babylonjs/Animations/easing";
  34121. export * from "babylonjs/Animations/runtimeAnimation";
  34122. export * from "babylonjs/Animations/animationEvent";
  34123. export * from "babylonjs/Animations/animationGroup";
  34124. export * from "babylonjs/Animations/animationKey";
  34125. export * from "babylonjs/Animations/animationRange";
  34126. }
  34127. declare module "babylonjs/Audio/soundTrack" {
  34128. import { Sound } from "babylonjs/Audio/sound";
  34129. import { Analyser } from "babylonjs/Audio/analyser";
  34130. import { Scene } from "babylonjs/scene";
  34131. /**
  34132. * Options allowed during the creation of a sound track.
  34133. */
  34134. export interface ISoundTrackOptions {
  34135. /**
  34136. * The volume the sound track should take during creation
  34137. */
  34138. volume?: number;
  34139. /**
  34140. * Define if the sound track is the main sound track of the scene
  34141. */
  34142. mainTrack?: boolean;
  34143. }
  34144. /**
  34145. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34146. * It will be also used in a future release to apply effects on a specific track.
  34147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34148. */
  34149. export class SoundTrack {
  34150. /**
  34151. * The unique identifier of the sound track in the scene.
  34152. */
  34153. id: number;
  34154. /**
  34155. * The list of sounds included in the sound track.
  34156. */
  34157. soundCollection: Array<Sound>;
  34158. private _outputAudioNode;
  34159. private _scene;
  34160. private _isMainTrack;
  34161. private _connectedAnalyser;
  34162. private _options;
  34163. private _isInitialized;
  34164. /**
  34165. * Creates a new sound track.
  34166. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34167. * @param scene Define the scene the sound track belongs to
  34168. * @param options
  34169. */
  34170. constructor(scene: Scene, options?: ISoundTrackOptions);
  34171. private _initializeSoundTrackAudioGraph;
  34172. /**
  34173. * Release the sound track and its associated resources
  34174. */
  34175. dispose(): void;
  34176. /**
  34177. * Adds a sound to this sound track
  34178. * @param sound define the cound to add
  34179. * @ignoreNaming
  34180. */
  34181. AddSound(sound: Sound): void;
  34182. /**
  34183. * Removes a sound to this sound track
  34184. * @param sound define the cound to remove
  34185. * @ignoreNaming
  34186. */
  34187. RemoveSound(sound: Sound): void;
  34188. /**
  34189. * Set a global volume for the full sound track.
  34190. * @param newVolume Define the new volume of the sound track
  34191. */
  34192. setVolume(newVolume: number): void;
  34193. /**
  34194. * Switch the panning model to HRTF:
  34195. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34197. */
  34198. switchPanningModelToHRTF(): void;
  34199. /**
  34200. * Switch the panning model to Equal Power:
  34201. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34203. */
  34204. switchPanningModelToEqualPower(): void;
  34205. /**
  34206. * Connect the sound track to an audio analyser allowing some amazing
  34207. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34208. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34209. * @param analyser The analyser to connect to the engine
  34210. */
  34211. connectToAnalyser(analyser: Analyser): void;
  34212. }
  34213. }
  34214. declare module "babylonjs/Audio/audioSceneComponent" {
  34215. import { Sound } from "babylonjs/Audio/sound";
  34216. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34217. import { Nullable } from "babylonjs/types";
  34218. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34219. import { Scene } from "babylonjs/scene";
  34220. import { AbstractScene } from "babylonjs/abstractScene";
  34221. module "babylonjs/abstractScene" {
  34222. interface AbstractScene {
  34223. /**
  34224. * The list of sounds used in the scene.
  34225. */
  34226. sounds: Nullable<Array<Sound>>;
  34227. }
  34228. }
  34229. module "babylonjs/scene" {
  34230. interface Scene {
  34231. /**
  34232. * @hidden
  34233. * Backing field
  34234. */
  34235. _mainSoundTrack: SoundTrack;
  34236. /**
  34237. * The main sound track played by the scene.
  34238. * It cotains your primary collection of sounds.
  34239. */
  34240. mainSoundTrack: SoundTrack;
  34241. /**
  34242. * The list of sound tracks added to the scene
  34243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34244. */
  34245. soundTracks: Nullable<Array<SoundTrack>>;
  34246. /**
  34247. * Gets a sound using a given name
  34248. * @param name defines the name to search for
  34249. * @return the found sound or null if not found at all.
  34250. */
  34251. getSoundByName(name: string): Nullable<Sound>;
  34252. /**
  34253. * Gets or sets if audio support is enabled
  34254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34255. */
  34256. audioEnabled: boolean;
  34257. /**
  34258. * Gets or sets if audio will be output to headphones
  34259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34260. */
  34261. headphone: boolean;
  34262. }
  34263. }
  34264. /**
  34265. * Defines the sound scene component responsible to manage any sounds
  34266. * in a given scene.
  34267. */
  34268. export class AudioSceneComponent implements ISceneSerializableComponent {
  34269. /**
  34270. * The component name helpfull to identify the component in the list of scene components.
  34271. */
  34272. readonly name: string;
  34273. /**
  34274. * The scene the component belongs to.
  34275. */
  34276. scene: Scene;
  34277. private _audioEnabled;
  34278. /**
  34279. * Gets whether audio is enabled or not.
  34280. * Please use related enable/disable method to switch state.
  34281. */
  34282. readonly audioEnabled: boolean;
  34283. private _headphone;
  34284. /**
  34285. * Gets whether audio is outputing to headphone or not.
  34286. * Please use the according Switch methods to change output.
  34287. */
  34288. readonly headphone: boolean;
  34289. /**
  34290. * Creates a new instance of the component for the given scene
  34291. * @param scene Defines the scene to register the component in
  34292. */
  34293. constructor(scene: Scene);
  34294. /**
  34295. * Registers the component in a given scene
  34296. */
  34297. register(): void;
  34298. /**
  34299. * Rebuilds the elements related to this component in case of
  34300. * context lost for instance.
  34301. */
  34302. rebuild(): void;
  34303. /**
  34304. * Serializes the component data to the specified json object
  34305. * @param serializationObject The object to serialize to
  34306. */
  34307. serialize(serializationObject: any): void;
  34308. /**
  34309. * Adds all the element from the container to the scene
  34310. * @param container the container holding the elements
  34311. */
  34312. addFromContainer(container: AbstractScene): void;
  34313. /**
  34314. * Removes all the elements in the container from the scene
  34315. * @param container contains the elements to remove
  34316. */
  34317. removeFromContainer(container: AbstractScene): void;
  34318. /**
  34319. * Disposes the component and the associated ressources.
  34320. */
  34321. dispose(): void;
  34322. /**
  34323. * Disables audio in the associated scene.
  34324. */
  34325. disableAudio(): void;
  34326. /**
  34327. * Enables audio in the associated scene.
  34328. */
  34329. enableAudio(): void;
  34330. /**
  34331. * Switch audio to headphone output.
  34332. */
  34333. switchAudioModeForHeadphones(): void;
  34334. /**
  34335. * Switch audio to normal speakers.
  34336. */
  34337. switchAudioModeForNormalSpeakers(): void;
  34338. private _afterRender;
  34339. }
  34340. }
  34341. declare module "babylonjs/Audio/weightedsound" {
  34342. import { Sound } from "babylonjs/Audio/sound";
  34343. /**
  34344. * Wraps one or more Sound objects and selects one with random weight for playback.
  34345. */
  34346. export class WeightedSound {
  34347. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34348. loop: boolean;
  34349. private _coneInnerAngle;
  34350. private _coneOuterAngle;
  34351. private _volume;
  34352. /** A Sound is currently playing. */
  34353. isPlaying: boolean;
  34354. /** A Sound is currently paused. */
  34355. isPaused: boolean;
  34356. private _sounds;
  34357. private _weights;
  34358. private _currentIndex?;
  34359. /**
  34360. * Creates a new WeightedSound from the list of sounds given.
  34361. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34362. * @param sounds Array of Sounds that will be selected from.
  34363. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34364. */
  34365. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34366. /**
  34367. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34368. */
  34369. /**
  34370. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34371. */
  34372. directionalConeInnerAngle: number;
  34373. /**
  34374. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34375. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34376. */
  34377. /**
  34378. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34379. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34380. */
  34381. directionalConeOuterAngle: number;
  34382. /**
  34383. * Playback volume.
  34384. */
  34385. /**
  34386. * Playback volume.
  34387. */
  34388. volume: number;
  34389. private _onended;
  34390. /**
  34391. * Suspend playback
  34392. */
  34393. pause(): void;
  34394. /**
  34395. * Stop playback
  34396. */
  34397. stop(): void;
  34398. /**
  34399. * Start playback.
  34400. * @param startOffset Position the clip head at a specific time in seconds.
  34401. */
  34402. play(startOffset?: number): void;
  34403. }
  34404. }
  34405. declare module "babylonjs/Audio/index" {
  34406. export * from "babylonjs/Audio/analyser";
  34407. export * from "babylonjs/Audio/audioEngine";
  34408. export * from "babylonjs/Audio/audioSceneComponent";
  34409. export * from "babylonjs/Audio/sound";
  34410. export * from "babylonjs/Audio/soundTrack";
  34411. export * from "babylonjs/Audio/weightedsound";
  34412. }
  34413. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34414. import { Behavior } from "babylonjs/Behaviors/behavior";
  34415. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34416. import { BackEase } from "babylonjs/Animations/easing";
  34417. /**
  34418. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34419. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34420. */
  34421. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34422. /**
  34423. * Gets the name of the behavior.
  34424. */
  34425. readonly name: string;
  34426. /**
  34427. * The easing function used by animations
  34428. */
  34429. static EasingFunction: BackEase;
  34430. /**
  34431. * The easing mode used by animations
  34432. */
  34433. static EasingMode: number;
  34434. /**
  34435. * The duration of the animation, in milliseconds
  34436. */
  34437. transitionDuration: number;
  34438. /**
  34439. * Length of the distance animated by the transition when lower radius is reached
  34440. */
  34441. lowerRadiusTransitionRange: number;
  34442. /**
  34443. * Length of the distance animated by the transition when upper radius is reached
  34444. */
  34445. upperRadiusTransitionRange: number;
  34446. private _autoTransitionRange;
  34447. /**
  34448. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34449. */
  34450. /**
  34451. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34452. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34453. */
  34454. autoTransitionRange: boolean;
  34455. private _attachedCamera;
  34456. private _onAfterCheckInputsObserver;
  34457. private _onMeshTargetChangedObserver;
  34458. /**
  34459. * Initializes the behavior.
  34460. */
  34461. init(): void;
  34462. /**
  34463. * Attaches the behavior to its arc rotate camera.
  34464. * @param camera Defines the camera to attach the behavior to
  34465. */
  34466. attach(camera: ArcRotateCamera): void;
  34467. /**
  34468. * Detaches the behavior from its current arc rotate camera.
  34469. */
  34470. detach(): void;
  34471. private _radiusIsAnimating;
  34472. private _radiusBounceTransition;
  34473. private _animatables;
  34474. private _cachedWheelPrecision;
  34475. /**
  34476. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34477. * @param radiusLimit The limit to check against.
  34478. * @return Bool to indicate if at limit.
  34479. */
  34480. private _isRadiusAtLimit;
  34481. /**
  34482. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34483. * @param radiusDelta The delta by which to animate to. Can be negative.
  34484. */
  34485. private _applyBoundRadiusAnimation;
  34486. /**
  34487. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34488. */
  34489. protected _clearAnimationLocks(): void;
  34490. /**
  34491. * Stops and removes all animations that have been applied to the camera
  34492. */
  34493. stopAllAnimations(): void;
  34494. }
  34495. }
  34496. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34497. import { Behavior } from "babylonjs/Behaviors/behavior";
  34498. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34499. import { ExponentialEase } from "babylonjs/Animations/easing";
  34500. import { Nullable } from "babylonjs/types";
  34501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34502. import { Vector3 } from "babylonjs/Maths/math";
  34503. /**
  34504. * 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.
  34505. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34506. */
  34507. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34508. /**
  34509. * Gets the name of the behavior.
  34510. */
  34511. readonly name: string;
  34512. private _mode;
  34513. private _radiusScale;
  34514. private _positionScale;
  34515. private _defaultElevation;
  34516. private _elevationReturnTime;
  34517. private _elevationReturnWaitTime;
  34518. private _zoomStopsAnimation;
  34519. private _framingTime;
  34520. /**
  34521. * The easing function used by animations
  34522. */
  34523. static EasingFunction: ExponentialEase;
  34524. /**
  34525. * The easing mode used by animations
  34526. */
  34527. static EasingMode: number;
  34528. /**
  34529. * Sets the current mode used by the behavior
  34530. */
  34531. /**
  34532. * Gets current mode used by the behavior.
  34533. */
  34534. mode: number;
  34535. /**
  34536. * Sets the scale applied to the radius (1 by default)
  34537. */
  34538. /**
  34539. * Gets the scale applied to the radius
  34540. */
  34541. radiusScale: number;
  34542. /**
  34543. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34544. */
  34545. /**
  34546. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34547. */
  34548. positionScale: number;
  34549. /**
  34550. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34551. * behaviour is triggered, in radians.
  34552. */
  34553. /**
  34554. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34555. * behaviour is triggered, in radians.
  34556. */
  34557. defaultElevation: number;
  34558. /**
  34559. * Sets the time (in milliseconds) taken to return to the default beta position.
  34560. * Negative value indicates camera should not return to default.
  34561. */
  34562. /**
  34563. * Gets the time (in milliseconds) taken to return to the default beta position.
  34564. * Negative value indicates camera should not return to default.
  34565. */
  34566. elevationReturnTime: number;
  34567. /**
  34568. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34569. */
  34570. /**
  34571. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34572. */
  34573. elevationReturnWaitTime: number;
  34574. /**
  34575. * Sets the flag that indicates if user zooming should stop animation.
  34576. */
  34577. /**
  34578. * Gets the flag that indicates if user zooming should stop animation.
  34579. */
  34580. zoomStopsAnimation: boolean;
  34581. /**
  34582. * Sets the transition time when framing the mesh, in milliseconds
  34583. */
  34584. /**
  34585. * Gets the transition time when framing the mesh, in milliseconds
  34586. */
  34587. framingTime: number;
  34588. /**
  34589. * Define if the behavior should automatically change the configured
  34590. * camera limits and sensibilities.
  34591. */
  34592. autoCorrectCameraLimitsAndSensibility: boolean;
  34593. private _onPrePointerObservableObserver;
  34594. private _onAfterCheckInputsObserver;
  34595. private _onMeshTargetChangedObserver;
  34596. private _attachedCamera;
  34597. private _isPointerDown;
  34598. private _lastInteractionTime;
  34599. /**
  34600. * Initializes the behavior.
  34601. */
  34602. init(): void;
  34603. /**
  34604. * Attaches the behavior to its arc rotate camera.
  34605. * @param camera Defines the camera to attach the behavior to
  34606. */
  34607. attach(camera: ArcRotateCamera): void;
  34608. /**
  34609. * Detaches the behavior from its current arc rotate camera.
  34610. */
  34611. detach(): void;
  34612. private _animatables;
  34613. private _betaIsAnimating;
  34614. private _betaTransition;
  34615. private _radiusTransition;
  34616. private _vectorTransition;
  34617. /**
  34618. * Targets the given mesh and updates zoom level accordingly.
  34619. * @param mesh The mesh to target.
  34620. * @param radius Optional. If a cached radius position already exists, overrides default.
  34621. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34622. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34623. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34624. */
  34625. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34626. /**
  34627. * Targets the given mesh with its children and updates zoom level accordingly.
  34628. * @param mesh The mesh to target.
  34629. * @param radius Optional. If a cached radius position already exists, overrides default.
  34630. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34631. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34632. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34633. */
  34634. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34635. /**
  34636. * Targets the given meshes with their children and updates zoom level accordingly.
  34637. * @param meshes The mesh to target.
  34638. * @param radius Optional. If a cached radius position already exists, overrides default.
  34639. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34640. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34641. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34642. */
  34643. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34644. /**
  34645. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34646. * @param minimumWorld Determines the smaller position of the bounding box extend
  34647. * @param maximumWorld Determines the bigger position of the bounding box extend
  34648. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34649. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34650. */
  34651. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34652. /**
  34653. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34654. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34655. * frustum width.
  34656. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34657. * to fully enclose the mesh in the viewing frustum.
  34658. */
  34659. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34660. /**
  34661. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34662. * is automatically returned to its default position (expected to be above ground plane).
  34663. */
  34664. private _maintainCameraAboveGround;
  34665. /**
  34666. * Returns the frustum slope based on the canvas ratio and camera FOV
  34667. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34668. */
  34669. private _getFrustumSlope;
  34670. /**
  34671. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34672. */
  34673. private _clearAnimationLocks;
  34674. /**
  34675. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34676. */
  34677. private _applyUserInteraction;
  34678. /**
  34679. * Stops and removes all animations that have been applied to the camera
  34680. */
  34681. stopAllAnimations(): void;
  34682. /**
  34683. * Gets a value indicating if the user is moving the camera
  34684. */
  34685. readonly isUserIsMoving: boolean;
  34686. /**
  34687. * The camera can move all the way towards the mesh.
  34688. */
  34689. static IgnoreBoundsSizeMode: number;
  34690. /**
  34691. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34692. */
  34693. static FitFrustumSidesMode: number;
  34694. }
  34695. }
  34696. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  34697. import { Nullable } from "babylonjs/types";
  34698. import { Camera } from "babylonjs/Cameras/camera";
  34699. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34700. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34701. /**
  34702. * Base class for Camera Pointer Inputs.
  34703. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34704. * for example usage.
  34705. */
  34706. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34707. /**
  34708. * Defines the camera the input is attached to.
  34709. */
  34710. abstract camera: Camera;
  34711. /**
  34712. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34713. */
  34714. protected _altKey: boolean;
  34715. protected _ctrlKey: boolean;
  34716. protected _metaKey: boolean;
  34717. protected _shiftKey: boolean;
  34718. /**
  34719. * Which mouse buttons were pressed at time of last mouse event.
  34720. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34721. */
  34722. protected _buttonsPressed: number;
  34723. /**
  34724. * Defines the buttons associated with the input to handle camera move.
  34725. */
  34726. buttons: number[];
  34727. /**
  34728. * Attach the input controls to a specific dom element to get the input from.
  34729. * @param element Defines the element the controls should be listened from
  34730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34731. */
  34732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34733. /**
  34734. * Detach the current controls from the specified dom element.
  34735. * @param element Defines the element to stop listening the inputs from
  34736. */
  34737. detachControl(element: Nullable<HTMLElement>): void;
  34738. /**
  34739. * Gets the class name of the current input.
  34740. * @returns the class name
  34741. */
  34742. getClassName(): string;
  34743. /**
  34744. * Get the friendly name associated with the input class.
  34745. * @returns the input friendly name
  34746. */
  34747. getSimpleName(): string;
  34748. /**
  34749. * Called on pointer POINTERDOUBLETAP event.
  34750. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34751. */
  34752. protected onDoubleTap(type: string): void;
  34753. /**
  34754. * Called on pointer POINTERMOVE event if only a single touch is active.
  34755. * Override this method to provide functionality.
  34756. */
  34757. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34758. /**
  34759. * Called on pointer POINTERMOVE event if multiple touches are active.
  34760. * Override this method to provide functionality.
  34761. */
  34762. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34763. /**
  34764. * Called on JS contextmenu event.
  34765. * Override this method to provide functionality.
  34766. */
  34767. protected onContextMenu(evt: PointerEvent): void;
  34768. /**
  34769. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34770. * press.
  34771. * Override this method to provide functionality.
  34772. */
  34773. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34774. /**
  34775. * Called each time a new POINTERUP event occurs. Ie, for each button
  34776. * release.
  34777. * Override this method to provide functionality.
  34778. */
  34779. protected onButtonUp(evt: PointerEvent): void;
  34780. /**
  34781. * Called when window becomes inactive.
  34782. * Override this method to provide functionality.
  34783. */
  34784. protected onLostFocus(): void;
  34785. private _pointerInput;
  34786. private _observer;
  34787. private _onLostFocus;
  34788. }
  34789. }
  34790. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34791. import { Nullable } from "babylonjs/types";
  34792. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34793. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  34794. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34795. /**
  34796. * Manage the pointers inputs to control an arc rotate camera.
  34797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34798. */
  34799. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34800. /**
  34801. * Defines the camera the input is attached to.
  34802. */
  34803. camera: ArcRotateCamera;
  34804. /**
  34805. * Gets the class name of the current input.
  34806. * @returns the class name
  34807. */
  34808. getClassName(): string;
  34809. /**
  34810. * Defines the buttons associated with the input to handle camera move.
  34811. */
  34812. buttons: number[];
  34813. /**
  34814. * Defines the pointer angular sensibility along the X axis or how fast is
  34815. * the camera rotating.
  34816. */
  34817. angularSensibilityX: number;
  34818. /**
  34819. * Defines the pointer angular sensibility along the Y axis or how fast is
  34820. * the camera rotating.
  34821. */
  34822. angularSensibilityY: number;
  34823. /**
  34824. * Defines the pointer pinch precision or how fast is the camera zooming.
  34825. */
  34826. pinchPrecision: number;
  34827. /**
  34828. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34829. * from 0.
  34830. * It defines the percentage of current camera.radius to use as delta when
  34831. * pinch zoom is used.
  34832. */
  34833. pinchDeltaPercentage: number;
  34834. /**
  34835. * Defines the pointer panning sensibility or how fast is the camera moving.
  34836. */
  34837. panningSensibility: number;
  34838. /**
  34839. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34840. */
  34841. multiTouchPanning: boolean;
  34842. /**
  34843. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34844. * zoom (pinch) through multitouch.
  34845. */
  34846. multiTouchPanAndZoom: boolean;
  34847. /**
  34848. * Revers pinch action direction.
  34849. */
  34850. pinchInwards: boolean;
  34851. private _isPanClick;
  34852. private _twoFingerActivityCount;
  34853. private _isPinching;
  34854. /**
  34855. * Called on pointer POINTERMOVE event if only a single touch is active.
  34856. */
  34857. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34858. /**
  34859. * Called on pointer POINTERDOUBLETAP event.
  34860. */
  34861. protected onDoubleTap(type: string): void;
  34862. /**
  34863. * Called on pointer POINTERMOVE event if multiple touches are active.
  34864. */
  34865. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34866. /**
  34867. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34868. * press.
  34869. */
  34870. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34871. /**
  34872. * Called each time a new POINTERUP event occurs. Ie, for each button
  34873. * release.
  34874. */
  34875. protected onButtonUp(evt: PointerEvent): void;
  34876. /**
  34877. * Called when window becomes inactive.
  34878. */
  34879. protected onLostFocus(): void;
  34880. }
  34881. }
  34882. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34883. import { Nullable } from "babylonjs/types";
  34884. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34885. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34886. /**
  34887. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34888. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34889. */
  34890. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34891. /**
  34892. * Defines the camera the input is attached to.
  34893. */
  34894. camera: ArcRotateCamera;
  34895. /**
  34896. * Defines the list of key codes associated with the up action (increase alpha)
  34897. */
  34898. keysUp: number[];
  34899. /**
  34900. * Defines the list of key codes associated with the down action (decrease alpha)
  34901. */
  34902. keysDown: number[];
  34903. /**
  34904. * Defines the list of key codes associated with the left action (increase beta)
  34905. */
  34906. keysLeft: number[];
  34907. /**
  34908. * Defines the list of key codes associated with the right action (decrease beta)
  34909. */
  34910. keysRight: number[];
  34911. /**
  34912. * Defines the list of key codes associated with the reset action.
  34913. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34914. */
  34915. keysReset: number[];
  34916. /**
  34917. * Defines the panning sensibility of the inputs.
  34918. * (How fast is the camera paning)
  34919. */
  34920. panningSensibility: number;
  34921. /**
  34922. * Defines the zooming sensibility of the inputs.
  34923. * (How fast is the camera zooming)
  34924. */
  34925. zoomingSensibility: number;
  34926. /**
  34927. * Defines wether maintaining the alt key down switch the movement mode from
  34928. * orientation to zoom.
  34929. */
  34930. useAltToZoom: boolean;
  34931. /**
  34932. * Rotation speed of the camera
  34933. */
  34934. angularSpeed: number;
  34935. private _keys;
  34936. private _ctrlPressed;
  34937. private _altPressed;
  34938. private _onCanvasBlurObserver;
  34939. private _onKeyboardObserver;
  34940. private _engine;
  34941. private _scene;
  34942. /**
  34943. * Attach the input controls to a specific dom element to get the input from.
  34944. * @param element Defines the element the controls should be listened from
  34945. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34946. */
  34947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34948. /**
  34949. * Detach the current controls from the specified dom element.
  34950. * @param element Defines the element to stop listening the inputs from
  34951. */
  34952. detachControl(element: Nullable<HTMLElement>): void;
  34953. /**
  34954. * Update the current camera state depending on the inputs that have been used this frame.
  34955. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34956. */
  34957. checkInputs(): void;
  34958. /**
  34959. * Gets the class name of the current intput.
  34960. * @returns the class name
  34961. */
  34962. getClassName(): string;
  34963. /**
  34964. * Get the friendly name associated with the input class.
  34965. * @returns the input friendly name
  34966. */
  34967. getSimpleName(): string;
  34968. }
  34969. }
  34970. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  34971. import { Nullable } from "babylonjs/types";
  34972. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34973. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34974. /**
  34975. * Manage the mouse wheel inputs to control an arc rotate camera.
  34976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34977. */
  34978. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34979. /**
  34980. * Defines the camera the input is attached to.
  34981. */
  34982. camera: ArcRotateCamera;
  34983. /**
  34984. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34985. */
  34986. wheelPrecision: number;
  34987. /**
  34988. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34989. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34990. */
  34991. wheelDeltaPercentage: number;
  34992. private _wheel;
  34993. private _observer;
  34994. /**
  34995. * Attach the input controls to a specific dom element to get the input from.
  34996. * @param element Defines the element the controls should be listened from
  34997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34998. */
  34999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35000. /**
  35001. * Detach the current controls from the specified dom element.
  35002. * @param element Defines the element to stop listening the inputs from
  35003. */
  35004. detachControl(element: Nullable<HTMLElement>): void;
  35005. /**
  35006. * Gets the class name of the current intput.
  35007. * @returns the class name
  35008. */
  35009. getClassName(): string;
  35010. /**
  35011. * Get the friendly name associated with the input class.
  35012. * @returns the input friendly name
  35013. */
  35014. getSimpleName(): string;
  35015. }
  35016. }
  35017. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35018. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35019. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35020. /**
  35021. * Default Inputs manager for the ArcRotateCamera.
  35022. * It groups all the default supported inputs for ease of use.
  35023. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35024. */
  35025. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35026. /**
  35027. * Instantiates a new ArcRotateCameraInputsManager.
  35028. * @param camera Defines the camera the inputs belong to
  35029. */
  35030. constructor(camera: ArcRotateCamera);
  35031. /**
  35032. * Add mouse wheel input support to the input manager.
  35033. * @returns the current input manager
  35034. */
  35035. addMouseWheel(): ArcRotateCameraInputsManager;
  35036. /**
  35037. * Add pointers input support to the input manager.
  35038. * @returns the current input manager
  35039. */
  35040. addPointers(): ArcRotateCameraInputsManager;
  35041. /**
  35042. * Add keyboard input support to the input manager.
  35043. * @returns the current input manager
  35044. */
  35045. addKeyboard(): ArcRotateCameraInputsManager;
  35046. }
  35047. }
  35048. declare module "babylonjs/Cameras/arcRotateCamera" {
  35049. import { Observable } from "babylonjs/Misc/observable";
  35050. import { Nullable } from "babylonjs/types";
  35051. import { Scene } from "babylonjs/scene";
  35052. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35054. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35055. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35056. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35057. import { Camera } from "babylonjs/Cameras/camera";
  35058. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35059. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35060. import { Collider } from "babylonjs/Collisions/collider";
  35061. /**
  35062. * This represents an orbital type of camera.
  35063. *
  35064. * 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.
  35065. * 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.
  35066. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35067. */
  35068. export class ArcRotateCamera extends TargetCamera {
  35069. /**
  35070. * Defines the rotation angle of the camera along the longitudinal axis.
  35071. */
  35072. alpha: number;
  35073. /**
  35074. * Defines the rotation angle of the camera along the latitudinal axis.
  35075. */
  35076. beta: number;
  35077. /**
  35078. * Defines the radius of the camera from it s target point.
  35079. */
  35080. radius: number;
  35081. protected _target: Vector3;
  35082. protected _targetHost: Nullable<AbstractMesh>;
  35083. /**
  35084. * Defines the target point of the camera.
  35085. * The camera looks towards it form the radius distance.
  35086. */
  35087. target: Vector3;
  35088. /**
  35089. * Define the current local position of the camera in the scene
  35090. */
  35091. position: Vector3;
  35092. /**
  35093. * Current inertia value on the longitudinal axis.
  35094. * The bigger this number the longer it will take for the camera to stop.
  35095. */
  35096. inertialAlphaOffset: number;
  35097. /**
  35098. * Current inertia value on the latitudinal axis.
  35099. * The bigger this number the longer it will take for the camera to stop.
  35100. */
  35101. inertialBetaOffset: number;
  35102. /**
  35103. * Current inertia value on the radius axis.
  35104. * The bigger this number the longer it will take for the camera to stop.
  35105. */
  35106. inertialRadiusOffset: number;
  35107. /**
  35108. * Minimum allowed angle on the longitudinal axis.
  35109. * This can help limiting how the Camera is able to move in the scene.
  35110. */
  35111. lowerAlphaLimit: Nullable<number>;
  35112. /**
  35113. * Maximum allowed angle on the longitudinal axis.
  35114. * This can help limiting how the Camera is able to move in the scene.
  35115. */
  35116. upperAlphaLimit: Nullable<number>;
  35117. /**
  35118. * Minimum allowed angle on the latitudinal axis.
  35119. * This can help limiting how the Camera is able to move in the scene.
  35120. */
  35121. lowerBetaLimit: number;
  35122. /**
  35123. * Maximum allowed angle on the latitudinal axis.
  35124. * This can help limiting how the Camera is able to move in the scene.
  35125. */
  35126. upperBetaLimit: number;
  35127. /**
  35128. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35129. * This can help limiting how the Camera is able to move in the scene.
  35130. */
  35131. lowerRadiusLimit: Nullable<number>;
  35132. /**
  35133. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35134. * This can help limiting how the Camera is able to move in the scene.
  35135. */
  35136. upperRadiusLimit: Nullable<number>;
  35137. /**
  35138. * Defines the current inertia value used during panning of the camera along the X axis.
  35139. */
  35140. inertialPanningX: number;
  35141. /**
  35142. * Defines the current inertia value used during panning of the camera along the Y axis.
  35143. */
  35144. inertialPanningY: number;
  35145. /**
  35146. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35147. * Basically if your fingers moves away from more than this distance you will be considered
  35148. * in pinch mode.
  35149. */
  35150. pinchToPanMaxDistance: number;
  35151. /**
  35152. * Defines the maximum distance the camera can pan.
  35153. * This could help keeping the cammera always in your scene.
  35154. */
  35155. panningDistanceLimit: Nullable<number>;
  35156. /**
  35157. * Defines the target of the camera before paning.
  35158. */
  35159. panningOriginTarget: Vector3;
  35160. /**
  35161. * Defines the value of the inertia used during panning.
  35162. * 0 would mean stop inertia and one would mean no decelleration at all.
  35163. */
  35164. panningInertia: number;
  35165. /**
  35166. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35167. */
  35168. angularSensibilityX: number;
  35169. /**
  35170. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35171. */
  35172. angularSensibilityY: number;
  35173. /**
  35174. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35175. */
  35176. pinchPrecision: number;
  35177. /**
  35178. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35179. * It will be used instead of pinchDeltaPrecision if different from 0.
  35180. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35181. */
  35182. pinchDeltaPercentage: number;
  35183. /**
  35184. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35185. */
  35186. panningSensibility: number;
  35187. /**
  35188. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35189. */
  35190. keysUp: number[];
  35191. /**
  35192. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35193. */
  35194. keysDown: number[];
  35195. /**
  35196. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35197. */
  35198. keysLeft: number[];
  35199. /**
  35200. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35201. */
  35202. keysRight: number[];
  35203. /**
  35204. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35205. */
  35206. wheelPrecision: number;
  35207. /**
  35208. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35209. * It will be used instead of pinchDeltaPrecision if different from 0.
  35210. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35211. */
  35212. wheelDeltaPercentage: number;
  35213. /**
  35214. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35215. */
  35216. zoomOnFactor: number;
  35217. /**
  35218. * Defines a screen offset for the camera position.
  35219. */
  35220. targetScreenOffset: Vector2;
  35221. /**
  35222. * Allows the camera to be completely reversed.
  35223. * If false the camera can not arrive upside down.
  35224. */
  35225. allowUpsideDown: boolean;
  35226. /**
  35227. * Define if double tap/click is used to restore the previously saved state of the camera.
  35228. */
  35229. useInputToRestoreState: boolean;
  35230. /** @hidden */
  35231. _viewMatrix: Matrix;
  35232. /** @hidden */
  35233. _useCtrlForPanning: boolean;
  35234. /** @hidden */
  35235. _panningMouseButton: number;
  35236. /**
  35237. * Defines the input associated to the camera.
  35238. */
  35239. inputs: ArcRotateCameraInputsManager;
  35240. /** @hidden */
  35241. _reset: () => void;
  35242. /**
  35243. * Defines the allowed panning axis.
  35244. */
  35245. panningAxis: Vector3;
  35246. protected _localDirection: Vector3;
  35247. protected _transformedDirection: Vector3;
  35248. private _bouncingBehavior;
  35249. /**
  35250. * Gets the bouncing behavior of the camera if it has been enabled.
  35251. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35252. */
  35253. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35254. /**
  35255. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35256. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35257. */
  35258. useBouncingBehavior: boolean;
  35259. private _framingBehavior;
  35260. /**
  35261. * Gets the framing behavior of the camera if it has been enabled.
  35262. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35263. */
  35264. readonly framingBehavior: Nullable<FramingBehavior>;
  35265. /**
  35266. * Defines if the framing behavior of the camera is enabled on the camera.
  35267. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35268. */
  35269. useFramingBehavior: boolean;
  35270. private _autoRotationBehavior;
  35271. /**
  35272. * Gets the auto rotation behavior of the camera if it has been enabled.
  35273. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35274. */
  35275. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35276. /**
  35277. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35278. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35279. */
  35280. useAutoRotationBehavior: boolean;
  35281. /**
  35282. * Observable triggered when the mesh target has been changed on the camera.
  35283. */
  35284. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35285. /**
  35286. * Event raised when the camera is colliding with a mesh.
  35287. */
  35288. onCollide: (collidedMesh: AbstractMesh) => void;
  35289. /**
  35290. * Defines whether the camera should check collision with the objects oh the scene.
  35291. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35292. */
  35293. checkCollisions: boolean;
  35294. /**
  35295. * Defines the collision radius of the camera.
  35296. * This simulates a sphere around the camera.
  35297. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35298. */
  35299. collisionRadius: Vector3;
  35300. protected _collider: Collider;
  35301. protected _previousPosition: Vector3;
  35302. protected _collisionVelocity: Vector3;
  35303. protected _newPosition: Vector3;
  35304. protected _previousAlpha: number;
  35305. protected _previousBeta: number;
  35306. protected _previousRadius: number;
  35307. protected _collisionTriggered: boolean;
  35308. protected _targetBoundingCenter: Nullable<Vector3>;
  35309. private _computationVector;
  35310. private _tempAxisVector;
  35311. private _tempAxisRotationMatrix;
  35312. /**
  35313. * Instantiates a new ArcRotateCamera in a given scene
  35314. * @param name Defines the name of the camera
  35315. * @param alpha Defines the camera rotation along the logitudinal axis
  35316. * @param beta Defines the camera rotation along the latitudinal axis
  35317. * @param radius Defines the camera distance from its target
  35318. * @param target Defines the camera target
  35319. * @param scene Defines the scene the camera belongs to
  35320. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35321. */
  35322. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35323. /** @hidden */
  35324. _initCache(): void;
  35325. /** @hidden */
  35326. _updateCache(ignoreParentClass?: boolean): void;
  35327. protected _getTargetPosition(): Vector3;
  35328. private _storedAlpha;
  35329. private _storedBeta;
  35330. private _storedRadius;
  35331. private _storedTarget;
  35332. /**
  35333. * Stores the current state of the camera (alpha, beta, radius and target)
  35334. * @returns the camera itself
  35335. */
  35336. storeState(): Camera;
  35337. /**
  35338. * @hidden
  35339. * Restored camera state. You must call storeState() first
  35340. */
  35341. _restoreStateValues(): boolean;
  35342. /** @hidden */
  35343. _isSynchronizedViewMatrix(): boolean;
  35344. /**
  35345. * Attached controls to the current camera.
  35346. * @param element Defines the element the controls should be listened from
  35347. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35348. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35349. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35350. */
  35351. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35352. /**
  35353. * Detach the current controls from the camera.
  35354. * The camera will stop reacting to inputs.
  35355. * @param element Defines the element to stop listening the inputs from
  35356. */
  35357. detachControl(element: HTMLElement): void;
  35358. /** @hidden */
  35359. _checkInputs(): void;
  35360. protected _checkLimits(): void;
  35361. /**
  35362. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35363. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35364. */
  35365. rebuildAnglesAndRadius(updateView?: boolean): void;
  35366. /**
  35367. * Use a position to define the current camera related information like aplha, beta and radius
  35368. * @param position Defines the position to set the camera at
  35369. */
  35370. setPosition(position: Vector3): void;
  35371. /**
  35372. * Defines the target the camera should look at.
  35373. * This will automatically adapt alpha beta and radius to fit within the new target.
  35374. * @param target Defines the new target as a Vector or a mesh
  35375. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35376. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35377. */
  35378. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35379. /** @hidden */
  35380. _getViewMatrix(): Matrix;
  35381. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35382. /**
  35383. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35384. * @param meshes Defines the mesh to zoom on
  35385. * @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)
  35386. */
  35387. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35388. /**
  35389. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35390. * The target will be changed but the radius
  35391. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35392. * @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)
  35393. */
  35394. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35395. min: Vector3;
  35396. max: Vector3;
  35397. distance: number;
  35398. }, doNotUpdateMaxZ?: boolean): void;
  35399. /**
  35400. * @override
  35401. * Override Camera.createRigCamera
  35402. */
  35403. createRigCamera(name: string, cameraIndex: number): Camera;
  35404. /**
  35405. * @hidden
  35406. * @override
  35407. * Override Camera._updateRigCameras
  35408. */
  35409. _updateRigCameras(): void;
  35410. /**
  35411. * Destroy the camera and release the current resources hold by it.
  35412. */
  35413. dispose(): void;
  35414. /**
  35415. * Gets the current object class name.
  35416. * @return the class name
  35417. */
  35418. getClassName(): string;
  35419. }
  35420. }
  35421. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35422. import { Behavior } from "babylonjs/Behaviors/behavior";
  35423. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35424. /**
  35425. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35426. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35427. */
  35428. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35429. /**
  35430. * Gets the name of the behavior.
  35431. */
  35432. readonly name: string;
  35433. private _zoomStopsAnimation;
  35434. private _idleRotationSpeed;
  35435. private _idleRotationWaitTime;
  35436. private _idleRotationSpinupTime;
  35437. /**
  35438. * Sets the flag that indicates if user zooming should stop animation.
  35439. */
  35440. /**
  35441. * Gets the flag that indicates if user zooming should stop animation.
  35442. */
  35443. zoomStopsAnimation: boolean;
  35444. /**
  35445. * Sets the default speed at which the camera rotates around the model.
  35446. */
  35447. /**
  35448. * Gets the default speed at which the camera rotates around the model.
  35449. */
  35450. idleRotationSpeed: number;
  35451. /**
  35452. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35453. */
  35454. /**
  35455. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35456. */
  35457. idleRotationWaitTime: number;
  35458. /**
  35459. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35460. */
  35461. /**
  35462. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35463. */
  35464. idleRotationSpinupTime: number;
  35465. /**
  35466. * Gets a value indicating if the camera is currently rotating because of this behavior
  35467. */
  35468. readonly rotationInProgress: boolean;
  35469. private _onPrePointerObservableObserver;
  35470. private _onAfterCheckInputsObserver;
  35471. private _attachedCamera;
  35472. private _isPointerDown;
  35473. private _lastFrameTime;
  35474. private _lastInteractionTime;
  35475. private _cameraRotationSpeed;
  35476. /**
  35477. * Initializes the behavior.
  35478. */
  35479. init(): void;
  35480. /**
  35481. * Attaches the behavior to its arc rotate camera.
  35482. * @param camera Defines the camera to attach the behavior to
  35483. */
  35484. attach(camera: ArcRotateCamera): void;
  35485. /**
  35486. * Detaches the behavior from its current arc rotate camera.
  35487. */
  35488. detach(): void;
  35489. /**
  35490. * Returns true if user is scrolling.
  35491. * @return true if user is scrolling.
  35492. */
  35493. private _userIsZooming;
  35494. private _lastFrameRadius;
  35495. private _shouldAnimationStopForInteraction;
  35496. /**
  35497. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35498. */
  35499. private _applyUserInteraction;
  35500. private _userIsMoving;
  35501. }
  35502. }
  35503. declare module "babylonjs/Behaviors/Cameras/index" {
  35504. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35505. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35506. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35507. }
  35508. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35509. import { Mesh } from "babylonjs/Meshes/mesh";
  35510. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35511. import { Behavior } from "babylonjs/Behaviors/behavior";
  35512. /**
  35513. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35514. */
  35515. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35516. private ui;
  35517. /**
  35518. * The name of the behavior
  35519. */
  35520. name: string;
  35521. /**
  35522. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35523. */
  35524. distanceAwayFromFace: number;
  35525. /**
  35526. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35527. */
  35528. distanceAwayFromBottomOfFace: number;
  35529. private _faceVectors;
  35530. private _target;
  35531. private _scene;
  35532. private _onRenderObserver;
  35533. private _tmpMatrix;
  35534. private _tmpVector;
  35535. /**
  35536. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35537. * @param ui The transform node that should be attched to the mesh
  35538. */
  35539. constructor(ui: TransformNode);
  35540. /**
  35541. * Initializes the behavior
  35542. */
  35543. init(): void;
  35544. private _closestFace;
  35545. private _zeroVector;
  35546. private _lookAtTmpMatrix;
  35547. private _lookAtToRef;
  35548. /**
  35549. * Attaches the AttachToBoxBehavior to the passed in mesh
  35550. * @param target The mesh that the specified node will be attached to
  35551. */
  35552. attach(target: Mesh): void;
  35553. /**
  35554. * Detaches the behavior from the mesh
  35555. */
  35556. detach(): void;
  35557. }
  35558. }
  35559. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35560. import { Behavior } from "babylonjs/Behaviors/behavior";
  35561. import { Mesh } from "babylonjs/Meshes/mesh";
  35562. /**
  35563. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35564. */
  35565. export class FadeInOutBehavior implements Behavior<Mesh> {
  35566. /**
  35567. * Time in milliseconds to delay before fading in (Default: 0)
  35568. */
  35569. delay: number;
  35570. /**
  35571. * Time in milliseconds for the mesh to fade in (Default: 300)
  35572. */
  35573. fadeInTime: number;
  35574. private _millisecondsPerFrame;
  35575. private _hovered;
  35576. private _hoverValue;
  35577. private _ownerNode;
  35578. /**
  35579. * Instatiates the FadeInOutBehavior
  35580. */
  35581. constructor();
  35582. /**
  35583. * The name of the behavior
  35584. */
  35585. readonly name: string;
  35586. /**
  35587. * Initializes the behavior
  35588. */
  35589. init(): void;
  35590. /**
  35591. * Attaches the fade behavior on the passed in mesh
  35592. * @param ownerNode The mesh that will be faded in/out once attached
  35593. */
  35594. attach(ownerNode: Mesh): void;
  35595. /**
  35596. * Detaches the behavior from the mesh
  35597. */
  35598. detach(): void;
  35599. /**
  35600. * Triggers the mesh to begin fading in or out
  35601. * @param value if the object should fade in or out (true to fade in)
  35602. */
  35603. fadeIn(value: boolean): void;
  35604. private _update;
  35605. private _setAllVisibility;
  35606. }
  35607. }
  35608. declare module "babylonjs/Misc/pivotTools" {
  35609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35610. /**
  35611. * Class containing a set of static utilities functions for managing Pivots
  35612. * @hidden
  35613. */
  35614. export class PivotTools {
  35615. private static _PivotCached;
  35616. private static _OldPivotPoint;
  35617. private static _PivotTranslation;
  35618. private static _PivotTmpVector;
  35619. /** @hidden */
  35620. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35621. /** @hidden */
  35622. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35623. }
  35624. }
  35625. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35626. import { Scene } from "babylonjs/scene";
  35627. import { Vector4, Plane } from "babylonjs/Maths/math";
  35628. import { Mesh } from "babylonjs/Meshes/mesh";
  35629. /**
  35630. * Class containing static functions to help procedurally build meshes
  35631. */
  35632. export class PlaneBuilder {
  35633. /**
  35634. * Creates a plane mesh
  35635. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35636. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35637. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35638. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35639. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35641. * @param name defines the name of the mesh
  35642. * @param options defines the options used to create the mesh
  35643. * @param scene defines the hosting scene
  35644. * @returns the plane mesh
  35645. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35646. */
  35647. static CreatePlane(name: string, options: {
  35648. size?: number;
  35649. width?: number;
  35650. height?: number;
  35651. sideOrientation?: number;
  35652. frontUVs?: Vector4;
  35653. backUVs?: Vector4;
  35654. updatable?: boolean;
  35655. sourcePlane?: Plane;
  35656. }, scene: Scene): Mesh;
  35657. }
  35658. }
  35659. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35660. import { Behavior } from "babylonjs/Behaviors/behavior";
  35661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35662. import { Observable } from "babylonjs/Misc/observable";
  35663. import { Vector3 } from "babylonjs/Maths/math";
  35664. import { Ray } from "babylonjs/Culling/ray";
  35665. import "babylonjs/Meshes/Builders/planeBuilder";
  35666. /**
  35667. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35668. */
  35669. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35670. private static _AnyMouseID;
  35671. private _attachedNode;
  35672. private _dragPlane;
  35673. private _scene;
  35674. private _pointerObserver;
  35675. private _beforeRenderObserver;
  35676. private static _planeScene;
  35677. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35678. /**
  35679. * 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)
  35680. */
  35681. maxDragAngle: number;
  35682. /**
  35683. * @hidden
  35684. */
  35685. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35686. /**
  35687. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35688. */
  35689. currentDraggingPointerID: number;
  35690. /**
  35691. * The last position where the pointer hit the drag plane in world space
  35692. */
  35693. lastDragPosition: Vector3;
  35694. /**
  35695. * If the behavior is currently in a dragging state
  35696. */
  35697. dragging: boolean;
  35698. /**
  35699. * 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)
  35700. */
  35701. dragDeltaRatio: number;
  35702. /**
  35703. * If the drag plane orientation should be updated during the dragging (Default: true)
  35704. */
  35705. updateDragPlane: boolean;
  35706. private _debugMode;
  35707. private _moving;
  35708. /**
  35709. * Fires each time the attached mesh is dragged with the pointer
  35710. * * delta between last drag position and current drag position in world space
  35711. * * dragDistance along the drag axis
  35712. * * dragPlaneNormal normal of the current drag plane used during the drag
  35713. * * dragPlanePoint in world space where the drag intersects the drag plane
  35714. */
  35715. onDragObservable: Observable<{
  35716. delta: Vector3;
  35717. dragPlanePoint: Vector3;
  35718. dragPlaneNormal: Vector3;
  35719. dragDistance: number;
  35720. pointerId: number;
  35721. }>;
  35722. /**
  35723. * Fires each time a drag begins (eg. mouse down on mesh)
  35724. */
  35725. onDragStartObservable: Observable<{
  35726. dragPlanePoint: Vector3;
  35727. pointerId: number;
  35728. }>;
  35729. /**
  35730. * Fires each time a drag ends (eg. mouse release after drag)
  35731. */
  35732. onDragEndObservable: Observable<{
  35733. dragPlanePoint: Vector3;
  35734. pointerId: number;
  35735. }>;
  35736. /**
  35737. * If the attached mesh should be moved when dragged
  35738. */
  35739. moveAttached: boolean;
  35740. /**
  35741. * If the drag behavior will react to drag events (Default: true)
  35742. */
  35743. enabled: boolean;
  35744. /**
  35745. * If camera controls should be detached during the drag
  35746. */
  35747. detachCameraControls: boolean;
  35748. /**
  35749. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35750. */
  35751. useObjectOrienationForDragging: boolean;
  35752. private _options;
  35753. /**
  35754. * Creates a pointer drag behavior that can be attached to a mesh
  35755. * @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)
  35756. */
  35757. constructor(options?: {
  35758. dragAxis?: Vector3;
  35759. dragPlaneNormal?: Vector3;
  35760. });
  35761. /**
  35762. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35763. */
  35764. validateDrag: (targetPosition: Vector3) => boolean;
  35765. /**
  35766. * The name of the behavior
  35767. */
  35768. readonly name: string;
  35769. /**
  35770. * Initializes the behavior
  35771. */
  35772. init(): void;
  35773. private _tmpVector;
  35774. private _alternatePickedPoint;
  35775. private _worldDragAxis;
  35776. private _targetPosition;
  35777. private _attachedElement;
  35778. /**
  35779. * Attaches the drag behavior the passed in mesh
  35780. * @param ownerNode The mesh that will be dragged around once attached
  35781. */
  35782. attach(ownerNode: AbstractMesh): void;
  35783. /**
  35784. * Force relase the drag action by code.
  35785. */
  35786. releaseDrag(): void;
  35787. private _startDragRay;
  35788. private _lastPointerRay;
  35789. /**
  35790. * Simulates the start of a pointer drag event on the behavior
  35791. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35792. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35793. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35794. */
  35795. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35796. private _startDrag;
  35797. private _dragDelta;
  35798. private _moveDrag;
  35799. private _pickWithRayOnDragPlane;
  35800. private _pointA;
  35801. private _pointB;
  35802. private _pointC;
  35803. private _lineA;
  35804. private _lineB;
  35805. private _localAxis;
  35806. private _lookAt;
  35807. private _updateDragPlanePosition;
  35808. /**
  35809. * Detaches the behavior from the mesh
  35810. */
  35811. detach(): void;
  35812. }
  35813. }
  35814. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35815. import { Mesh } from "babylonjs/Meshes/mesh";
  35816. import { Behavior } from "babylonjs/Behaviors/behavior";
  35817. /**
  35818. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35819. */
  35820. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35821. private _dragBehaviorA;
  35822. private _dragBehaviorB;
  35823. private _startDistance;
  35824. private _initialScale;
  35825. private _targetScale;
  35826. private _ownerNode;
  35827. private _sceneRenderObserver;
  35828. /**
  35829. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35830. */
  35831. constructor();
  35832. /**
  35833. * The name of the behavior
  35834. */
  35835. readonly name: string;
  35836. /**
  35837. * Initializes the behavior
  35838. */
  35839. init(): void;
  35840. private _getCurrentDistance;
  35841. /**
  35842. * Attaches the scale behavior the passed in mesh
  35843. * @param ownerNode The mesh that will be scaled around once attached
  35844. */
  35845. attach(ownerNode: Mesh): void;
  35846. /**
  35847. * Detaches the behavior from the mesh
  35848. */
  35849. detach(): void;
  35850. }
  35851. }
  35852. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35853. import { Behavior } from "babylonjs/Behaviors/behavior";
  35854. import { Mesh } from "babylonjs/Meshes/mesh";
  35855. import { Observable } from "babylonjs/Misc/observable";
  35856. /**
  35857. * 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
  35858. */
  35859. export class SixDofDragBehavior implements Behavior<Mesh> {
  35860. private static _virtualScene;
  35861. private _ownerNode;
  35862. private _sceneRenderObserver;
  35863. private _scene;
  35864. private _targetPosition;
  35865. private _virtualOriginMesh;
  35866. private _virtualDragMesh;
  35867. private _pointerObserver;
  35868. private _moving;
  35869. private _startingOrientation;
  35870. /**
  35871. * 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)
  35872. */
  35873. private zDragFactor;
  35874. /**
  35875. * If the object should rotate to face the drag origin
  35876. */
  35877. rotateDraggedObject: boolean;
  35878. /**
  35879. * If the behavior is currently in a dragging state
  35880. */
  35881. dragging: boolean;
  35882. /**
  35883. * 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)
  35884. */
  35885. dragDeltaRatio: number;
  35886. /**
  35887. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35888. */
  35889. currentDraggingPointerID: number;
  35890. /**
  35891. * If camera controls should be detached during the drag
  35892. */
  35893. detachCameraControls: boolean;
  35894. /**
  35895. * Fires each time a drag starts
  35896. */
  35897. onDragStartObservable: Observable<{}>;
  35898. /**
  35899. * Fires each time a drag ends (eg. mouse release after drag)
  35900. */
  35901. onDragEndObservable: Observable<{}>;
  35902. /**
  35903. * 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
  35904. */
  35905. constructor();
  35906. /**
  35907. * The name of the behavior
  35908. */
  35909. readonly name: string;
  35910. /**
  35911. * Initializes the behavior
  35912. */
  35913. init(): void;
  35914. /**
  35915. * Attaches the scale behavior the passed in mesh
  35916. * @param ownerNode The mesh that will be scaled around once attached
  35917. */
  35918. attach(ownerNode: Mesh): void;
  35919. /**
  35920. * Detaches the behavior from the mesh
  35921. */
  35922. detach(): void;
  35923. }
  35924. }
  35925. declare module "babylonjs/Behaviors/Meshes/index" {
  35926. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  35927. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  35928. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  35929. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  35930. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  35931. }
  35932. declare module "babylonjs/Behaviors/index" {
  35933. export * from "babylonjs/Behaviors/behavior";
  35934. export * from "babylonjs/Behaviors/Cameras/index";
  35935. export * from "babylonjs/Behaviors/Meshes/index";
  35936. }
  35937. declare module "babylonjs/Bones/boneIKController" {
  35938. import { Bone } from "babylonjs/Bones/bone";
  35939. import { Vector3 } from "babylonjs/Maths/math";
  35940. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35941. import { Nullable } from "babylonjs/types";
  35942. /**
  35943. * Class used to apply inverse kinematics to bones
  35944. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35945. */
  35946. export class BoneIKController {
  35947. private static _tmpVecs;
  35948. private static _tmpQuat;
  35949. private static _tmpMats;
  35950. /**
  35951. * Gets or sets the target mesh
  35952. */
  35953. targetMesh: AbstractMesh;
  35954. /** Gets or sets the mesh used as pole */
  35955. poleTargetMesh: AbstractMesh;
  35956. /**
  35957. * Gets or sets the bone used as pole
  35958. */
  35959. poleTargetBone: Nullable<Bone>;
  35960. /**
  35961. * Gets or sets the target position
  35962. */
  35963. targetPosition: Vector3;
  35964. /**
  35965. * Gets or sets the pole target position
  35966. */
  35967. poleTargetPosition: Vector3;
  35968. /**
  35969. * Gets or sets the pole target local offset
  35970. */
  35971. poleTargetLocalOffset: Vector3;
  35972. /**
  35973. * Gets or sets the pole angle
  35974. */
  35975. poleAngle: number;
  35976. /**
  35977. * Gets or sets the mesh associated with the controller
  35978. */
  35979. mesh: AbstractMesh;
  35980. /**
  35981. * 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)
  35982. */
  35983. slerpAmount: number;
  35984. private _bone1Quat;
  35985. private _bone1Mat;
  35986. private _bone2Ang;
  35987. private _bone1;
  35988. private _bone2;
  35989. private _bone1Length;
  35990. private _bone2Length;
  35991. private _maxAngle;
  35992. private _maxReach;
  35993. private _rightHandedSystem;
  35994. private _bendAxis;
  35995. private _slerping;
  35996. private _adjustRoll;
  35997. /**
  35998. * Gets or sets maximum allowed angle
  35999. */
  36000. maxAngle: number;
  36001. /**
  36002. * Creates a new BoneIKController
  36003. * @param mesh defines the mesh to control
  36004. * @param bone defines the bone to control
  36005. * @param options defines options to set up the controller
  36006. */
  36007. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36008. targetMesh?: AbstractMesh;
  36009. poleTargetMesh?: AbstractMesh;
  36010. poleTargetBone?: Bone;
  36011. poleTargetLocalOffset?: Vector3;
  36012. poleAngle?: number;
  36013. bendAxis?: Vector3;
  36014. maxAngle?: number;
  36015. slerpAmount?: number;
  36016. });
  36017. private _setMaxAngle;
  36018. /**
  36019. * Force the controller to update the bones
  36020. */
  36021. update(): void;
  36022. }
  36023. }
  36024. declare module "babylonjs/Bones/boneLookController" {
  36025. import { Vector3, Space } from "babylonjs/Maths/math";
  36026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36027. import { Bone } from "babylonjs/Bones/bone";
  36028. /**
  36029. * Class used to make a bone look toward a point in space
  36030. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36031. */
  36032. export class BoneLookController {
  36033. private static _tmpVecs;
  36034. private static _tmpQuat;
  36035. private static _tmpMats;
  36036. /**
  36037. * The target Vector3 that the bone will look at
  36038. */
  36039. target: Vector3;
  36040. /**
  36041. * The mesh that the bone is attached to
  36042. */
  36043. mesh: AbstractMesh;
  36044. /**
  36045. * The bone that will be looking to the target
  36046. */
  36047. bone: Bone;
  36048. /**
  36049. * The up axis of the coordinate system that is used when the bone is rotated
  36050. */
  36051. upAxis: Vector3;
  36052. /**
  36053. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36054. */
  36055. upAxisSpace: Space;
  36056. /**
  36057. * Used to make an adjustment to the yaw of the bone
  36058. */
  36059. adjustYaw: number;
  36060. /**
  36061. * Used to make an adjustment to the pitch of the bone
  36062. */
  36063. adjustPitch: number;
  36064. /**
  36065. * Used to make an adjustment to the roll of the bone
  36066. */
  36067. adjustRoll: number;
  36068. /**
  36069. * 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)
  36070. */
  36071. slerpAmount: number;
  36072. private _minYaw;
  36073. private _maxYaw;
  36074. private _minPitch;
  36075. private _maxPitch;
  36076. private _minYawSin;
  36077. private _minYawCos;
  36078. private _maxYawSin;
  36079. private _maxYawCos;
  36080. private _midYawConstraint;
  36081. private _minPitchTan;
  36082. private _maxPitchTan;
  36083. private _boneQuat;
  36084. private _slerping;
  36085. private _transformYawPitch;
  36086. private _transformYawPitchInv;
  36087. private _firstFrameSkipped;
  36088. private _yawRange;
  36089. private _fowardAxis;
  36090. /**
  36091. * Gets or sets the minimum yaw angle that the bone can look to
  36092. */
  36093. minYaw: number;
  36094. /**
  36095. * Gets or sets the maximum yaw angle that the bone can look to
  36096. */
  36097. maxYaw: number;
  36098. /**
  36099. * Gets or sets the minimum pitch angle that the bone can look to
  36100. */
  36101. minPitch: number;
  36102. /**
  36103. * Gets or sets the maximum pitch angle that the bone can look to
  36104. */
  36105. maxPitch: number;
  36106. /**
  36107. * Create a BoneLookController
  36108. * @param mesh the mesh that the bone belongs to
  36109. * @param bone the bone that will be looking to the target
  36110. * @param target the target Vector3 to look at
  36111. * @param options optional settings:
  36112. * * maxYaw: the maximum angle the bone will yaw to
  36113. * * minYaw: the minimum angle the bone will yaw to
  36114. * * maxPitch: the maximum angle the bone will pitch to
  36115. * * minPitch: the minimum angle the bone will yaw to
  36116. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36117. * * upAxis: the up axis of the coordinate system
  36118. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36119. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36120. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36121. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36122. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36123. * * adjustRoll: used to make an adjustment to the roll of the bone
  36124. **/
  36125. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36126. maxYaw?: number;
  36127. minYaw?: number;
  36128. maxPitch?: number;
  36129. minPitch?: number;
  36130. slerpAmount?: number;
  36131. upAxis?: Vector3;
  36132. upAxisSpace?: Space;
  36133. yawAxis?: Vector3;
  36134. pitchAxis?: Vector3;
  36135. adjustYaw?: number;
  36136. adjustPitch?: number;
  36137. adjustRoll?: number;
  36138. });
  36139. /**
  36140. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36141. */
  36142. update(): void;
  36143. private _getAngleDiff;
  36144. private _getAngleBetween;
  36145. private _isAngleBetween;
  36146. }
  36147. }
  36148. declare module "babylonjs/Bones/index" {
  36149. export * from "babylonjs/Bones/bone";
  36150. export * from "babylonjs/Bones/boneIKController";
  36151. export * from "babylonjs/Bones/boneLookController";
  36152. export * from "babylonjs/Bones/skeleton";
  36153. }
  36154. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36155. import { Nullable } from "babylonjs/types";
  36156. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36157. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36158. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36159. /**
  36160. * Manage the gamepad inputs to control an arc rotate camera.
  36161. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36162. */
  36163. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36164. /**
  36165. * Defines the camera the input is attached to.
  36166. */
  36167. camera: ArcRotateCamera;
  36168. /**
  36169. * Defines the gamepad the input is gathering event from.
  36170. */
  36171. gamepad: Nullable<Gamepad>;
  36172. /**
  36173. * Defines the gamepad rotation sensiblity.
  36174. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36175. */
  36176. gamepadRotationSensibility: number;
  36177. /**
  36178. * Defines the gamepad move sensiblity.
  36179. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36180. */
  36181. gamepadMoveSensibility: number;
  36182. private _onGamepadConnectedObserver;
  36183. private _onGamepadDisconnectedObserver;
  36184. /**
  36185. * Attach the input controls to a specific dom element to get the input from.
  36186. * @param element Defines the element the controls should be listened from
  36187. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36188. */
  36189. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36190. /**
  36191. * Detach the current controls from the specified dom element.
  36192. * @param element Defines the element to stop listening the inputs from
  36193. */
  36194. detachControl(element: Nullable<HTMLElement>): void;
  36195. /**
  36196. * Update the current camera state depending on the inputs that have been used this frame.
  36197. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36198. */
  36199. checkInputs(): void;
  36200. /**
  36201. * Gets the class name of the current intput.
  36202. * @returns the class name
  36203. */
  36204. getClassName(): string;
  36205. /**
  36206. * Get the friendly name associated with the input class.
  36207. * @returns the input friendly name
  36208. */
  36209. getSimpleName(): string;
  36210. }
  36211. }
  36212. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36213. import { Nullable } from "babylonjs/types";
  36214. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36215. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36216. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36217. interface ArcRotateCameraInputsManager {
  36218. /**
  36219. * Add orientation input support to the input manager.
  36220. * @returns the current input manager
  36221. */
  36222. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36223. }
  36224. }
  36225. /**
  36226. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36227. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36228. */
  36229. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36230. /**
  36231. * Defines the camera the input is attached to.
  36232. */
  36233. camera: ArcRotateCamera;
  36234. /**
  36235. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36236. */
  36237. alphaCorrection: number;
  36238. /**
  36239. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36240. */
  36241. gammaCorrection: number;
  36242. private _alpha;
  36243. private _gamma;
  36244. private _dirty;
  36245. private _deviceOrientationHandler;
  36246. /**
  36247. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36248. */
  36249. constructor();
  36250. /**
  36251. * Attach the input controls to a specific dom element to get the input from.
  36252. * @param element Defines the element the controls should be listened from
  36253. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36254. */
  36255. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36256. /** @hidden */
  36257. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36258. /**
  36259. * Update the current camera state depending on the inputs that have been used this frame.
  36260. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36261. */
  36262. checkInputs(): void;
  36263. /**
  36264. * Detach the current controls from the specified dom element.
  36265. * @param element Defines the element to stop listening the inputs from
  36266. */
  36267. detachControl(element: Nullable<HTMLElement>): void;
  36268. /**
  36269. * Gets the class name of the current intput.
  36270. * @returns the class name
  36271. */
  36272. getClassName(): string;
  36273. /**
  36274. * Get the friendly name associated with the input class.
  36275. * @returns the input friendly name
  36276. */
  36277. getSimpleName(): string;
  36278. }
  36279. }
  36280. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36281. import { Nullable } from "babylonjs/types";
  36282. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36283. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36284. /**
  36285. * Listen to mouse events to control the camera.
  36286. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36287. */
  36288. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36289. /**
  36290. * Defines the camera the input is attached to.
  36291. */
  36292. camera: FlyCamera;
  36293. /**
  36294. * Defines if touch is enabled. (Default is true.)
  36295. */
  36296. touchEnabled: boolean;
  36297. /**
  36298. * Defines the buttons associated with the input to handle camera rotation.
  36299. */
  36300. buttons: number[];
  36301. /**
  36302. * Assign buttons for Yaw control.
  36303. */
  36304. buttonsYaw: number[];
  36305. /**
  36306. * Assign buttons for Pitch control.
  36307. */
  36308. buttonsPitch: number[];
  36309. /**
  36310. * Assign buttons for Roll control.
  36311. */
  36312. buttonsRoll: number[];
  36313. /**
  36314. * Detect if any button is being pressed while mouse is moved.
  36315. * -1 = Mouse locked.
  36316. * 0 = Left button.
  36317. * 1 = Middle Button.
  36318. * 2 = Right Button.
  36319. */
  36320. activeButton: number;
  36321. /**
  36322. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36323. * Higher values reduce its sensitivity.
  36324. */
  36325. angularSensibility: number;
  36326. private _mousemoveCallback;
  36327. private _observer;
  36328. private _rollObserver;
  36329. private previousPosition;
  36330. private noPreventDefault;
  36331. private element;
  36332. /**
  36333. * Listen to mouse events to control the camera.
  36334. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36336. */
  36337. constructor(touchEnabled?: boolean);
  36338. /**
  36339. * Attach the mouse control to the HTML DOM element.
  36340. * @param element Defines the element that listens to the input events.
  36341. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36342. */
  36343. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36344. /**
  36345. * Detach the current controls from the specified dom element.
  36346. * @param element Defines the element to stop listening the inputs from
  36347. */
  36348. detachControl(element: Nullable<HTMLElement>): void;
  36349. /**
  36350. * Gets the class name of the current input.
  36351. * @returns the class name.
  36352. */
  36353. getClassName(): string;
  36354. /**
  36355. * Get the friendly name associated with the input class.
  36356. * @returns the input's friendly name.
  36357. */
  36358. getSimpleName(): string;
  36359. private _pointerInput;
  36360. private _onMouseMove;
  36361. /**
  36362. * Rotate camera by mouse offset.
  36363. */
  36364. private rotateCamera;
  36365. }
  36366. }
  36367. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36368. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36369. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36370. /**
  36371. * Default Inputs manager for the FlyCamera.
  36372. * It groups all the default supported inputs for ease of use.
  36373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36374. */
  36375. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36376. /**
  36377. * Instantiates a new FlyCameraInputsManager.
  36378. * @param camera Defines the camera the inputs belong to.
  36379. */
  36380. constructor(camera: FlyCamera);
  36381. /**
  36382. * Add keyboard input support to the input manager.
  36383. * @returns the new FlyCameraKeyboardMoveInput().
  36384. */
  36385. addKeyboard(): FlyCameraInputsManager;
  36386. /**
  36387. * Add mouse input support to the input manager.
  36388. * @param touchEnabled Enable touch screen support.
  36389. * @returns the new FlyCameraMouseInput().
  36390. */
  36391. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36392. }
  36393. }
  36394. declare module "babylonjs/Cameras/flyCamera" {
  36395. import { Scene } from "babylonjs/scene";
  36396. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36398. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36399. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36400. /**
  36401. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36402. * such as in a 3D Space Shooter or a Flight Simulator.
  36403. */
  36404. export class FlyCamera extends TargetCamera {
  36405. /**
  36406. * Define the collision ellipsoid of the camera.
  36407. * This is helpful for simulating a camera body, like a player's body.
  36408. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36409. */
  36410. ellipsoid: Vector3;
  36411. /**
  36412. * Define an offset for the position of the ellipsoid around the camera.
  36413. * This can be helpful if the camera is attached away from the player's body center,
  36414. * such as at its head.
  36415. */
  36416. ellipsoidOffset: Vector3;
  36417. /**
  36418. * Enable or disable collisions of the camera with the rest of the scene objects.
  36419. */
  36420. checkCollisions: boolean;
  36421. /**
  36422. * Enable or disable gravity on the camera.
  36423. */
  36424. applyGravity: boolean;
  36425. /**
  36426. * Define the current direction the camera is moving to.
  36427. */
  36428. cameraDirection: Vector3;
  36429. /**
  36430. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36431. * This overrides and empties cameraRotation.
  36432. */
  36433. rotationQuaternion: Quaternion;
  36434. /**
  36435. * Track Roll to maintain the wanted Rolling when looking around.
  36436. */
  36437. _trackRoll: number;
  36438. /**
  36439. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36440. */
  36441. rollCorrect: number;
  36442. /**
  36443. * Mimic a banked turn, Rolling the camera when Yawing.
  36444. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36445. */
  36446. bankedTurn: boolean;
  36447. /**
  36448. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36449. */
  36450. bankedTurnLimit: number;
  36451. /**
  36452. * Value of 0 disables the banked Roll.
  36453. * Value of 1 is equal to the Yaw angle in radians.
  36454. */
  36455. bankedTurnMultiplier: number;
  36456. /**
  36457. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36458. */
  36459. inputs: FlyCameraInputsManager;
  36460. /**
  36461. * Gets the input sensibility for mouse input.
  36462. * Higher values reduce sensitivity.
  36463. */
  36464. /**
  36465. * Sets the input sensibility for a mouse input.
  36466. * Higher values reduce sensitivity.
  36467. */
  36468. angularSensibility: number;
  36469. /**
  36470. * Get the keys for camera movement forward.
  36471. */
  36472. /**
  36473. * Set the keys for camera movement forward.
  36474. */
  36475. keysForward: number[];
  36476. /**
  36477. * Get the keys for camera movement backward.
  36478. */
  36479. keysBackward: number[];
  36480. /**
  36481. * Get the keys for camera movement up.
  36482. */
  36483. /**
  36484. * Set the keys for camera movement up.
  36485. */
  36486. keysUp: number[];
  36487. /**
  36488. * Get the keys for camera movement down.
  36489. */
  36490. /**
  36491. * Set the keys for camera movement down.
  36492. */
  36493. keysDown: number[];
  36494. /**
  36495. * Get the keys for camera movement left.
  36496. */
  36497. /**
  36498. * Set the keys for camera movement left.
  36499. */
  36500. keysLeft: number[];
  36501. /**
  36502. * Set the keys for camera movement right.
  36503. */
  36504. /**
  36505. * Set the keys for camera movement right.
  36506. */
  36507. keysRight: number[];
  36508. /**
  36509. * Event raised when the camera collides with a mesh in the scene.
  36510. */
  36511. onCollide: (collidedMesh: AbstractMesh) => void;
  36512. private _collider;
  36513. private _needMoveForGravity;
  36514. private _oldPosition;
  36515. private _diffPosition;
  36516. private _newPosition;
  36517. /** @hidden */
  36518. _localDirection: Vector3;
  36519. /** @hidden */
  36520. _transformedDirection: Vector3;
  36521. /**
  36522. * Instantiates a FlyCamera.
  36523. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36524. * such as in a 3D Space Shooter or a Flight Simulator.
  36525. * @param name Define the name of the camera in the scene.
  36526. * @param position Define the starting position of the camera in the scene.
  36527. * @param scene Define the scene the camera belongs to.
  36528. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36529. */
  36530. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36531. /**
  36532. * Attach a control to the HTML DOM element.
  36533. * @param element Defines the element that listens to the input events.
  36534. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36535. */
  36536. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36537. /**
  36538. * Detach a control from the HTML DOM element.
  36539. * The camera will stop reacting to that input.
  36540. * @param element Defines the element that listens to the input events.
  36541. */
  36542. detachControl(element: HTMLElement): void;
  36543. private _collisionMask;
  36544. /**
  36545. * Get the mask that the camera ignores in collision events.
  36546. */
  36547. /**
  36548. * Set the mask that the camera ignores in collision events.
  36549. */
  36550. collisionMask: number;
  36551. /** @hidden */
  36552. _collideWithWorld(displacement: Vector3): void;
  36553. /** @hidden */
  36554. private _onCollisionPositionChange;
  36555. /** @hidden */
  36556. _checkInputs(): void;
  36557. /** @hidden */
  36558. _decideIfNeedsToMove(): boolean;
  36559. /** @hidden */
  36560. _updatePosition(): void;
  36561. /**
  36562. * Restore the Roll to its target value at the rate specified.
  36563. * @param rate - Higher means slower restoring.
  36564. * @hidden
  36565. */
  36566. restoreRoll(rate: number): void;
  36567. /**
  36568. * Destroy the camera and release the current resources held by it.
  36569. */
  36570. dispose(): void;
  36571. /**
  36572. * Get the current object class name.
  36573. * @returns the class name.
  36574. */
  36575. getClassName(): string;
  36576. }
  36577. }
  36578. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36579. import { Nullable } from "babylonjs/types";
  36580. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36581. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36582. /**
  36583. * Listen to keyboard events to control the camera.
  36584. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36585. */
  36586. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36587. /**
  36588. * Defines the camera the input is attached to.
  36589. */
  36590. camera: FlyCamera;
  36591. /**
  36592. * The list of keyboard keys used to control the forward move of the camera.
  36593. */
  36594. keysForward: number[];
  36595. /**
  36596. * The list of keyboard keys used to control the backward move of the camera.
  36597. */
  36598. keysBackward: number[];
  36599. /**
  36600. * The list of keyboard keys used to control the forward move of the camera.
  36601. */
  36602. keysUp: number[];
  36603. /**
  36604. * The list of keyboard keys used to control the backward move of the camera.
  36605. */
  36606. keysDown: number[];
  36607. /**
  36608. * The list of keyboard keys used to control the right strafe move of the camera.
  36609. */
  36610. keysRight: number[];
  36611. /**
  36612. * The list of keyboard keys used to control the left strafe move of the camera.
  36613. */
  36614. keysLeft: number[];
  36615. private _keys;
  36616. private _onCanvasBlurObserver;
  36617. private _onKeyboardObserver;
  36618. private _engine;
  36619. private _scene;
  36620. /**
  36621. * Attach the input controls to a specific dom element to get the input from.
  36622. * @param element Defines the element the controls should be listened from
  36623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36624. */
  36625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36626. /**
  36627. * Detach the current controls from the specified dom element.
  36628. * @param element Defines the element to stop listening the inputs from
  36629. */
  36630. detachControl(element: Nullable<HTMLElement>): void;
  36631. /**
  36632. * Gets the class name of the current intput.
  36633. * @returns the class name
  36634. */
  36635. getClassName(): string;
  36636. /** @hidden */
  36637. _onLostFocus(e: FocusEvent): void;
  36638. /**
  36639. * Get the friendly name associated with the input class.
  36640. * @returns the input friendly name
  36641. */
  36642. getSimpleName(): string;
  36643. /**
  36644. * Update the current camera state depending on the inputs that have been used this frame.
  36645. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36646. */
  36647. checkInputs(): void;
  36648. }
  36649. }
  36650. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36651. import { Nullable } from "babylonjs/types";
  36652. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36653. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36654. /**
  36655. * Manage the mouse wheel inputs to control a follow camera.
  36656. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36657. */
  36658. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36659. /**
  36660. * Defines the camera the input is attached to.
  36661. */
  36662. camera: FollowCamera;
  36663. /**
  36664. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36665. */
  36666. axisControlRadius: boolean;
  36667. /**
  36668. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36669. */
  36670. axisControlHeight: boolean;
  36671. /**
  36672. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36673. */
  36674. axisControlRotation: boolean;
  36675. /**
  36676. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36677. * relation to mouseWheel events.
  36678. */
  36679. wheelPrecision: number;
  36680. /**
  36681. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36682. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36683. */
  36684. wheelDeltaPercentage: number;
  36685. private _wheel;
  36686. private _observer;
  36687. /**
  36688. * Attach the input controls to a specific dom element to get the input from.
  36689. * @param element Defines the element the controls should be listened from
  36690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36691. */
  36692. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36693. /**
  36694. * Detach the current controls from the specified dom element.
  36695. * @param element Defines the element to stop listening the inputs from
  36696. */
  36697. detachControl(element: Nullable<HTMLElement>): void;
  36698. /**
  36699. * Gets the class name of the current intput.
  36700. * @returns the class name
  36701. */
  36702. getClassName(): string;
  36703. /**
  36704. * Get the friendly name associated with the input class.
  36705. * @returns the input friendly name
  36706. */
  36707. getSimpleName(): string;
  36708. }
  36709. }
  36710. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  36711. import { Nullable } from "babylonjs/types";
  36712. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36713. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36714. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36715. /**
  36716. * Manage the pointers inputs to control an follow camera.
  36717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36718. */
  36719. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36720. /**
  36721. * Defines the camera the input is attached to.
  36722. */
  36723. camera: FollowCamera;
  36724. /**
  36725. * Gets the class name of the current input.
  36726. * @returns the class name
  36727. */
  36728. getClassName(): string;
  36729. /**
  36730. * Defines the pointer angular sensibility along the X axis or how fast is
  36731. * the camera rotating.
  36732. * A negative number will reverse the axis direction.
  36733. */
  36734. angularSensibilityX: number;
  36735. /**
  36736. * Defines the pointer angular sensibility along the Y axis or how fast is
  36737. * the camera rotating.
  36738. * A negative number will reverse the axis direction.
  36739. */
  36740. angularSensibilityY: number;
  36741. /**
  36742. * Defines the pointer pinch precision or how fast is the camera zooming.
  36743. * A negative number will reverse the axis direction.
  36744. */
  36745. pinchPrecision: number;
  36746. /**
  36747. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36748. * from 0.
  36749. * It defines the percentage of current camera.radius to use as delta when
  36750. * pinch zoom is used.
  36751. */
  36752. pinchDeltaPercentage: number;
  36753. /**
  36754. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36755. */
  36756. axisXControlRadius: boolean;
  36757. /**
  36758. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36759. */
  36760. axisXControlHeight: boolean;
  36761. /**
  36762. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36763. */
  36764. axisXControlRotation: boolean;
  36765. /**
  36766. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36767. */
  36768. axisYControlRadius: boolean;
  36769. /**
  36770. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36771. */
  36772. axisYControlHeight: boolean;
  36773. /**
  36774. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36775. */
  36776. axisYControlRotation: boolean;
  36777. /**
  36778. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36779. */
  36780. axisPinchControlRadius: boolean;
  36781. /**
  36782. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36783. */
  36784. axisPinchControlHeight: boolean;
  36785. /**
  36786. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36787. */
  36788. axisPinchControlRotation: boolean;
  36789. /**
  36790. * Log error messages if basic misconfiguration has occurred.
  36791. */
  36792. warningEnable: boolean;
  36793. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36794. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36795. private _warningCounter;
  36796. private _warning;
  36797. }
  36798. }
  36799. declare module "babylonjs/Cameras/followCameraInputsManager" {
  36800. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36801. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36802. /**
  36803. * Default Inputs manager for the FollowCamera.
  36804. * It groups all the default supported inputs for ease of use.
  36805. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36806. */
  36807. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36808. /**
  36809. * Instantiates a new FollowCameraInputsManager.
  36810. * @param camera Defines the camera the inputs belong to
  36811. */
  36812. constructor(camera: FollowCamera);
  36813. /**
  36814. * Add keyboard input support to the input manager.
  36815. * @returns the current input manager
  36816. */
  36817. addKeyboard(): FollowCameraInputsManager;
  36818. /**
  36819. * Add mouse wheel input support to the input manager.
  36820. * @returns the current input manager
  36821. */
  36822. addMouseWheel(): FollowCameraInputsManager;
  36823. /**
  36824. * Add pointers input support to the input manager.
  36825. * @returns the current input manager
  36826. */
  36827. addPointers(): FollowCameraInputsManager;
  36828. /**
  36829. * Add orientation input support to the input manager.
  36830. * @returns the current input manager
  36831. */
  36832. addVRDeviceOrientation(): FollowCameraInputsManager;
  36833. }
  36834. }
  36835. declare module "babylonjs/Cameras/followCamera" {
  36836. import { Nullable } from "babylonjs/types";
  36837. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36838. import { Scene } from "babylonjs/scene";
  36839. import { Vector3 } from "babylonjs/Maths/math";
  36840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36841. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  36842. /**
  36843. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36844. * an arc rotate version arcFollowCamera are available.
  36845. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36846. */
  36847. export class FollowCamera extends TargetCamera {
  36848. /**
  36849. * Distance the follow camera should follow an object at
  36850. */
  36851. radius: number;
  36852. /**
  36853. * Minimum allowed distance of the camera to the axis of rotation
  36854. * (The camera can not get closer).
  36855. * This can help limiting how the Camera is able to move in the scene.
  36856. */
  36857. lowerRadiusLimit: Nullable<number>;
  36858. /**
  36859. * Maximum allowed distance of the camera to the axis of rotation
  36860. * (The camera can not get further).
  36861. * This can help limiting how the Camera is able to move in the scene.
  36862. */
  36863. upperRadiusLimit: Nullable<number>;
  36864. /**
  36865. * Define a rotation offset between the camera and the object it follows
  36866. */
  36867. rotationOffset: number;
  36868. /**
  36869. * Minimum allowed angle to camera position relative to target object.
  36870. * This can help limiting how the Camera is able to move in the scene.
  36871. */
  36872. lowerRotationOffsetLimit: Nullable<number>;
  36873. /**
  36874. * Maximum allowed angle to camera position relative to target object.
  36875. * This can help limiting how the Camera is able to move in the scene.
  36876. */
  36877. upperRotationOffsetLimit: Nullable<number>;
  36878. /**
  36879. * Define a height offset between the camera and the object it follows.
  36880. * It can help following an object from the top (like a car chaing a plane)
  36881. */
  36882. heightOffset: number;
  36883. /**
  36884. * Minimum allowed height of camera position relative to target object.
  36885. * This can help limiting how the Camera is able to move in the scene.
  36886. */
  36887. lowerHeightOffsetLimit: Nullable<number>;
  36888. /**
  36889. * Maximum allowed height of camera position relative to target object.
  36890. * This can help limiting how the Camera is able to move in the scene.
  36891. */
  36892. upperHeightOffsetLimit: Nullable<number>;
  36893. /**
  36894. * Define how fast the camera can accelerate to follow it s target.
  36895. */
  36896. cameraAcceleration: number;
  36897. /**
  36898. * Define the speed limit of the camera following an object.
  36899. */
  36900. maxCameraSpeed: number;
  36901. /**
  36902. * Define the target of the camera.
  36903. */
  36904. lockedTarget: Nullable<AbstractMesh>;
  36905. /**
  36906. * Defines the input associated with the camera.
  36907. */
  36908. inputs: FollowCameraInputsManager;
  36909. /**
  36910. * Instantiates the follow camera.
  36911. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36912. * @param name Define the name of the camera in the scene
  36913. * @param position Define the position of the camera
  36914. * @param scene Define the scene the camera belong to
  36915. * @param lockedTarget Define the target of the camera
  36916. */
  36917. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36918. private _follow;
  36919. /**
  36920. * Attached controls to the current camera.
  36921. * @param element Defines the element the controls should be listened from
  36922. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36923. */
  36924. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36925. /**
  36926. * Detach the current controls from the camera.
  36927. * The camera will stop reacting to inputs.
  36928. * @param element Defines the element to stop listening the inputs from
  36929. */
  36930. detachControl(element: HTMLElement): void;
  36931. /** @hidden */
  36932. _checkInputs(): void;
  36933. private _checkLimits;
  36934. /**
  36935. * Gets the camera class name.
  36936. * @returns the class name
  36937. */
  36938. getClassName(): string;
  36939. }
  36940. /**
  36941. * Arc Rotate version of the follow camera.
  36942. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36943. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36944. */
  36945. export class ArcFollowCamera extends TargetCamera {
  36946. /** The longitudinal angle of the camera */
  36947. alpha: number;
  36948. /** The latitudinal angle of the camera */
  36949. beta: number;
  36950. /** The radius of the camera from its target */
  36951. radius: number;
  36952. /** Define the camera target (the messh it should follow) */
  36953. target: Nullable<AbstractMesh>;
  36954. private _cartesianCoordinates;
  36955. /**
  36956. * Instantiates a new ArcFollowCamera
  36957. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36958. * @param name Define the name of the camera
  36959. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36960. * @param beta Define the rotation angle of the camera around the elevation axis
  36961. * @param radius Define the radius of the camera from its target point
  36962. * @param target Define the target of the camera
  36963. * @param scene Define the scene the camera belongs to
  36964. */
  36965. constructor(name: string,
  36966. /** The longitudinal angle of the camera */
  36967. alpha: number,
  36968. /** The latitudinal angle of the camera */
  36969. beta: number,
  36970. /** The radius of the camera from its target */
  36971. radius: number,
  36972. /** Define the camera target (the messh it should follow) */
  36973. target: Nullable<AbstractMesh>, scene: Scene);
  36974. private _follow;
  36975. /** @hidden */
  36976. _checkInputs(): void;
  36977. /**
  36978. * Returns the class name of the object.
  36979. * It is mostly used internally for serialization purposes.
  36980. */
  36981. getClassName(): string;
  36982. }
  36983. }
  36984. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  36985. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36986. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36987. import { Nullable } from "babylonjs/types";
  36988. /**
  36989. * Manage the keyboard inputs to control the movement of a follow camera.
  36990. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36991. */
  36992. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36993. /**
  36994. * Defines the camera the input is attached to.
  36995. */
  36996. camera: FollowCamera;
  36997. /**
  36998. * Defines the list of key codes associated with the up action (increase heightOffset)
  36999. */
  37000. keysHeightOffsetIncr: number[];
  37001. /**
  37002. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37003. */
  37004. keysHeightOffsetDecr: number[];
  37005. /**
  37006. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37007. */
  37008. keysHeightOffsetModifierAlt: boolean;
  37009. /**
  37010. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37011. */
  37012. keysHeightOffsetModifierCtrl: boolean;
  37013. /**
  37014. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37015. */
  37016. keysHeightOffsetModifierShift: boolean;
  37017. /**
  37018. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37019. */
  37020. keysRotationOffsetIncr: number[];
  37021. /**
  37022. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37023. */
  37024. keysRotationOffsetDecr: number[];
  37025. /**
  37026. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37027. */
  37028. keysRotationOffsetModifierAlt: boolean;
  37029. /**
  37030. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37031. */
  37032. keysRotationOffsetModifierCtrl: boolean;
  37033. /**
  37034. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37035. */
  37036. keysRotationOffsetModifierShift: boolean;
  37037. /**
  37038. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37039. */
  37040. keysRadiusIncr: number[];
  37041. /**
  37042. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37043. */
  37044. keysRadiusDecr: number[];
  37045. /**
  37046. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37047. */
  37048. keysRadiusModifierAlt: boolean;
  37049. /**
  37050. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37051. */
  37052. keysRadiusModifierCtrl: boolean;
  37053. /**
  37054. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37055. */
  37056. keysRadiusModifierShift: boolean;
  37057. /**
  37058. * Defines the rate of change of heightOffset.
  37059. */
  37060. heightSensibility: number;
  37061. /**
  37062. * Defines the rate of change of rotationOffset.
  37063. */
  37064. rotationSensibility: number;
  37065. /**
  37066. * Defines the rate of change of radius.
  37067. */
  37068. radiusSensibility: number;
  37069. private _keys;
  37070. private _ctrlPressed;
  37071. private _altPressed;
  37072. private _shiftPressed;
  37073. private _onCanvasBlurObserver;
  37074. private _onKeyboardObserver;
  37075. private _engine;
  37076. private _scene;
  37077. /**
  37078. * Attach the input controls to a specific dom element to get the input from.
  37079. * @param element Defines the element the controls should be listened from
  37080. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37081. */
  37082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37083. /**
  37084. * Detach the current controls from the specified dom element.
  37085. * @param element Defines the element to stop listening the inputs from
  37086. */
  37087. detachControl(element: Nullable<HTMLElement>): void;
  37088. /**
  37089. * Update the current camera state depending on the inputs that have been used this frame.
  37090. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37091. */
  37092. checkInputs(): void;
  37093. /**
  37094. * Gets the class name of the current input.
  37095. * @returns the class name
  37096. */
  37097. getClassName(): string;
  37098. /**
  37099. * Get the friendly name associated with the input class.
  37100. * @returns the input friendly name
  37101. */
  37102. getSimpleName(): string;
  37103. /**
  37104. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37105. * allow modification of the heightOffset value.
  37106. */
  37107. private _modifierHeightOffset;
  37108. /**
  37109. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37110. * allow modification of the rotationOffset value.
  37111. */
  37112. private _modifierRotationOffset;
  37113. /**
  37114. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37115. * allow modification of the radius value.
  37116. */
  37117. private _modifierRadius;
  37118. }
  37119. }
  37120. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37121. import { Nullable } from "babylonjs/types";
  37122. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37123. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37124. module "babylonjs/Cameras/freeCameraInputsManager" {
  37125. interface FreeCameraInputsManager {
  37126. /**
  37127. * Add orientation input support to the input manager.
  37128. * @returns the current input manager
  37129. */
  37130. addDeviceOrientation(): FreeCameraInputsManager;
  37131. }
  37132. }
  37133. /**
  37134. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37135. * Screen rotation is taken into account.
  37136. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37137. */
  37138. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37139. private _camera;
  37140. private _screenOrientationAngle;
  37141. private _constantTranform;
  37142. private _screenQuaternion;
  37143. private _alpha;
  37144. private _beta;
  37145. private _gamma;
  37146. /**
  37147. * Instantiates a new input
  37148. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37149. */
  37150. constructor();
  37151. /**
  37152. * Define the camera controlled by the input.
  37153. */
  37154. camera: FreeCamera;
  37155. /**
  37156. * Attach the input controls to a specific dom element to get the input from.
  37157. * @param element Defines the element the controls should be listened from
  37158. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37159. */
  37160. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37161. private _orientationChanged;
  37162. private _deviceOrientation;
  37163. /**
  37164. * Detach the current controls from the specified dom element.
  37165. * @param element Defines the element to stop listening the inputs from
  37166. */
  37167. detachControl(element: Nullable<HTMLElement>): void;
  37168. /**
  37169. * Update the current camera state depending on the inputs that have been used this frame.
  37170. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37171. */
  37172. checkInputs(): void;
  37173. /**
  37174. * Gets the class name of the current intput.
  37175. * @returns the class name
  37176. */
  37177. getClassName(): string;
  37178. /**
  37179. * Get the friendly name associated with the input class.
  37180. * @returns the input friendly name
  37181. */
  37182. getSimpleName(): string;
  37183. }
  37184. }
  37185. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37186. import { Nullable } from "babylonjs/types";
  37187. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37188. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37189. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37190. /**
  37191. * Manage the gamepad inputs to control a free camera.
  37192. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37193. */
  37194. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37195. /**
  37196. * Define the camera the input is attached to.
  37197. */
  37198. camera: FreeCamera;
  37199. /**
  37200. * Define the Gamepad controlling the input
  37201. */
  37202. gamepad: Nullable<Gamepad>;
  37203. /**
  37204. * Defines the gamepad rotation sensiblity.
  37205. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37206. */
  37207. gamepadAngularSensibility: number;
  37208. /**
  37209. * Defines the gamepad move sensiblity.
  37210. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37211. */
  37212. gamepadMoveSensibility: number;
  37213. private _onGamepadConnectedObserver;
  37214. private _onGamepadDisconnectedObserver;
  37215. private _cameraTransform;
  37216. private _deltaTransform;
  37217. private _vector3;
  37218. private _vector2;
  37219. /**
  37220. * Attach the input controls to a specific dom element to get the input from.
  37221. * @param element Defines the element the controls should be listened from
  37222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37223. */
  37224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37225. /**
  37226. * Detach the current controls from the specified dom element.
  37227. * @param element Defines the element to stop listening the inputs from
  37228. */
  37229. detachControl(element: Nullable<HTMLElement>): void;
  37230. /**
  37231. * Update the current camera state depending on the inputs that have been used this frame.
  37232. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37233. */
  37234. checkInputs(): void;
  37235. /**
  37236. * Gets the class name of the current intput.
  37237. * @returns the class name
  37238. */
  37239. getClassName(): string;
  37240. /**
  37241. * Get the friendly name associated with the input class.
  37242. * @returns the input friendly name
  37243. */
  37244. getSimpleName(): string;
  37245. }
  37246. }
  37247. declare module "babylonjs/Misc/virtualJoystick" {
  37248. import { Nullable } from "babylonjs/types";
  37249. import { Vector3 } from "babylonjs/Maths/math";
  37250. /**
  37251. * Defines the potential axis of a Joystick
  37252. */
  37253. export enum JoystickAxis {
  37254. /** X axis */
  37255. X = 0,
  37256. /** Y axis */
  37257. Y = 1,
  37258. /** Z axis */
  37259. Z = 2
  37260. }
  37261. /**
  37262. * Class used to define virtual joystick (used in touch mode)
  37263. */
  37264. export class VirtualJoystick {
  37265. /**
  37266. * Gets or sets a boolean indicating that left and right values must be inverted
  37267. */
  37268. reverseLeftRight: boolean;
  37269. /**
  37270. * Gets or sets a boolean indicating that up and down values must be inverted
  37271. */
  37272. reverseUpDown: boolean;
  37273. /**
  37274. * Gets the offset value for the position (ie. the change of the position value)
  37275. */
  37276. deltaPosition: Vector3;
  37277. /**
  37278. * Gets a boolean indicating if the virtual joystick was pressed
  37279. */
  37280. pressed: boolean;
  37281. /**
  37282. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37283. */
  37284. static Canvas: Nullable<HTMLCanvasElement>;
  37285. private static _globalJoystickIndex;
  37286. private static vjCanvasContext;
  37287. private static vjCanvasWidth;
  37288. private static vjCanvasHeight;
  37289. private static halfWidth;
  37290. private _action;
  37291. private _axisTargetedByLeftAndRight;
  37292. private _axisTargetedByUpAndDown;
  37293. private _joystickSensibility;
  37294. private _inversedSensibility;
  37295. private _joystickPointerID;
  37296. private _joystickColor;
  37297. private _joystickPointerPos;
  37298. private _joystickPreviousPointerPos;
  37299. private _joystickPointerStartPos;
  37300. private _deltaJoystickVector;
  37301. private _leftJoystick;
  37302. private _touches;
  37303. private _onPointerDownHandlerRef;
  37304. private _onPointerMoveHandlerRef;
  37305. private _onPointerUpHandlerRef;
  37306. private _onResize;
  37307. /**
  37308. * Creates a new virtual joystick
  37309. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37310. */
  37311. constructor(leftJoystick?: boolean);
  37312. /**
  37313. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37314. * @param newJoystickSensibility defines the new sensibility
  37315. */
  37316. setJoystickSensibility(newJoystickSensibility: number): void;
  37317. private _onPointerDown;
  37318. private _onPointerMove;
  37319. private _onPointerUp;
  37320. /**
  37321. * Change the color of the virtual joystick
  37322. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37323. */
  37324. setJoystickColor(newColor: string): void;
  37325. /**
  37326. * Defines a callback to call when the joystick is touched
  37327. * @param action defines the callback
  37328. */
  37329. setActionOnTouch(action: () => any): void;
  37330. /**
  37331. * Defines which axis you'd like to control for left & right
  37332. * @param axis defines the axis to use
  37333. */
  37334. setAxisForLeftRight(axis: JoystickAxis): void;
  37335. /**
  37336. * Defines which axis you'd like to control for up & down
  37337. * @param axis defines the axis to use
  37338. */
  37339. setAxisForUpDown(axis: JoystickAxis): void;
  37340. private _drawVirtualJoystick;
  37341. /**
  37342. * Release internal HTML canvas
  37343. */
  37344. releaseCanvas(): void;
  37345. }
  37346. }
  37347. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37348. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37349. import { Nullable } from "babylonjs/types";
  37350. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37351. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37352. module "babylonjs/Cameras/freeCameraInputsManager" {
  37353. interface FreeCameraInputsManager {
  37354. /**
  37355. * Add virtual joystick input support to the input manager.
  37356. * @returns the current input manager
  37357. */
  37358. addVirtualJoystick(): FreeCameraInputsManager;
  37359. }
  37360. }
  37361. /**
  37362. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37364. */
  37365. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37366. /**
  37367. * Defines the camera the input is attached to.
  37368. */
  37369. camera: FreeCamera;
  37370. private _leftjoystick;
  37371. private _rightjoystick;
  37372. /**
  37373. * Gets the left stick of the virtual joystick.
  37374. * @returns The virtual Joystick
  37375. */
  37376. getLeftJoystick(): VirtualJoystick;
  37377. /**
  37378. * Gets the right stick of the virtual joystick.
  37379. * @returns The virtual Joystick
  37380. */
  37381. getRightJoystick(): VirtualJoystick;
  37382. /**
  37383. * Update the current camera state depending on the inputs that have been used this frame.
  37384. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37385. */
  37386. checkInputs(): void;
  37387. /**
  37388. * Attach the input controls to a specific dom element to get the input from.
  37389. * @param element Defines the element the controls should be listened from
  37390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37391. */
  37392. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37393. /**
  37394. * Detach the current controls from the specified dom element.
  37395. * @param element Defines the element to stop listening the inputs from
  37396. */
  37397. detachControl(element: Nullable<HTMLElement>): void;
  37398. /**
  37399. * Gets the class name of the current intput.
  37400. * @returns the class name
  37401. */
  37402. getClassName(): string;
  37403. /**
  37404. * Get the friendly name associated with the input class.
  37405. * @returns the input friendly name
  37406. */
  37407. getSimpleName(): string;
  37408. }
  37409. }
  37410. declare module "babylonjs/Cameras/Inputs/index" {
  37411. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37412. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37413. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37414. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37415. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37416. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37417. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37418. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37419. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37420. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37421. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37422. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37423. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37424. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37425. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37426. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37427. }
  37428. declare module "babylonjs/Cameras/touchCamera" {
  37429. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37430. import { Scene } from "babylonjs/scene";
  37431. import { Vector3 } from "babylonjs/Maths/math";
  37432. /**
  37433. * This represents a FPS type of camera controlled by touch.
  37434. * This is like a universal camera minus the Gamepad controls.
  37435. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37436. */
  37437. export class TouchCamera extends FreeCamera {
  37438. /**
  37439. * Defines the touch sensibility for rotation.
  37440. * The higher the faster.
  37441. */
  37442. touchAngularSensibility: number;
  37443. /**
  37444. * Defines the touch sensibility for move.
  37445. * The higher the faster.
  37446. */
  37447. touchMoveSensibility: number;
  37448. /**
  37449. * Instantiates a new touch camera.
  37450. * This represents a FPS type of camera controlled by touch.
  37451. * This is like a universal camera minus the Gamepad controls.
  37452. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37453. * @param name Define the name of the camera in the scene
  37454. * @param position Define the start position of the camera in the scene
  37455. * @param scene Define the scene the camera belongs to
  37456. */
  37457. constructor(name: string, position: Vector3, scene: Scene);
  37458. /**
  37459. * Gets the current object class name.
  37460. * @return the class name
  37461. */
  37462. getClassName(): string;
  37463. /** @hidden */
  37464. _setupInputs(): void;
  37465. }
  37466. }
  37467. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37468. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37469. import { Scene } from "babylonjs/scene";
  37470. import { Vector3, Axis } from "babylonjs/Maths/math";
  37471. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37472. /**
  37473. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37474. * being tilted forward or back and left or right.
  37475. */
  37476. export class DeviceOrientationCamera extends FreeCamera {
  37477. private _initialQuaternion;
  37478. private _quaternionCache;
  37479. /**
  37480. * Creates a new device orientation camera
  37481. * @param name The name of the camera
  37482. * @param position The start position camera
  37483. * @param scene The scene the camera belongs to
  37484. */
  37485. constructor(name: string, position: Vector3, scene: Scene);
  37486. /**
  37487. * Gets the current instance class name ("DeviceOrientationCamera").
  37488. * This helps avoiding instanceof at run time.
  37489. * @returns the class name
  37490. */
  37491. getClassName(): string;
  37492. /**
  37493. * @hidden
  37494. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37495. */
  37496. _checkInputs(): void;
  37497. /**
  37498. * Reset the camera to its default orientation on the specified axis only.
  37499. * @param axis The axis to reset
  37500. */
  37501. resetToCurrentRotation(axis?: Axis): void;
  37502. }
  37503. }
  37504. declare module "babylonjs/Cameras/universalCamera" {
  37505. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37506. import { Scene } from "babylonjs/scene";
  37507. import { Vector3 } from "babylonjs/Maths/math";
  37508. /**
  37509. * 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,
  37510. * which still works and will still be found in many Playgrounds.
  37511. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37512. */
  37513. export class UniversalCamera extends TouchCamera {
  37514. /**
  37515. * Defines the gamepad rotation sensiblity.
  37516. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37517. */
  37518. gamepadAngularSensibility: number;
  37519. /**
  37520. * Defines the gamepad move sensiblity.
  37521. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37522. */
  37523. gamepadMoveSensibility: number;
  37524. /**
  37525. * 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,
  37526. * which still works and will still be found in many Playgrounds.
  37527. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37528. * @param name Define the name of the camera in the scene
  37529. * @param position Define the start position of the camera in the scene
  37530. * @param scene Define the scene the camera belongs to
  37531. */
  37532. constructor(name: string, position: Vector3, scene: Scene);
  37533. /**
  37534. * Gets the current object class name.
  37535. * @return the class name
  37536. */
  37537. getClassName(): string;
  37538. }
  37539. }
  37540. declare module "babylonjs/Cameras/gamepadCamera" {
  37541. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37542. import { Scene } from "babylonjs/scene";
  37543. import { Vector3 } from "babylonjs/Maths/math";
  37544. /**
  37545. * This represents a FPS type of camera. This is only here for back compat purpose.
  37546. * Please use the UniversalCamera instead as both are identical.
  37547. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37548. */
  37549. export class GamepadCamera extends UniversalCamera {
  37550. /**
  37551. * Instantiates a new Gamepad Camera
  37552. * This represents a FPS type of camera. This is only here for back compat purpose.
  37553. * Please use the UniversalCamera instead as both are identical.
  37554. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37555. * @param name Define the name of the camera in the scene
  37556. * @param position Define the start position of the camera in the scene
  37557. * @param scene Define the scene the camera belongs to
  37558. */
  37559. constructor(name: string, position: Vector3, scene: Scene);
  37560. /**
  37561. * Gets the current object class name.
  37562. * @return the class name
  37563. */
  37564. getClassName(): string;
  37565. }
  37566. }
  37567. declare module "babylonjs/Shaders/pass.fragment" {
  37568. /** @hidden */
  37569. export var passPixelShader: {
  37570. name: string;
  37571. shader: string;
  37572. };
  37573. }
  37574. declare module "babylonjs/Shaders/passCube.fragment" {
  37575. /** @hidden */
  37576. export var passCubePixelShader: {
  37577. name: string;
  37578. shader: string;
  37579. };
  37580. }
  37581. declare module "babylonjs/PostProcesses/passPostProcess" {
  37582. import { Nullable } from "babylonjs/types";
  37583. import { Camera } from "babylonjs/Cameras/camera";
  37584. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37585. import { Engine } from "babylonjs/Engines/engine";
  37586. import "babylonjs/Shaders/pass.fragment";
  37587. import "babylonjs/Shaders/passCube.fragment";
  37588. /**
  37589. * PassPostProcess which produces an output the same as it's input
  37590. */
  37591. export class PassPostProcess extends PostProcess {
  37592. /**
  37593. * Creates the PassPostProcess
  37594. * @param name The name of the effect.
  37595. * @param options The required width/height ratio to downsize to before computing the render pass.
  37596. * @param camera The camera to apply the render pass to.
  37597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37598. * @param engine The engine which the post process will be applied. (default: current engine)
  37599. * @param reusable If the post process can be reused on the same frame. (default: false)
  37600. * @param textureType The type of texture to be used when performing the post processing.
  37601. * @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)
  37602. */
  37603. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37604. }
  37605. /**
  37606. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37607. */
  37608. export class PassCubePostProcess extends PostProcess {
  37609. private _face;
  37610. /**
  37611. * Gets or sets the cube face to display.
  37612. * * 0 is +X
  37613. * * 1 is -X
  37614. * * 2 is +Y
  37615. * * 3 is -Y
  37616. * * 4 is +Z
  37617. * * 5 is -Z
  37618. */
  37619. face: number;
  37620. /**
  37621. * Creates the PassCubePostProcess
  37622. * @param name The name of the effect.
  37623. * @param options The required width/height ratio to downsize to before computing the render pass.
  37624. * @param camera The camera to apply the render pass to.
  37625. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37626. * @param engine The engine which the post process will be applied. (default: current engine)
  37627. * @param reusable If the post process can be reused on the same frame. (default: false)
  37628. * @param textureType The type of texture to be used when performing the post processing.
  37629. * @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)
  37630. */
  37631. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37632. }
  37633. }
  37634. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37635. /** @hidden */
  37636. export var anaglyphPixelShader: {
  37637. name: string;
  37638. shader: string;
  37639. };
  37640. }
  37641. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37642. import { Engine } from "babylonjs/Engines/engine";
  37643. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37644. import { Camera } from "babylonjs/Cameras/camera";
  37645. import "babylonjs/Shaders/anaglyph.fragment";
  37646. /**
  37647. * Postprocess used to generate anaglyphic rendering
  37648. */
  37649. export class AnaglyphPostProcess extends PostProcess {
  37650. private _passedProcess;
  37651. /**
  37652. * Creates a new AnaglyphPostProcess
  37653. * @param name defines postprocess name
  37654. * @param options defines creation options or target ratio scale
  37655. * @param rigCameras defines cameras using this postprocess
  37656. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37657. * @param engine defines hosting engine
  37658. * @param reusable defines if the postprocess will be reused multiple times per frame
  37659. */
  37660. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37661. }
  37662. }
  37663. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37664. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37665. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37666. import { Scene } from "babylonjs/scene";
  37667. import { Vector3 } from "babylonjs/Maths/math";
  37668. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37669. /**
  37670. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37671. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37672. */
  37673. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37674. /**
  37675. * Creates a new AnaglyphArcRotateCamera
  37676. * @param name defines camera name
  37677. * @param alpha defines alpha angle (in radians)
  37678. * @param beta defines beta angle (in radians)
  37679. * @param radius defines radius
  37680. * @param target defines camera target
  37681. * @param interaxialDistance defines distance between each color axis
  37682. * @param scene defines the hosting scene
  37683. */
  37684. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37685. /**
  37686. * Gets camera class name
  37687. * @returns AnaglyphArcRotateCamera
  37688. */
  37689. getClassName(): string;
  37690. }
  37691. }
  37692. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37693. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37694. import { Scene } from "babylonjs/scene";
  37695. import { Vector3 } from "babylonjs/Maths/math";
  37696. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37697. /**
  37698. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37699. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37700. */
  37701. export class AnaglyphFreeCamera extends FreeCamera {
  37702. /**
  37703. * Creates a new AnaglyphFreeCamera
  37704. * @param name defines camera name
  37705. * @param position defines initial position
  37706. * @param interaxialDistance defines distance between each color axis
  37707. * @param scene defines the hosting scene
  37708. */
  37709. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37710. /**
  37711. * Gets camera class name
  37712. * @returns AnaglyphFreeCamera
  37713. */
  37714. getClassName(): string;
  37715. }
  37716. }
  37717. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37718. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37719. import { Scene } from "babylonjs/scene";
  37720. import { Vector3 } from "babylonjs/Maths/math";
  37721. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37722. /**
  37723. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37724. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37725. */
  37726. export class AnaglyphGamepadCamera extends GamepadCamera {
  37727. /**
  37728. * Creates a new AnaglyphGamepadCamera
  37729. * @param name defines camera name
  37730. * @param position defines initial position
  37731. * @param interaxialDistance defines distance between each color axis
  37732. * @param scene defines the hosting scene
  37733. */
  37734. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37735. /**
  37736. * Gets camera class name
  37737. * @returns AnaglyphGamepadCamera
  37738. */
  37739. getClassName(): string;
  37740. }
  37741. }
  37742. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37743. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37744. import { Scene } from "babylonjs/scene";
  37745. import { Vector3 } from "babylonjs/Maths/math";
  37746. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37747. /**
  37748. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37749. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37750. */
  37751. export class AnaglyphUniversalCamera extends UniversalCamera {
  37752. /**
  37753. * Creates a new AnaglyphUniversalCamera
  37754. * @param name defines camera name
  37755. * @param position defines initial position
  37756. * @param interaxialDistance defines distance between each color axis
  37757. * @param scene defines the hosting scene
  37758. */
  37759. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37760. /**
  37761. * Gets camera class name
  37762. * @returns AnaglyphUniversalCamera
  37763. */
  37764. getClassName(): string;
  37765. }
  37766. }
  37767. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37768. /** @hidden */
  37769. export var stereoscopicInterlacePixelShader: {
  37770. name: string;
  37771. shader: string;
  37772. };
  37773. }
  37774. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37775. import { Camera } from "babylonjs/Cameras/camera";
  37776. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37777. import { Engine } from "babylonjs/Engines/engine";
  37778. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37779. /**
  37780. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37781. */
  37782. export class StereoscopicInterlacePostProcess extends PostProcess {
  37783. private _stepSize;
  37784. private _passedProcess;
  37785. /**
  37786. * Initializes a StereoscopicInterlacePostProcess
  37787. * @param name The name of the effect.
  37788. * @param rigCameras The rig cameras to be appled to the post process
  37789. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37790. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37791. * @param engine The engine which the post process will be applied. (default: current engine)
  37792. * @param reusable If the post process can be reused on the same frame. (default: false)
  37793. */
  37794. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37795. }
  37796. }
  37797. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37798. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37799. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37800. import { Scene } from "babylonjs/scene";
  37801. import { Vector3 } from "babylonjs/Maths/math";
  37802. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37803. /**
  37804. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37805. * @see http://doc.babylonjs.com/features/cameras
  37806. */
  37807. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37808. /**
  37809. * Creates a new StereoscopicArcRotateCamera
  37810. * @param name defines camera name
  37811. * @param alpha defines alpha angle (in radians)
  37812. * @param beta defines beta angle (in radians)
  37813. * @param radius defines radius
  37814. * @param target defines camera target
  37815. * @param interaxialDistance defines distance between each color axis
  37816. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37817. * @param scene defines the hosting scene
  37818. */
  37819. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37820. /**
  37821. * Gets camera class name
  37822. * @returns StereoscopicArcRotateCamera
  37823. */
  37824. getClassName(): string;
  37825. }
  37826. }
  37827. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37828. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37829. import { Scene } from "babylonjs/scene";
  37830. import { Vector3 } from "babylonjs/Maths/math";
  37831. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37832. /**
  37833. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37834. * @see http://doc.babylonjs.com/features/cameras
  37835. */
  37836. export class StereoscopicFreeCamera extends FreeCamera {
  37837. /**
  37838. * Creates a new StereoscopicFreeCamera
  37839. * @param name defines camera name
  37840. * @param position defines initial position
  37841. * @param interaxialDistance defines distance between each color axis
  37842. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37843. * @param scene defines the hosting scene
  37844. */
  37845. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37846. /**
  37847. * Gets camera class name
  37848. * @returns StereoscopicFreeCamera
  37849. */
  37850. getClassName(): string;
  37851. }
  37852. }
  37853. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37854. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37855. import { Scene } from "babylonjs/scene";
  37856. import { Vector3 } from "babylonjs/Maths/math";
  37857. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37858. /**
  37859. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37860. * @see http://doc.babylonjs.com/features/cameras
  37861. */
  37862. export class StereoscopicGamepadCamera extends GamepadCamera {
  37863. /**
  37864. * Creates a new StereoscopicGamepadCamera
  37865. * @param name defines camera name
  37866. * @param position defines initial position
  37867. * @param interaxialDistance defines distance between each color axis
  37868. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37869. * @param scene defines the hosting scene
  37870. */
  37871. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37872. /**
  37873. * Gets camera class name
  37874. * @returns StereoscopicGamepadCamera
  37875. */
  37876. getClassName(): string;
  37877. }
  37878. }
  37879. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37880. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37881. import { Scene } from "babylonjs/scene";
  37882. import { Vector3 } from "babylonjs/Maths/math";
  37883. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37884. /**
  37885. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37886. * @see http://doc.babylonjs.com/features/cameras
  37887. */
  37888. export class StereoscopicUniversalCamera extends UniversalCamera {
  37889. /**
  37890. * Creates a new StereoscopicUniversalCamera
  37891. * @param name defines camera name
  37892. * @param position defines initial position
  37893. * @param interaxialDistance defines distance between each color axis
  37894. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37895. * @param scene defines the hosting scene
  37896. */
  37897. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37898. /**
  37899. * Gets camera class name
  37900. * @returns StereoscopicUniversalCamera
  37901. */
  37902. getClassName(): string;
  37903. }
  37904. }
  37905. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37906. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37907. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37908. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37909. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37910. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37911. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  37912. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  37913. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  37914. }
  37915. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  37916. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37917. import { Scene } from "babylonjs/scene";
  37918. import { Vector3 } from "babylonjs/Maths/math";
  37919. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37920. /**
  37921. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37922. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37923. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37924. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37925. */
  37926. export class VirtualJoysticksCamera extends FreeCamera {
  37927. /**
  37928. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37929. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37930. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37931. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37932. * @param name Define the name of the camera in the scene
  37933. * @param position Define the start position of the camera in the scene
  37934. * @param scene Define the scene the camera belongs to
  37935. */
  37936. constructor(name: string, position: Vector3, scene: Scene);
  37937. /**
  37938. * Gets the current object class name.
  37939. * @return the class name
  37940. */
  37941. getClassName(): string;
  37942. }
  37943. }
  37944. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  37945. import { Matrix } from "babylonjs/Maths/math";
  37946. /**
  37947. * This represents all the required metrics to create a VR camera.
  37948. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37949. */
  37950. export class VRCameraMetrics {
  37951. /**
  37952. * Define the horizontal resolution off the screen.
  37953. */
  37954. hResolution: number;
  37955. /**
  37956. * Define the vertical resolution off the screen.
  37957. */
  37958. vResolution: number;
  37959. /**
  37960. * Define the horizontal screen size.
  37961. */
  37962. hScreenSize: number;
  37963. /**
  37964. * Define the vertical screen size.
  37965. */
  37966. vScreenSize: number;
  37967. /**
  37968. * Define the vertical screen center position.
  37969. */
  37970. vScreenCenter: number;
  37971. /**
  37972. * Define the distance of the eyes to the screen.
  37973. */
  37974. eyeToScreenDistance: number;
  37975. /**
  37976. * Define the distance between both lenses
  37977. */
  37978. lensSeparationDistance: number;
  37979. /**
  37980. * Define the distance between both viewer's eyes.
  37981. */
  37982. interpupillaryDistance: number;
  37983. /**
  37984. * Define the distortion factor of the VR postprocess.
  37985. * Please, touch with care.
  37986. */
  37987. distortionK: number[];
  37988. /**
  37989. * Define the chromatic aberration correction factors for the VR post process.
  37990. */
  37991. chromaAbCorrection: number[];
  37992. /**
  37993. * Define the scale factor of the post process.
  37994. * The smaller the better but the slower.
  37995. */
  37996. postProcessScaleFactor: number;
  37997. /**
  37998. * Define an offset for the lens center.
  37999. */
  38000. lensCenterOffset: number;
  38001. /**
  38002. * Define if the current vr camera should compensate the distortion of the lense or not.
  38003. */
  38004. compensateDistortion: boolean;
  38005. /**
  38006. * Gets the rendering aspect ratio based on the provided resolutions.
  38007. */
  38008. readonly aspectRatio: number;
  38009. /**
  38010. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38011. */
  38012. readonly aspectRatioFov: number;
  38013. /**
  38014. * @hidden
  38015. */
  38016. readonly leftHMatrix: Matrix;
  38017. /**
  38018. * @hidden
  38019. */
  38020. readonly rightHMatrix: Matrix;
  38021. /**
  38022. * @hidden
  38023. */
  38024. readonly leftPreViewMatrix: Matrix;
  38025. /**
  38026. * @hidden
  38027. */
  38028. readonly rightPreViewMatrix: Matrix;
  38029. /**
  38030. * Get the default VRMetrics based on the most generic setup.
  38031. * @returns the default vr metrics
  38032. */
  38033. static GetDefault(): VRCameraMetrics;
  38034. }
  38035. }
  38036. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38037. /** @hidden */
  38038. export var vrDistortionCorrectionPixelShader: {
  38039. name: string;
  38040. shader: string;
  38041. };
  38042. }
  38043. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38044. import { Camera } from "babylonjs/Cameras/camera";
  38045. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38046. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38047. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38048. /**
  38049. * VRDistortionCorrectionPostProcess used for mobile VR
  38050. */
  38051. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38052. private _isRightEye;
  38053. private _distortionFactors;
  38054. private _postProcessScaleFactor;
  38055. private _lensCenterOffset;
  38056. private _scaleIn;
  38057. private _scaleFactor;
  38058. private _lensCenter;
  38059. /**
  38060. * Initializes the VRDistortionCorrectionPostProcess
  38061. * @param name The name of the effect.
  38062. * @param camera The camera to apply the render pass to.
  38063. * @param isRightEye If this is for the right eye distortion
  38064. * @param vrMetrics All the required metrics for the VR camera
  38065. */
  38066. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38067. }
  38068. }
  38069. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38070. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38071. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38072. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38073. import { Scene } from "babylonjs/scene";
  38074. import { Vector3 } from "babylonjs/Maths/math";
  38075. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38076. import "babylonjs/Cameras/RigModes/vrRigMode";
  38077. /**
  38078. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38079. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38080. */
  38081. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38082. /**
  38083. * Creates a new VRDeviceOrientationArcRotateCamera
  38084. * @param name defines camera name
  38085. * @param alpha defines the camera rotation along the logitudinal axis
  38086. * @param beta defines the camera rotation along the latitudinal axis
  38087. * @param radius defines the camera distance from its target
  38088. * @param target defines the camera target
  38089. * @param scene defines the scene the camera belongs to
  38090. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38091. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38092. */
  38093. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38094. /**
  38095. * Gets camera class name
  38096. * @returns VRDeviceOrientationArcRotateCamera
  38097. */
  38098. getClassName(): string;
  38099. }
  38100. }
  38101. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38102. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38103. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38104. import { Scene } from "babylonjs/scene";
  38105. import { Vector3 } from "babylonjs/Maths/math";
  38106. import "babylonjs/Cameras/RigModes/vrRigMode";
  38107. /**
  38108. * Camera used to simulate VR rendering (based on FreeCamera)
  38109. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38110. */
  38111. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38112. /**
  38113. * Creates a new VRDeviceOrientationFreeCamera
  38114. * @param name defines camera name
  38115. * @param position defines the start position of the camera
  38116. * @param scene defines the scene the camera belongs to
  38117. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38118. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38119. */
  38120. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38121. /**
  38122. * Gets camera class name
  38123. * @returns VRDeviceOrientationFreeCamera
  38124. */
  38125. getClassName(): string;
  38126. }
  38127. }
  38128. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38129. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38130. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38131. import { Scene } from "babylonjs/scene";
  38132. import { Vector3 } from "babylonjs/Maths/math";
  38133. /**
  38134. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38135. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38136. */
  38137. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38138. /**
  38139. * Creates a new VRDeviceOrientationGamepadCamera
  38140. * @param name defines camera name
  38141. * @param position defines the start position of the camera
  38142. * @param scene defines the scene the camera belongs to
  38143. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38144. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38145. */
  38146. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38147. /**
  38148. * Gets camera class name
  38149. * @returns VRDeviceOrientationGamepadCamera
  38150. */
  38151. getClassName(): string;
  38152. }
  38153. }
  38154. declare module "babylonjs/Gamepads/xboxGamepad" {
  38155. import { Observable } from "babylonjs/Misc/observable";
  38156. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38157. /**
  38158. * Defines supported buttons for XBox360 compatible gamepads
  38159. */
  38160. export enum Xbox360Button {
  38161. /** A */
  38162. A = 0,
  38163. /** B */
  38164. B = 1,
  38165. /** X */
  38166. X = 2,
  38167. /** Y */
  38168. Y = 3,
  38169. /** Start */
  38170. Start = 4,
  38171. /** Back */
  38172. Back = 5,
  38173. /** Left button */
  38174. LB = 6,
  38175. /** Right button */
  38176. RB = 7,
  38177. /** Left stick */
  38178. LeftStick = 8,
  38179. /** Right stick */
  38180. RightStick = 9
  38181. }
  38182. /** Defines values for XBox360 DPad */
  38183. export enum Xbox360Dpad {
  38184. /** Up */
  38185. Up = 0,
  38186. /** Down */
  38187. Down = 1,
  38188. /** Left */
  38189. Left = 2,
  38190. /** Right */
  38191. Right = 3
  38192. }
  38193. /**
  38194. * Defines a XBox360 gamepad
  38195. */
  38196. export class Xbox360Pad extends Gamepad {
  38197. private _leftTrigger;
  38198. private _rightTrigger;
  38199. private _onlefttriggerchanged;
  38200. private _onrighttriggerchanged;
  38201. private _onbuttondown;
  38202. private _onbuttonup;
  38203. private _ondpaddown;
  38204. private _ondpadup;
  38205. /** Observable raised when a button is pressed */
  38206. onButtonDownObservable: Observable<Xbox360Button>;
  38207. /** Observable raised when a button is released */
  38208. onButtonUpObservable: Observable<Xbox360Button>;
  38209. /** Observable raised when a pad is pressed */
  38210. onPadDownObservable: Observable<Xbox360Dpad>;
  38211. /** Observable raised when a pad is released */
  38212. onPadUpObservable: Observable<Xbox360Dpad>;
  38213. private _buttonA;
  38214. private _buttonB;
  38215. private _buttonX;
  38216. private _buttonY;
  38217. private _buttonBack;
  38218. private _buttonStart;
  38219. private _buttonLB;
  38220. private _buttonRB;
  38221. private _buttonLeftStick;
  38222. private _buttonRightStick;
  38223. private _dPadUp;
  38224. private _dPadDown;
  38225. private _dPadLeft;
  38226. private _dPadRight;
  38227. private _isXboxOnePad;
  38228. /**
  38229. * Creates a new XBox360 gamepad object
  38230. * @param id defines the id of this gamepad
  38231. * @param index defines its index
  38232. * @param gamepad defines the internal HTML gamepad object
  38233. * @param xboxOne defines if it is a XBox One gamepad
  38234. */
  38235. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38236. /**
  38237. * Defines the callback to call when left trigger is pressed
  38238. * @param callback defines the callback to use
  38239. */
  38240. onlefttriggerchanged(callback: (value: number) => void): void;
  38241. /**
  38242. * Defines the callback to call when right trigger is pressed
  38243. * @param callback defines the callback to use
  38244. */
  38245. onrighttriggerchanged(callback: (value: number) => void): void;
  38246. /**
  38247. * Gets the left trigger value
  38248. */
  38249. /**
  38250. * Sets the left trigger value
  38251. */
  38252. leftTrigger: number;
  38253. /**
  38254. * Gets the right trigger value
  38255. */
  38256. /**
  38257. * Sets the right trigger value
  38258. */
  38259. rightTrigger: number;
  38260. /**
  38261. * Defines the callback to call when a button is pressed
  38262. * @param callback defines the callback to use
  38263. */
  38264. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38265. /**
  38266. * Defines the callback to call when a button is released
  38267. * @param callback defines the callback to use
  38268. */
  38269. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38270. /**
  38271. * Defines the callback to call when a pad is pressed
  38272. * @param callback defines the callback to use
  38273. */
  38274. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38275. /**
  38276. * Defines the callback to call when a pad is released
  38277. * @param callback defines the callback to use
  38278. */
  38279. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38280. private _setButtonValue;
  38281. private _setDPadValue;
  38282. /**
  38283. * Gets the value of the `A` button
  38284. */
  38285. /**
  38286. * Sets the value of the `A` button
  38287. */
  38288. buttonA: number;
  38289. /**
  38290. * Gets the value of the `B` button
  38291. */
  38292. /**
  38293. * Sets the value of the `B` button
  38294. */
  38295. buttonB: number;
  38296. /**
  38297. * Gets the value of the `X` button
  38298. */
  38299. /**
  38300. * Sets the value of the `X` button
  38301. */
  38302. buttonX: number;
  38303. /**
  38304. * Gets the value of the `Y` button
  38305. */
  38306. /**
  38307. * Sets the value of the `Y` button
  38308. */
  38309. buttonY: number;
  38310. /**
  38311. * Gets the value of the `Start` button
  38312. */
  38313. /**
  38314. * Sets the value of the `Start` button
  38315. */
  38316. buttonStart: number;
  38317. /**
  38318. * Gets the value of the `Back` button
  38319. */
  38320. /**
  38321. * Sets the value of the `Back` button
  38322. */
  38323. buttonBack: number;
  38324. /**
  38325. * Gets the value of the `Left` button
  38326. */
  38327. /**
  38328. * Sets the value of the `Left` button
  38329. */
  38330. buttonLB: number;
  38331. /**
  38332. * Gets the value of the `Right` button
  38333. */
  38334. /**
  38335. * Sets the value of the `Right` button
  38336. */
  38337. buttonRB: number;
  38338. /**
  38339. * Gets the value of the Left joystick
  38340. */
  38341. /**
  38342. * Sets the value of the Left joystick
  38343. */
  38344. buttonLeftStick: number;
  38345. /**
  38346. * Gets the value of the Right joystick
  38347. */
  38348. /**
  38349. * Sets the value of the Right joystick
  38350. */
  38351. buttonRightStick: number;
  38352. /**
  38353. * Gets the value of D-pad up
  38354. */
  38355. /**
  38356. * Sets the value of D-pad up
  38357. */
  38358. dPadUp: number;
  38359. /**
  38360. * Gets the value of D-pad down
  38361. */
  38362. /**
  38363. * Sets the value of D-pad down
  38364. */
  38365. dPadDown: number;
  38366. /**
  38367. * Gets the value of D-pad left
  38368. */
  38369. /**
  38370. * Sets the value of D-pad left
  38371. */
  38372. dPadLeft: number;
  38373. /**
  38374. * Gets the value of D-pad right
  38375. */
  38376. /**
  38377. * Sets the value of D-pad right
  38378. */
  38379. dPadRight: number;
  38380. /**
  38381. * Force the gamepad to synchronize with device values
  38382. */
  38383. update(): void;
  38384. /**
  38385. * Disposes the gamepad
  38386. */
  38387. dispose(): void;
  38388. }
  38389. }
  38390. declare module "babylonjs/Materials/pushMaterial" {
  38391. import { Nullable } from "babylonjs/types";
  38392. import { Scene } from "babylonjs/scene";
  38393. import { Matrix } from "babylonjs/Maths/math";
  38394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38395. import { Mesh } from "babylonjs/Meshes/mesh";
  38396. import { Material } from "babylonjs/Materials/material";
  38397. import { Effect } from "babylonjs/Materials/effect";
  38398. /**
  38399. * Base class of materials working in push mode in babylon JS
  38400. * @hidden
  38401. */
  38402. export class PushMaterial extends Material {
  38403. protected _activeEffect: Effect;
  38404. protected _normalMatrix: Matrix;
  38405. /**
  38406. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38407. * This means that the material can keep using a previous shader while a new one is being compiled.
  38408. * This is mostly used when shader parallel compilation is supported (true by default)
  38409. */
  38410. allowShaderHotSwapping: boolean;
  38411. constructor(name: string, scene: Scene);
  38412. getEffect(): Effect;
  38413. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38414. /**
  38415. * Binds the given world matrix to the active effect
  38416. *
  38417. * @param world the matrix to bind
  38418. */
  38419. bindOnlyWorldMatrix(world: Matrix): void;
  38420. /**
  38421. * Binds the given normal matrix to the active effect
  38422. *
  38423. * @param normalMatrix the matrix to bind
  38424. */
  38425. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38426. bind(world: Matrix, mesh?: Mesh): void;
  38427. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38428. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38429. }
  38430. }
  38431. declare module "babylonjs/Materials/materialFlags" {
  38432. /**
  38433. * This groups all the flags used to control the materials channel.
  38434. */
  38435. export class MaterialFlags {
  38436. private static _DiffuseTextureEnabled;
  38437. /**
  38438. * Are diffuse textures enabled in the application.
  38439. */
  38440. static DiffuseTextureEnabled: boolean;
  38441. private static _AmbientTextureEnabled;
  38442. /**
  38443. * Are ambient textures enabled in the application.
  38444. */
  38445. static AmbientTextureEnabled: boolean;
  38446. private static _OpacityTextureEnabled;
  38447. /**
  38448. * Are opacity textures enabled in the application.
  38449. */
  38450. static OpacityTextureEnabled: boolean;
  38451. private static _ReflectionTextureEnabled;
  38452. /**
  38453. * Are reflection textures enabled in the application.
  38454. */
  38455. static ReflectionTextureEnabled: boolean;
  38456. private static _EmissiveTextureEnabled;
  38457. /**
  38458. * Are emissive textures enabled in the application.
  38459. */
  38460. static EmissiveTextureEnabled: boolean;
  38461. private static _SpecularTextureEnabled;
  38462. /**
  38463. * Are specular textures enabled in the application.
  38464. */
  38465. static SpecularTextureEnabled: boolean;
  38466. private static _BumpTextureEnabled;
  38467. /**
  38468. * Are bump textures enabled in the application.
  38469. */
  38470. static BumpTextureEnabled: boolean;
  38471. private static _LightmapTextureEnabled;
  38472. /**
  38473. * Are lightmap textures enabled in the application.
  38474. */
  38475. static LightmapTextureEnabled: boolean;
  38476. private static _RefractionTextureEnabled;
  38477. /**
  38478. * Are refraction textures enabled in the application.
  38479. */
  38480. static RefractionTextureEnabled: boolean;
  38481. private static _ColorGradingTextureEnabled;
  38482. /**
  38483. * Are color grading textures enabled in the application.
  38484. */
  38485. static ColorGradingTextureEnabled: boolean;
  38486. private static _FresnelEnabled;
  38487. /**
  38488. * Are fresnels enabled in the application.
  38489. */
  38490. static FresnelEnabled: boolean;
  38491. private static _ClearCoatTextureEnabled;
  38492. /**
  38493. * Are clear coat textures enabled in the application.
  38494. */
  38495. static ClearCoatTextureEnabled: boolean;
  38496. private static _ClearCoatBumpTextureEnabled;
  38497. /**
  38498. * Are clear coat bump textures enabled in the application.
  38499. */
  38500. static ClearCoatBumpTextureEnabled: boolean;
  38501. private static _ClearCoatTintTextureEnabled;
  38502. /**
  38503. * Are clear coat tint textures enabled in the application.
  38504. */
  38505. static ClearCoatTintTextureEnabled: boolean;
  38506. }
  38507. }
  38508. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38509. /** @hidden */
  38510. export var defaultFragmentDeclaration: {
  38511. name: string;
  38512. shader: string;
  38513. };
  38514. }
  38515. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38516. /** @hidden */
  38517. export var defaultUboDeclaration: {
  38518. name: string;
  38519. shader: string;
  38520. };
  38521. }
  38522. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38523. /** @hidden */
  38524. export var lightFragmentDeclaration: {
  38525. name: string;
  38526. shader: string;
  38527. };
  38528. }
  38529. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38530. /** @hidden */
  38531. export var lightUboDeclaration: {
  38532. name: string;
  38533. shader: string;
  38534. };
  38535. }
  38536. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38537. /** @hidden */
  38538. export var lightsFragmentFunctions: {
  38539. name: string;
  38540. shader: string;
  38541. };
  38542. }
  38543. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38544. /** @hidden */
  38545. export var shadowsFragmentFunctions: {
  38546. name: string;
  38547. shader: string;
  38548. };
  38549. }
  38550. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38551. /** @hidden */
  38552. export var fresnelFunction: {
  38553. name: string;
  38554. shader: string;
  38555. };
  38556. }
  38557. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38558. /** @hidden */
  38559. export var reflectionFunction: {
  38560. name: string;
  38561. shader: string;
  38562. };
  38563. }
  38564. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38565. /** @hidden */
  38566. export var bumpFragmentFunctions: {
  38567. name: string;
  38568. shader: string;
  38569. };
  38570. }
  38571. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38572. /** @hidden */
  38573. export var logDepthDeclaration: {
  38574. name: string;
  38575. shader: string;
  38576. };
  38577. }
  38578. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38579. /** @hidden */
  38580. export var bumpFragment: {
  38581. name: string;
  38582. shader: string;
  38583. };
  38584. }
  38585. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38586. /** @hidden */
  38587. export var depthPrePass: {
  38588. name: string;
  38589. shader: string;
  38590. };
  38591. }
  38592. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38593. /** @hidden */
  38594. export var lightFragment: {
  38595. name: string;
  38596. shader: string;
  38597. };
  38598. }
  38599. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38600. /** @hidden */
  38601. export var logDepthFragment: {
  38602. name: string;
  38603. shader: string;
  38604. };
  38605. }
  38606. declare module "babylonjs/Shaders/default.fragment" {
  38607. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38608. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38609. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38610. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38611. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38612. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38613. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38614. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38615. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38616. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38617. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38618. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38619. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38620. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38621. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38622. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38623. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38624. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38625. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38626. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38627. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38628. /** @hidden */
  38629. export var defaultPixelShader: {
  38630. name: string;
  38631. shader: string;
  38632. };
  38633. }
  38634. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38635. /** @hidden */
  38636. export var defaultVertexDeclaration: {
  38637. name: string;
  38638. shader: string;
  38639. };
  38640. }
  38641. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38642. /** @hidden */
  38643. export var bumpVertexDeclaration: {
  38644. name: string;
  38645. shader: string;
  38646. };
  38647. }
  38648. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38649. /** @hidden */
  38650. export var bumpVertex: {
  38651. name: string;
  38652. shader: string;
  38653. };
  38654. }
  38655. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38656. /** @hidden */
  38657. export var fogVertex: {
  38658. name: string;
  38659. shader: string;
  38660. };
  38661. }
  38662. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38663. /** @hidden */
  38664. export var shadowsVertex: {
  38665. name: string;
  38666. shader: string;
  38667. };
  38668. }
  38669. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38670. /** @hidden */
  38671. export var pointCloudVertex: {
  38672. name: string;
  38673. shader: string;
  38674. };
  38675. }
  38676. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38677. /** @hidden */
  38678. export var logDepthVertex: {
  38679. name: string;
  38680. shader: string;
  38681. };
  38682. }
  38683. declare module "babylonjs/Shaders/default.vertex" {
  38684. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38685. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38686. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38687. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38688. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38689. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38690. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38691. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38692. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38693. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38694. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38695. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38696. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38697. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38698. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38699. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38700. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38701. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38702. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38703. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38704. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38705. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38706. /** @hidden */
  38707. export var defaultVertexShader: {
  38708. name: string;
  38709. shader: string;
  38710. };
  38711. }
  38712. declare module "babylonjs/Materials/standardMaterial" {
  38713. import { SmartArray } from "babylonjs/Misc/smartArray";
  38714. import { IAnimatable } from "babylonjs/Misc/tools";
  38715. import { Nullable } from "babylonjs/types";
  38716. import { Scene } from "babylonjs/scene";
  38717. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38718. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38720. import { Mesh } from "babylonjs/Meshes/mesh";
  38721. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38722. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38723. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38724. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38725. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38726. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38727. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38728. import "babylonjs/Shaders/default.fragment";
  38729. import "babylonjs/Shaders/default.vertex";
  38730. /** @hidden */
  38731. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38732. MAINUV1: boolean;
  38733. MAINUV2: boolean;
  38734. DIFFUSE: boolean;
  38735. DIFFUSEDIRECTUV: number;
  38736. AMBIENT: boolean;
  38737. AMBIENTDIRECTUV: number;
  38738. OPACITY: boolean;
  38739. OPACITYDIRECTUV: number;
  38740. OPACITYRGB: boolean;
  38741. REFLECTION: boolean;
  38742. EMISSIVE: boolean;
  38743. EMISSIVEDIRECTUV: number;
  38744. SPECULAR: boolean;
  38745. SPECULARDIRECTUV: number;
  38746. BUMP: boolean;
  38747. BUMPDIRECTUV: number;
  38748. PARALLAX: boolean;
  38749. PARALLAXOCCLUSION: boolean;
  38750. SPECULAROVERALPHA: boolean;
  38751. CLIPPLANE: boolean;
  38752. CLIPPLANE2: boolean;
  38753. CLIPPLANE3: boolean;
  38754. CLIPPLANE4: boolean;
  38755. ALPHATEST: boolean;
  38756. DEPTHPREPASS: boolean;
  38757. ALPHAFROMDIFFUSE: boolean;
  38758. POINTSIZE: boolean;
  38759. FOG: boolean;
  38760. SPECULARTERM: boolean;
  38761. DIFFUSEFRESNEL: boolean;
  38762. OPACITYFRESNEL: boolean;
  38763. REFLECTIONFRESNEL: boolean;
  38764. REFRACTIONFRESNEL: boolean;
  38765. EMISSIVEFRESNEL: boolean;
  38766. FRESNEL: boolean;
  38767. NORMAL: boolean;
  38768. UV1: boolean;
  38769. UV2: boolean;
  38770. VERTEXCOLOR: boolean;
  38771. VERTEXALPHA: boolean;
  38772. NUM_BONE_INFLUENCERS: number;
  38773. BonesPerMesh: number;
  38774. BONETEXTURE: boolean;
  38775. INSTANCES: boolean;
  38776. GLOSSINESS: boolean;
  38777. ROUGHNESS: boolean;
  38778. EMISSIVEASILLUMINATION: boolean;
  38779. LINKEMISSIVEWITHDIFFUSE: boolean;
  38780. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38781. LIGHTMAP: boolean;
  38782. LIGHTMAPDIRECTUV: number;
  38783. OBJECTSPACE_NORMALMAP: boolean;
  38784. USELIGHTMAPASSHADOWMAP: boolean;
  38785. REFLECTIONMAP_3D: boolean;
  38786. REFLECTIONMAP_SPHERICAL: boolean;
  38787. REFLECTIONMAP_PLANAR: boolean;
  38788. REFLECTIONMAP_CUBIC: boolean;
  38789. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38790. REFLECTIONMAP_PROJECTION: boolean;
  38791. REFLECTIONMAP_SKYBOX: boolean;
  38792. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38793. REFLECTIONMAP_EXPLICIT: boolean;
  38794. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38795. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38796. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38797. INVERTCUBICMAP: boolean;
  38798. LOGARITHMICDEPTH: boolean;
  38799. REFRACTION: boolean;
  38800. REFRACTIONMAP_3D: boolean;
  38801. REFLECTIONOVERALPHA: boolean;
  38802. TWOSIDEDLIGHTING: boolean;
  38803. SHADOWFLOAT: boolean;
  38804. MORPHTARGETS: boolean;
  38805. MORPHTARGETS_NORMAL: boolean;
  38806. MORPHTARGETS_TANGENT: boolean;
  38807. NUM_MORPH_INFLUENCERS: number;
  38808. NONUNIFORMSCALING: boolean;
  38809. PREMULTIPLYALPHA: boolean;
  38810. IMAGEPROCESSING: boolean;
  38811. VIGNETTE: boolean;
  38812. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38813. VIGNETTEBLENDMODEOPAQUE: boolean;
  38814. TONEMAPPING: boolean;
  38815. TONEMAPPING_ACES: boolean;
  38816. CONTRAST: boolean;
  38817. COLORCURVES: boolean;
  38818. COLORGRADING: boolean;
  38819. COLORGRADING3D: boolean;
  38820. SAMPLER3DGREENDEPTH: boolean;
  38821. SAMPLER3DBGRMAP: boolean;
  38822. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38823. /**
  38824. * If the reflection texture on this material is in linear color space
  38825. * @hidden
  38826. */
  38827. IS_REFLECTION_LINEAR: boolean;
  38828. /**
  38829. * If the refraction texture on this material is in linear color space
  38830. * @hidden
  38831. */
  38832. IS_REFRACTION_LINEAR: boolean;
  38833. EXPOSURE: boolean;
  38834. constructor();
  38835. setReflectionMode(modeToEnable: string): void;
  38836. }
  38837. /**
  38838. * This is the default material used in Babylon. It is the best trade off between quality
  38839. * and performances.
  38840. * @see http://doc.babylonjs.com/babylon101/materials
  38841. */
  38842. export class StandardMaterial extends PushMaterial {
  38843. private _diffuseTexture;
  38844. /**
  38845. * The basic texture of the material as viewed under a light.
  38846. */
  38847. diffuseTexture: Nullable<BaseTexture>;
  38848. private _ambientTexture;
  38849. /**
  38850. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38851. */
  38852. ambientTexture: Nullable<BaseTexture>;
  38853. private _opacityTexture;
  38854. /**
  38855. * Define the transparency of the material from a texture.
  38856. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38857. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38858. */
  38859. opacityTexture: Nullable<BaseTexture>;
  38860. private _reflectionTexture;
  38861. /**
  38862. * Define the texture used to display the reflection.
  38863. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38864. */
  38865. reflectionTexture: Nullable<BaseTexture>;
  38866. private _emissiveTexture;
  38867. /**
  38868. * Define texture of the material as if self lit.
  38869. * This will be mixed in the final result even in the absence of light.
  38870. */
  38871. emissiveTexture: Nullable<BaseTexture>;
  38872. private _specularTexture;
  38873. /**
  38874. * Define how the color and intensity of the highlight given by the light in the material.
  38875. */
  38876. specularTexture: Nullable<BaseTexture>;
  38877. private _bumpTexture;
  38878. /**
  38879. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38880. * 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.
  38881. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38882. */
  38883. bumpTexture: Nullable<BaseTexture>;
  38884. private _lightmapTexture;
  38885. /**
  38886. * Complex lighting can be computationally expensive to compute at runtime.
  38887. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38888. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38889. */
  38890. lightmapTexture: Nullable<BaseTexture>;
  38891. private _refractionTexture;
  38892. /**
  38893. * Define the texture used to display the refraction.
  38894. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38895. */
  38896. refractionTexture: Nullable<BaseTexture>;
  38897. /**
  38898. * The color of the material lit by the environmental background lighting.
  38899. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38900. */
  38901. ambientColor: Color3;
  38902. /**
  38903. * The basic color of the material as viewed under a light.
  38904. */
  38905. diffuseColor: Color3;
  38906. /**
  38907. * Define how the color and intensity of the highlight given by the light in the material.
  38908. */
  38909. specularColor: Color3;
  38910. /**
  38911. * Define the color of the material as if self lit.
  38912. * This will be mixed in the final result even in the absence of light.
  38913. */
  38914. emissiveColor: Color3;
  38915. /**
  38916. * Defines how sharp are the highlights in the material.
  38917. * The bigger the value the sharper giving a more glossy feeling to the result.
  38918. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38919. */
  38920. specularPower: number;
  38921. private _useAlphaFromDiffuseTexture;
  38922. /**
  38923. * Does the transparency come from the diffuse texture alpha channel.
  38924. */
  38925. useAlphaFromDiffuseTexture: boolean;
  38926. private _useEmissiveAsIllumination;
  38927. /**
  38928. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38929. */
  38930. useEmissiveAsIllumination: boolean;
  38931. private _linkEmissiveWithDiffuse;
  38932. /**
  38933. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38934. * the emissive level when the final color is close to one.
  38935. */
  38936. linkEmissiveWithDiffuse: boolean;
  38937. private _useSpecularOverAlpha;
  38938. /**
  38939. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38940. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38941. */
  38942. useSpecularOverAlpha: boolean;
  38943. private _useReflectionOverAlpha;
  38944. /**
  38945. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38946. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38947. */
  38948. useReflectionOverAlpha: boolean;
  38949. private _disableLighting;
  38950. /**
  38951. * Does lights from the scene impacts this material.
  38952. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38953. */
  38954. disableLighting: boolean;
  38955. private _useObjectSpaceNormalMap;
  38956. /**
  38957. * Allows using an object space normal map (instead of tangent space).
  38958. */
  38959. useObjectSpaceNormalMap: boolean;
  38960. private _useParallax;
  38961. /**
  38962. * Is parallax enabled or not.
  38963. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38964. */
  38965. useParallax: boolean;
  38966. private _useParallaxOcclusion;
  38967. /**
  38968. * Is parallax occlusion enabled or not.
  38969. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38970. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38971. */
  38972. useParallaxOcclusion: boolean;
  38973. /**
  38974. * 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.
  38975. */
  38976. parallaxScaleBias: number;
  38977. private _roughness;
  38978. /**
  38979. * Helps to define how blurry the reflections should appears in the material.
  38980. */
  38981. roughness: number;
  38982. /**
  38983. * In case of refraction, define the value of the indice of refraction.
  38984. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38985. */
  38986. indexOfRefraction: number;
  38987. /**
  38988. * Invert the refraction texture alongside the y axis.
  38989. * It can be useful with procedural textures or probe for instance.
  38990. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38991. */
  38992. invertRefractionY: boolean;
  38993. /**
  38994. * Defines the alpha limits in alpha test mode.
  38995. */
  38996. alphaCutOff: number;
  38997. private _useLightmapAsShadowmap;
  38998. /**
  38999. * In case of light mapping, define whether the map contains light or shadow informations.
  39000. */
  39001. useLightmapAsShadowmap: boolean;
  39002. private _diffuseFresnelParameters;
  39003. /**
  39004. * Define the diffuse fresnel parameters of the material.
  39005. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39006. */
  39007. diffuseFresnelParameters: FresnelParameters;
  39008. private _opacityFresnelParameters;
  39009. /**
  39010. * Define the opacity fresnel parameters of the material.
  39011. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39012. */
  39013. opacityFresnelParameters: FresnelParameters;
  39014. private _reflectionFresnelParameters;
  39015. /**
  39016. * Define the reflection fresnel parameters of the material.
  39017. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39018. */
  39019. reflectionFresnelParameters: FresnelParameters;
  39020. private _refractionFresnelParameters;
  39021. /**
  39022. * Define the refraction fresnel parameters of the material.
  39023. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39024. */
  39025. refractionFresnelParameters: FresnelParameters;
  39026. private _emissiveFresnelParameters;
  39027. /**
  39028. * Define the emissive fresnel parameters of the material.
  39029. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39030. */
  39031. emissiveFresnelParameters: FresnelParameters;
  39032. private _useReflectionFresnelFromSpecular;
  39033. /**
  39034. * If true automatically deducts the fresnels values from the material specularity.
  39035. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39036. */
  39037. useReflectionFresnelFromSpecular: boolean;
  39038. private _useGlossinessFromSpecularMapAlpha;
  39039. /**
  39040. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39041. */
  39042. useGlossinessFromSpecularMapAlpha: boolean;
  39043. private _maxSimultaneousLights;
  39044. /**
  39045. * Defines the maximum number of lights that can be used in the material
  39046. */
  39047. maxSimultaneousLights: number;
  39048. private _invertNormalMapX;
  39049. /**
  39050. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39051. */
  39052. invertNormalMapX: boolean;
  39053. private _invertNormalMapY;
  39054. /**
  39055. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39056. */
  39057. invertNormalMapY: boolean;
  39058. private _twoSidedLighting;
  39059. /**
  39060. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39061. */
  39062. twoSidedLighting: boolean;
  39063. /**
  39064. * Default configuration related to image processing available in the standard Material.
  39065. */
  39066. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39067. /**
  39068. * Gets the image processing configuration used either in this material.
  39069. */
  39070. /**
  39071. * Sets the Default image processing configuration used either in the this material.
  39072. *
  39073. * If sets to null, the scene one is in use.
  39074. */
  39075. imageProcessingConfiguration: ImageProcessingConfiguration;
  39076. /**
  39077. * Keep track of the image processing observer to allow dispose and replace.
  39078. */
  39079. private _imageProcessingObserver;
  39080. /**
  39081. * Attaches a new image processing configuration to the Standard Material.
  39082. * @param configuration
  39083. */
  39084. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39085. /**
  39086. * Gets wether the color curves effect is enabled.
  39087. */
  39088. /**
  39089. * Sets wether the color curves effect is enabled.
  39090. */
  39091. cameraColorCurvesEnabled: boolean;
  39092. /**
  39093. * Gets wether the color grading effect is enabled.
  39094. */
  39095. /**
  39096. * Gets wether the color grading effect is enabled.
  39097. */
  39098. cameraColorGradingEnabled: boolean;
  39099. /**
  39100. * Gets wether tonemapping is enabled or not.
  39101. */
  39102. /**
  39103. * Sets wether tonemapping is enabled or not
  39104. */
  39105. cameraToneMappingEnabled: boolean;
  39106. /**
  39107. * The camera exposure used on this material.
  39108. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39109. * This corresponds to a photographic exposure.
  39110. */
  39111. /**
  39112. * The camera exposure used on this material.
  39113. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39114. * This corresponds to a photographic exposure.
  39115. */
  39116. cameraExposure: number;
  39117. /**
  39118. * Gets The camera contrast used on this material.
  39119. */
  39120. /**
  39121. * Sets The camera contrast used on this material.
  39122. */
  39123. cameraContrast: number;
  39124. /**
  39125. * Gets the Color Grading 2D Lookup Texture.
  39126. */
  39127. /**
  39128. * Sets the Color Grading 2D Lookup Texture.
  39129. */
  39130. cameraColorGradingTexture: Nullable<BaseTexture>;
  39131. /**
  39132. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39133. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39134. * 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;
  39135. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39136. */
  39137. /**
  39138. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39139. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39140. * 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;
  39141. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39142. */
  39143. cameraColorCurves: Nullable<ColorCurves>;
  39144. /**
  39145. * Custom callback helping to override the default shader used in the material.
  39146. */
  39147. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39148. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39149. protected _worldViewProjectionMatrix: Matrix;
  39150. protected _globalAmbientColor: Color3;
  39151. protected _useLogarithmicDepth: boolean;
  39152. /**
  39153. * Instantiates a new standard material.
  39154. * This is the default material used in Babylon. It is the best trade off between quality
  39155. * and performances.
  39156. * @see http://doc.babylonjs.com/babylon101/materials
  39157. * @param name Define the name of the material in the scene
  39158. * @param scene Define the scene the material belong to
  39159. */
  39160. constructor(name: string, scene: Scene);
  39161. /**
  39162. * Gets a boolean indicating that current material needs to register RTT
  39163. */
  39164. readonly hasRenderTargetTextures: boolean;
  39165. /**
  39166. * Gets the current class name of the material e.g. "StandardMaterial"
  39167. * Mainly use in serialization.
  39168. * @returns the class name
  39169. */
  39170. getClassName(): string;
  39171. /**
  39172. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39173. * You can try switching to logarithmic depth.
  39174. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39175. */
  39176. useLogarithmicDepth: boolean;
  39177. /**
  39178. * Specifies if the material will require alpha blending
  39179. * @returns a boolean specifying if alpha blending is needed
  39180. */
  39181. needAlphaBlending(): boolean;
  39182. /**
  39183. * Specifies if this material should be rendered in alpha test mode
  39184. * @returns a boolean specifying if an alpha test is needed.
  39185. */
  39186. needAlphaTesting(): boolean;
  39187. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39188. /**
  39189. * Get the texture used for alpha test purpose.
  39190. * @returns the diffuse texture in case of the standard material.
  39191. */
  39192. getAlphaTestTexture(): Nullable<BaseTexture>;
  39193. /**
  39194. * Get if the submesh is ready to be used and all its information available.
  39195. * Child classes can use it to update shaders
  39196. * @param mesh defines the mesh to check
  39197. * @param subMesh defines which submesh to check
  39198. * @param useInstances specifies that instances should be used
  39199. * @returns a boolean indicating that the submesh is ready or not
  39200. */
  39201. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39202. /**
  39203. * Builds the material UBO layouts.
  39204. * Used internally during the effect preparation.
  39205. */
  39206. buildUniformLayout(): void;
  39207. /**
  39208. * Unbinds the material from the mesh
  39209. */
  39210. unbind(): void;
  39211. /**
  39212. * Binds the submesh to this material by preparing the effect and shader to draw
  39213. * @param world defines the world transformation matrix
  39214. * @param mesh defines the mesh containing the submesh
  39215. * @param subMesh defines the submesh to bind the material to
  39216. */
  39217. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39218. /**
  39219. * Get the list of animatables in the material.
  39220. * @returns the list of animatables object used in the material
  39221. */
  39222. getAnimatables(): IAnimatable[];
  39223. /**
  39224. * Gets the active textures from the material
  39225. * @returns an array of textures
  39226. */
  39227. getActiveTextures(): BaseTexture[];
  39228. /**
  39229. * Specifies if the material uses a texture
  39230. * @param texture defines the texture to check against the material
  39231. * @returns a boolean specifying if the material uses the texture
  39232. */
  39233. hasTexture(texture: BaseTexture): boolean;
  39234. /**
  39235. * Disposes the material
  39236. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39237. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39238. */
  39239. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39240. /**
  39241. * Makes a duplicate of the material, and gives it a new name
  39242. * @param name defines the new name for the duplicated material
  39243. * @returns the cloned material
  39244. */
  39245. clone(name: string): StandardMaterial;
  39246. /**
  39247. * Serializes this material in a JSON representation
  39248. * @returns the serialized material object
  39249. */
  39250. serialize(): any;
  39251. /**
  39252. * Creates a standard material from parsed material data
  39253. * @param source defines the JSON representation of the material
  39254. * @param scene defines the hosting scene
  39255. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39256. * @returns a new standard material
  39257. */
  39258. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39259. /**
  39260. * Are diffuse textures enabled in the application.
  39261. */
  39262. static DiffuseTextureEnabled: boolean;
  39263. /**
  39264. * Are ambient textures enabled in the application.
  39265. */
  39266. static AmbientTextureEnabled: boolean;
  39267. /**
  39268. * Are opacity textures enabled in the application.
  39269. */
  39270. static OpacityTextureEnabled: boolean;
  39271. /**
  39272. * Are reflection textures enabled in the application.
  39273. */
  39274. static ReflectionTextureEnabled: boolean;
  39275. /**
  39276. * Are emissive textures enabled in the application.
  39277. */
  39278. static EmissiveTextureEnabled: boolean;
  39279. /**
  39280. * Are specular textures enabled in the application.
  39281. */
  39282. static SpecularTextureEnabled: boolean;
  39283. /**
  39284. * Are bump textures enabled in the application.
  39285. */
  39286. static BumpTextureEnabled: boolean;
  39287. /**
  39288. * Are lightmap textures enabled in the application.
  39289. */
  39290. static LightmapTextureEnabled: boolean;
  39291. /**
  39292. * Are refraction textures enabled in the application.
  39293. */
  39294. static RefractionTextureEnabled: boolean;
  39295. /**
  39296. * Are color grading textures enabled in the application.
  39297. */
  39298. static ColorGradingTextureEnabled: boolean;
  39299. /**
  39300. * Are fresnels enabled in the application.
  39301. */
  39302. static FresnelEnabled: boolean;
  39303. }
  39304. }
  39305. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39306. import { Scene } from "babylonjs/scene";
  39307. import { Texture } from "babylonjs/Materials/Textures/texture";
  39308. /**
  39309. * A class extending Texture allowing drawing on a texture
  39310. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39311. */
  39312. export class DynamicTexture extends Texture {
  39313. private _generateMipMaps;
  39314. private _canvas;
  39315. private _context;
  39316. private _engine;
  39317. /**
  39318. * Creates a DynamicTexture
  39319. * @param name defines the name of the texture
  39320. * @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
  39321. * @param scene defines the scene where you want the texture
  39322. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39323. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39324. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39325. */
  39326. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39327. /**
  39328. * Get the current class name of the texture useful for serialization or dynamic coding.
  39329. * @returns "DynamicTexture"
  39330. */
  39331. getClassName(): string;
  39332. /**
  39333. * Gets the current state of canRescale
  39334. */
  39335. readonly canRescale: boolean;
  39336. private _recreate;
  39337. /**
  39338. * Scales the texture
  39339. * @param ratio the scale factor to apply to both width and height
  39340. */
  39341. scale(ratio: number): void;
  39342. /**
  39343. * Resizes the texture
  39344. * @param width the new width
  39345. * @param height the new height
  39346. */
  39347. scaleTo(width: number, height: number): void;
  39348. /**
  39349. * Gets the context of the canvas used by the texture
  39350. * @returns the canvas context of the dynamic texture
  39351. */
  39352. getContext(): CanvasRenderingContext2D;
  39353. /**
  39354. * Clears the texture
  39355. */
  39356. clear(): void;
  39357. /**
  39358. * Updates the texture
  39359. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39360. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39361. */
  39362. update(invertY?: boolean, premulAlpha?: boolean): void;
  39363. /**
  39364. * Draws text onto the texture
  39365. * @param text defines the text to be drawn
  39366. * @param x defines the placement of the text from the left
  39367. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39368. * @param font defines the font to be used with font-style, font-size, font-name
  39369. * @param color defines the color used for the text
  39370. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39371. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39372. * @param update defines whether texture is immediately update (default is true)
  39373. */
  39374. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39375. /**
  39376. * Clones the texture
  39377. * @returns the clone of the texture.
  39378. */
  39379. clone(): DynamicTexture;
  39380. /**
  39381. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39382. * @returns a serialized dynamic texture object
  39383. */
  39384. serialize(): any;
  39385. /** @hidden */
  39386. _rebuild(): void;
  39387. }
  39388. }
  39389. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39390. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39391. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39392. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39393. /** @hidden */
  39394. export var imageProcessingPixelShader: {
  39395. name: string;
  39396. shader: string;
  39397. };
  39398. }
  39399. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39400. import { Nullable } from "babylonjs/types";
  39401. import { Color4 } from "babylonjs/Maths/math";
  39402. import { Camera } from "babylonjs/Cameras/camera";
  39403. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39404. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39405. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39406. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39407. import { Engine } from "babylonjs/Engines/engine";
  39408. import "babylonjs/Shaders/imageProcessing.fragment";
  39409. import "babylonjs/Shaders/postprocess.vertex";
  39410. /**
  39411. * ImageProcessingPostProcess
  39412. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39413. */
  39414. export class ImageProcessingPostProcess extends PostProcess {
  39415. /**
  39416. * Default configuration related to image processing available in the PBR Material.
  39417. */
  39418. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39419. /**
  39420. * Gets the image processing configuration used either in this material.
  39421. */
  39422. /**
  39423. * Sets the Default image processing configuration used either in the this material.
  39424. *
  39425. * If sets to null, the scene one is in use.
  39426. */
  39427. imageProcessingConfiguration: ImageProcessingConfiguration;
  39428. /**
  39429. * Keep track of the image processing observer to allow dispose and replace.
  39430. */
  39431. private _imageProcessingObserver;
  39432. /**
  39433. * Attaches a new image processing configuration to the PBR Material.
  39434. * @param configuration
  39435. */
  39436. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39437. /**
  39438. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39439. */
  39440. /**
  39441. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39442. */
  39443. colorCurves: Nullable<ColorCurves>;
  39444. /**
  39445. * Gets wether the color curves effect is enabled.
  39446. */
  39447. /**
  39448. * Sets wether the color curves effect is enabled.
  39449. */
  39450. colorCurvesEnabled: boolean;
  39451. /**
  39452. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39453. */
  39454. /**
  39455. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39456. */
  39457. colorGradingTexture: Nullable<BaseTexture>;
  39458. /**
  39459. * Gets wether the color grading effect is enabled.
  39460. */
  39461. /**
  39462. * Gets wether the color grading effect is enabled.
  39463. */
  39464. colorGradingEnabled: boolean;
  39465. /**
  39466. * Gets exposure used in the effect.
  39467. */
  39468. /**
  39469. * Sets exposure used in the effect.
  39470. */
  39471. exposure: number;
  39472. /**
  39473. * Gets wether tonemapping is enabled or not.
  39474. */
  39475. /**
  39476. * Sets wether tonemapping is enabled or not
  39477. */
  39478. toneMappingEnabled: boolean;
  39479. /**
  39480. * Gets the type of tone mapping effect.
  39481. */
  39482. /**
  39483. * Sets the type of tone mapping effect.
  39484. */
  39485. toneMappingType: number;
  39486. /**
  39487. * Gets contrast used in the effect.
  39488. */
  39489. /**
  39490. * Sets contrast used in the effect.
  39491. */
  39492. contrast: number;
  39493. /**
  39494. * Gets Vignette stretch size.
  39495. */
  39496. /**
  39497. * Sets Vignette stretch size.
  39498. */
  39499. vignetteStretch: number;
  39500. /**
  39501. * Gets Vignette centre X Offset.
  39502. */
  39503. /**
  39504. * Sets Vignette centre X Offset.
  39505. */
  39506. vignetteCentreX: number;
  39507. /**
  39508. * Gets Vignette centre Y Offset.
  39509. */
  39510. /**
  39511. * Sets Vignette centre Y Offset.
  39512. */
  39513. vignetteCentreY: number;
  39514. /**
  39515. * Gets Vignette weight or intensity of the vignette effect.
  39516. */
  39517. /**
  39518. * Sets Vignette weight or intensity of the vignette effect.
  39519. */
  39520. vignetteWeight: number;
  39521. /**
  39522. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39523. * if vignetteEnabled is set to true.
  39524. */
  39525. /**
  39526. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39527. * if vignetteEnabled is set to true.
  39528. */
  39529. vignetteColor: Color4;
  39530. /**
  39531. * Gets Camera field of view used by the Vignette effect.
  39532. */
  39533. /**
  39534. * Sets Camera field of view used by the Vignette effect.
  39535. */
  39536. vignetteCameraFov: number;
  39537. /**
  39538. * Gets the vignette blend mode allowing different kind of effect.
  39539. */
  39540. /**
  39541. * Sets the vignette blend mode allowing different kind of effect.
  39542. */
  39543. vignetteBlendMode: number;
  39544. /**
  39545. * Gets wether the vignette effect is enabled.
  39546. */
  39547. /**
  39548. * Sets wether the vignette effect is enabled.
  39549. */
  39550. vignetteEnabled: boolean;
  39551. private _fromLinearSpace;
  39552. /**
  39553. * Gets wether the input of the processing is in Gamma or Linear Space.
  39554. */
  39555. /**
  39556. * Sets wether the input of the processing is in Gamma or Linear Space.
  39557. */
  39558. fromLinearSpace: boolean;
  39559. /**
  39560. * Defines cache preventing GC.
  39561. */
  39562. private _defines;
  39563. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39564. /**
  39565. * "ImageProcessingPostProcess"
  39566. * @returns "ImageProcessingPostProcess"
  39567. */
  39568. getClassName(): string;
  39569. protected _updateParameters(): void;
  39570. dispose(camera?: Camera): void;
  39571. }
  39572. }
  39573. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39574. import { Scene } from "babylonjs/scene";
  39575. import { Color3 } from "babylonjs/Maths/math";
  39576. import { Mesh } from "babylonjs/Meshes/mesh";
  39577. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39578. /**
  39579. * Class containing static functions to help procedurally build meshes
  39580. */
  39581. export class GroundBuilder {
  39582. /**
  39583. * Creates a ground mesh
  39584. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39585. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39587. * @param name defines the name of the mesh
  39588. * @param options defines the options used to create the mesh
  39589. * @param scene defines the hosting scene
  39590. * @returns the ground mesh
  39591. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39592. */
  39593. static CreateGround(name: string, options: {
  39594. width?: number;
  39595. height?: number;
  39596. subdivisions?: number;
  39597. subdivisionsX?: number;
  39598. subdivisionsY?: number;
  39599. updatable?: boolean;
  39600. }, scene: any): Mesh;
  39601. /**
  39602. * Creates a tiled ground mesh
  39603. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39604. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39605. * * 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
  39606. * * 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
  39607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39608. * @param name defines the name of the mesh
  39609. * @param options defines the options used to create the mesh
  39610. * @param scene defines the hosting scene
  39611. * @returns the tiled ground mesh
  39612. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39613. */
  39614. static CreateTiledGround(name: string, options: {
  39615. xmin: number;
  39616. zmin: number;
  39617. xmax: number;
  39618. zmax: number;
  39619. subdivisions?: {
  39620. w: number;
  39621. h: number;
  39622. };
  39623. precision?: {
  39624. w: number;
  39625. h: number;
  39626. };
  39627. updatable?: boolean;
  39628. }, scene: Scene): Mesh;
  39629. /**
  39630. * Creates a ground mesh from a height map
  39631. * * The parameter `url` sets the URL of the height map image resource.
  39632. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39633. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39634. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39635. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39636. * * 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.
  39637. * * 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).
  39638. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39640. * @param name defines the name of the mesh
  39641. * @param url defines the url to the height map
  39642. * @param options defines the options used to create the mesh
  39643. * @param scene defines the hosting scene
  39644. * @returns the ground mesh
  39645. * @see https://doc.babylonjs.com/babylon101/height_map
  39646. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39647. */
  39648. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39649. width?: number;
  39650. height?: number;
  39651. subdivisions?: number;
  39652. minHeight?: number;
  39653. maxHeight?: number;
  39654. colorFilter?: Color3;
  39655. alphaFilter?: number;
  39656. updatable?: boolean;
  39657. onReady?: (mesh: GroundMesh) => void;
  39658. }, scene: Scene): GroundMesh;
  39659. }
  39660. }
  39661. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39662. import { Vector4 } from "babylonjs/Maths/math";
  39663. import { Mesh } from "babylonjs/Meshes/mesh";
  39664. /**
  39665. * Class containing static functions to help procedurally build meshes
  39666. */
  39667. export class TorusBuilder {
  39668. /**
  39669. * Creates a torus mesh
  39670. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39671. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39672. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39676. * @param name defines the name of the mesh
  39677. * @param options defines the options used to create the mesh
  39678. * @param scene defines the hosting scene
  39679. * @returns the torus mesh
  39680. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39681. */
  39682. static CreateTorus(name: string, options: {
  39683. diameter?: number;
  39684. thickness?: number;
  39685. tessellation?: number;
  39686. updatable?: boolean;
  39687. sideOrientation?: number;
  39688. frontUVs?: Vector4;
  39689. backUVs?: Vector4;
  39690. }, scene: any): Mesh;
  39691. }
  39692. }
  39693. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39694. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39695. import { Mesh } from "babylonjs/Meshes/mesh";
  39696. /**
  39697. * Class containing static functions to help procedurally build meshes
  39698. */
  39699. export class CylinderBuilder {
  39700. /**
  39701. * Creates a cylinder or a cone mesh
  39702. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39703. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39704. * * 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.
  39705. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39706. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39707. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39708. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39709. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39710. * * 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).
  39711. * * 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
  39712. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39713. * * 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
  39714. * * 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.
  39715. * * If `enclose` is false, a ring surface is one element.
  39716. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39717. * * 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
  39718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39719. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39721. * @param name defines the name of the mesh
  39722. * @param options defines the options used to create the mesh
  39723. * @param scene defines the hosting scene
  39724. * @returns the cylinder mesh
  39725. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39726. */
  39727. static CreateCylinder(name: string, options: {
  39728. height?: number;
  39729. diameterTop?: number;
  39730. diameterBottom?: number;
  39731. diameter?: number;
  39732. tessellation?: number;
  39733. subdivisions?: number;
  39734. arc?: number;
  39735. faceColors?: Color4[];
  39736. faceUV?: Vector4[];
  39737. updatable?: boolean;
  39738. hasRings?: boolean;
  39739. enclose?: boolean;
  39740. sideOrientation?: number;
  39741. frontUVs?: Vector4;
  39742. backUVs?: Vector4;
  39743. }, scene: any): Mesh;
  39744. }
  39745. }
  39746. declare module "babylonjs/Gamepads/gamepadManager" {
  39747. import { Observable } from "babylonjs/Misc/observable";
  39748. import { Nullable } from "babylonjs/types";
  39749. import { Scene } from "babylonjs/scene";
  39750. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39751. /**
  39752. * Manager for handling gamepads
  39753. */
  39754. export class GamepadManager {
  39755. private _scene?;
  39756. private _babylonGamepads;
  39757. private _oneGamepadConnected;
  39758. /** @hidden */
  39759. _isMonitoring: boolean;
  39760. private _gamepadEventSupported;
  39761. private _gamepadSupport;
  39762. /**
  39763. * observable to be triggered when the gamepad controller has been connected
  39764. */
  39765. onGamepadConnectedObservable: Observable<Gamepad>;
  39766. /**
  39767. * observable to be triggered when the gamepad controller has been disconnected
  39768. */
  39769. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39770. private _onGamepadConnectedEvent;
  39771. private _onGamepadDisconnectedEvent;
  39772. /**
  39773. * Initializes the gamepad manager
  39774. * @param _scene BabylonJS scene
  39775. */
  39776. constructor(_scene?: Scene | undefined);
  39777. /**
  39778. * The gamepads in the game pad manager
  39779. */
  39780. readonly gamepads: Gamepad[];
  39781. /**
  39782. * Get the gamepad controllers based on type
  39783. * @param type The type of gamepad controller
  39784. * @returns Nullable gamepad
  39785. */
  39786. getGamepadByType(type?: number): Nullable<Gamepad>;
  39787. /**
  39788. * Disposes the gamepad manager
  39789. */
  39790. dispose(): void;
  39791. private _addNewGamepad;
  39792. private _startMonitoringGamepads;
  39793. private _stopMonitoringGamepads;
  39794. /** @hidden */
  39795. _checkGamepadsStatus(): void;
  39796. private _updateGamepadObjects;
  39797. }
  39798. }
  39799. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39800. import { Nullable } from "babylonjs/types";
  39801. import { Scene } from "babylonjs/scene";
  39802. import { ISceneComponent } from "babylonjs/sceneComponent";
  39803. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39804. module "babylonjs/scene" {
  39805. interface Scene {
  39806. /** @hidden */
  39807. _gamepadManager: Nullable<GamepadManager>;
  39808. /**
  39809. * Gets the gamepad manager associated with the scene
  39810. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39811. */
  39812. gamepadManager: GamepadManager;
  39813. }
  39814. }
  39815. module "babylonjs/Cameras/freeCameraInputsManager" {
  39816. /**
  39817. * Interface representing a free camera inputs manager
  39818. */
  39819. interface FreeCameraInputsManager {
  39820. /**
  39821. * Adds gamepad input support to the FreeCameraInputsManager.
  39822. * @returns the FreeCameraInputsManager
  39823. */
  39824. addGamepad(): FreeCameraInputsManager;
  39825. }
  39826. }
  39827. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39828. /**
  39829. * Interface representing an arc rotate camera inputs manager
  39830. */
  39831. interface ArcRotateCameraInputsManager {
  39832. /**
  39833. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39834. * @returns the camera inputs manager
  39835. */
  39836. addGamepad(): ArcRotateCameraInputsManager;
  39837. }
  39838. }
  39839. /**
  39840. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39841. */
  39842. export class GamepadSystemSceneComponent implements ISceneComponent {
  39843. /**
  39844. * The component name helpfull to identify the component in the list of scene components.
  39845. */
  39846. readonly name: string;
  39847. /**
  39848. * The scene the component belongs to.
  39849. */
  39850. scene: Scene;
  39851. /**
  39852. * Creates a new instance of the component for the given scene
  39853. * @param scene Defines the scene to register the component in
  39854. */
  39855. constructor(scene: Scene);
  39856. /**
  39857. * Registers the component in a given scene
  39858. */
  39859. register(): void;
  39860. /**
  39861. * Rebuilds the elements related to this component in case of
  39862. * context lost for instance.
  39863. */
  39864. rebuild(): void;
  39865. /**
  39866. * Disposes the component and the associated ressources
  39867. */
  39868. dispose(): void;
  39869. private _beforeCameraUpdate;
  39870. }
  39871. }
  39872. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39873. import { Observable } from "babylonjs/Misc/observable";
  39874. import { Nullable } from "babylonjs/types";
  39875. import { Camera } from "babylonjs/Cameras/camera";
  39876. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39877. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39878. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39879. import { Scene } from "babylonjs/scene";
  39880. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39881. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39883. import { Mesh } from "babylonjs/Meshes/mesh";
  39884. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39885. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39886. import "babylonjs/Meshes/Builders/groundBuilder";
  39887. import "babylonjs/Meshes/Builders/torusBuilder";
  39888. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39889. import "babylonjs/Gamepads/gamepadSceneComponent";
  39890. import "babylonjs/Animations/animatable";
  39891. /**
  39892. * Options to modify the vr teleportation behavior.
  39893. */
  39894. export interface VRTeleportationOptions {
  39895. /**
  39896. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39897. */
  39898. floorMeshName?: string;
  39899. /**
  39900. * A list of meshes to be used as the teleportation floor. (default: empty)
  39901. */
  39902. floorMeshes?: Mesh[];
  39903. }
  39904. /**
  39905. * Options to modify the vr experience helper's behavior.
  39906. */
  39907. export interface VRExperienceHelperOptions extends WebVROptions {
  39908. /**
  39909. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39910. */
  39911. createDeviceOrientationCamera?: boolean;
  39912. /**
  39913. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39914. */
  39915. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39916. /**
  39917. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39918. */
  39919. laserToggle?: boolean;
  39920. /**
  39921. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39922. */
  39923. floorMeshes?: Mesh[];
  39924. /**
  39925. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39926. */
  39927. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39928. }
  39929. /**
  39930. * Event containing information after VR has been entered
  39931. */
  39932. export class OnAfterEnteringVRObservableEvent {
  39933. /**
  39934. * If entering vr was successful
  39935. */
  39936. success: boolean;
  39937. }
  39938. /**
  39939. * Helps to quickly add VR support to an existing scene.
  39940. * See http://doc.babylonjs.com/how_to/webvr_helper
  39941. */
  39942. export class VRExperienceHelper {
  39943. /** Options to modify the vr experience helper's behavior. */
  39944. webVROptions: VRExperienceHelperOptions;
  39945. private _scene;
  39946. private _position;
  39947. private _btnVR;
  39948. private _btnVRDisplayed;
  39949. private _webVRsupported;
  39950. private _webVRready;
  39951. private _webVRrequesting;
  39952. private _webVRpresenting;
  39953. private _hasEnteredVR;
  39954. private _fullscreenVRpresenting;
  39955. private _canvas;
  39956. private _webVRCamera;
  39957. private _vrDeviceOrientationCamera;
  39958. private _deviceOrientationCamera;
  39959. private _existingCamera;
  39960. private _onKeyDown;
  39961. private _onVrDisplayPresentChange;
  39962. private _onVRDisplayChanged;
  39963. private _onVRRequestPresentStart;
  39964. private _onVRRequestPresentComplete;
  39965. /**
  39966. * Observable raised right before entering VR.
  39967. */
  39968. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39969. /**
  39970. * Observable raised when entering VR has completed.
  39971. */
  39972. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39973. /**
  39974. * Observable raised when exiting VR.
  39975. */
  39976. onExitingVRObservable: Observable<VRExperienceHelper>;
  39977. /**
  39978. * Observable raised when controller mesh is loaded.
  39979. */
  39980. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39981. /** Return this.onEnteringVRObservable
  39982. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39983. */
  39984. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39985. /** Return this.onExitingVRObservable
  39986. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39987. */
  39988. readonly onExitingVR: Observable<VRExperienceHelper>;
  39989. /** Return this.onControllerMeshLoadedObservable
  39990. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39991. */
  39992. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39993. private _rayLength;
  39994. private _useCustomVRButton;
  39995. private _teleportationRequested;
  39996. private _teleportActive;
  39997. private _floorMeshName;
  39998. private _floorMeshesCollection;
  39999. private _rotationAllowed;
  40000. private _teleportBackwardsVector;
  40001. private _teleportationTarget;
  40002. private _isDefaultTeleportationTarget;
  40003. private _postProcessMove;
  40004. private _teleportationFillColor;
  40005. private _teleportationBorderColor;
  40006. private _rotationAngle;
  40007. private _haloCenter;
  40008. private _cameraGazer;
  40009. private _padSensibilityUp;
  40010. private _padSensibilityDown;
  40011. private _leftController;
  40012. private _rightController;
  40013. /**
  40014. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40015. */
  40016. onNewMeshSelected: Observable<AbstractMesh>;
  40017. /**
  40018. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40019. */
  40020. onNewMeshPicked: Observable<PickingInfo>;
  40021. private _circleEase;
  40022. /**
  40023. * Observable raised before camera teleportation
  40024. */
  40025. onBeforeCameraTeleport: Observable<Vector3>;
  40026. /**
  40027. * Observable raised after camera teleportation
  40028. */
  40029. onAfterCameraTeleport: Observable<Vector3>;
  40030. /**
  40031. * Observable raised when current selected mesh gets unselected
  40032. */
  40033. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40034. private _raySelectionPredicate;
  40035. /**
  40036. * To be optionaly changed by user to define custom ray selection
  40037. */
  40038. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40039. /**
  40040. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40041. */
  40042. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40043. /**
  40044. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40045. */
  40046. teleportationEnabled: boolean;
  40047. private _defaultHeight;
  40048. private _teleportationInitialized;
  40049. private _interactionsEnabled;
  40050. private _interactionsRequested;
  40051. private _displayGaze;
  40052. private _displayLaserPointer;
  40053. /**
  40054. * The mesh used to display where the user is going to teleport.
  40055. */
  40056. /**
  40057. * Sets the mesh to be used to display where the user is going to teleport.
  40058. */
  40059. teleportationTarget: Mesh;
  40060. /**
  40061. * 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
  40062. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40063. * See http://doc.babylonjs.com/resources/baking_transformations
  40064. */
  40065. gazeTrackerMesh: Mesh;
  40066. /**
  40067. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40068. */
  40069. updateGazeTrackerScale: boolean;
  40070. /**
  40071. * If the gaze trackers color should be updated when selecting meshes
  40072. */
  40073. updateGazeTrackerColor: boolean;
  40074. /**
  40075. * The gaze tracking mesh corresponding to the left controller
  40076. */
  40077. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40078. /**
  40079. * The gaze tracking mesh corresponding to the right controller
  40080. */
  40081. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40082. /**
  40083. * If the ray of the gaze should be displayed.
  40084. */
  40085. /**
  40086. * Sets if the ray of the gaze should be displayed.
  40087. */
  40088. displayGaze: boolean;
  40089. /**
  40090. * If the ray of the LaserPointer should be displayed.
  40091. */
  40092. /**
  40093. * Sets if the ray of the LaserPointer should be displayed.
  40094. */
  40095. displayLaserPointer: boolean;
  40096. /**
  40097. * The deviceOrientationCamera used as the camera when not in VR.
  40098. */
  40099. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40100. /**
  40101. * Based on the current WebVR support, returns the current VR camera used.
  40102. */
  40103. readonly currentVRCamera: Nullable<Camera>;
  40104. /**
  40105. * The webVRCamera which is used when in VR.
  40106. */
  40107. readonly webVRCamera: WebVRFreeCamera;
  40108. /**
  40109. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40110. */
  40111. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40112. private readonly _teleportationRequestInitiated;
  40113. /**
  40114. * Defines wether or not Pointer lock should be requested when switching to
  40115. * full screen.
  40116. */
  40117. requestPointerLockOnFullScreen: boolean;
  40118. /**
  40119. * Instantiates a VRExperienceHelper.
  40120. * Helps to quickly add VR support to an existing scene.
  40121. * @param scene The scene the VRExperienceHelper belongs to.
  40122. * @param webVROptions Options to modify the vr experience helper's behavior.
  40123. */
  40124. constructor(scene: Scene,
  40125. /** Options to modify the vr experience helper's behavior. */
  40126. webVROptions?: VRExperienceHelperOptions);
  40127. private _onDefaultMeshLoaded;
  40128. private _onResize;
  40129. private _onFullscreenChange;
  40130. /**
  40131. * Gets a value indicating if we are currently in VR mode.
  40132. */
  40133. readonly isInVRMode: boolean;
  40134. private onVrDisplayPresentChange;
  40135. private onVRDisplayChanged;
  40136. private moveButtonToBottomRight;
  40137. private displayVRButton;
  40138. private updateButtonVisibility;
  40139. private _cachedAngularSensibility;
  40140. /**
  40141. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40142. * Otherwise, will use the fullscreen API.
  40143. */
  40144. enterVR(): void;
  40145. /**
  40146. * Attempt to exit VR, or fullscreen.
  40147. */
  40148. exitVR(): void;
  40149. /**
  40150. * The position of the vr experience helper.
  40151. */
  40152. /**
  40153. * Sets the position of the vr experience helper.
  40154. */
  40155. position: Vector3;
  40156. /**
  40157. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40158. */
  40159. enableInteractions(): void;
  40160. private readonly _noControllerIsActive;
  40161. private beforeRender;
  40162. private _isTeleportationFloor;
  40163. /**
  40164. * Adds a floor mesh to be used for teleportation.
  40165. * @param floorMesh the mesh to be used for teleportation.
  40166. */
  40167. addFloorMesh(floorMesh: Mesh): void;
  40168. /**
  40169. * Removes a floor mesh from being used for teleportation.
  40170. * @param floorMesh the mesh to be removed.
  40171. */
  40172. removeFloorMesh(floorMesh: Mesh): void;
  40173. /**
  40174. * Enables interactions and teleportation using the VR controllers and gaze.
  40175. * @param vrTeleportationOptions options to modify teleportation behavior.
  40176. */
  40177. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40178. private _onNewGamepadConnected;
  40179. private _tryEnableInteractionOnController;
  40180. private _onNewGamepadDisconnected;
  40181. private _enableInteractionOnController;
  40182. private _checkTeleportWithRay;
  40183. private _checkRotate;
  40184. private _checkTeleportBackwards;
  40185. private _enableTeleportationOnController;
  40186. private _createTeleportationCircles;
  40187. private _displayTeleportationTarget;
  40188. private _hideTeleportationTarget;
  40189. private _rotateCamera;
  40190. private _moveTeleportationSelectorTo;
  40191. private _workingVector;
  40192. private _workingQuaternion;
  40193. private _workingMatrix;
  40194. /**
  40195. * Teleports the users feet to the desired location
  40196. * @param location The location where the user's feet should be placed
  40197. */
  40198. teleportCamera(location: Vector3): void;
  40199. private _convertNormalToDirectionOfRay;
  40200. private _castRayAndSelectObject;
  40201. private _notifySelectedMeshUnselected;
  40202. /**
  40203. * Sets the color of the laser ray from the vr controllers.
  40204. * @param color new color for the ray.
  40205. */
  40206. changeLaserColor(color: Color3): void;
  40207. /**
  40208. * Sets the color of the ray from the vr headsets gaze.
  40209. * @param color new color for the ray.
  40210. */
  40211. changeGazeColor(color: Color3): void;
  40212. /**
  40213. * Exits VR and disposes of the vr experience helper
  40214. */
  40215. dispose(): void;
  40216. /**
  40217. * Gets the name of the VRExperienceHelper class
  40218. * @returns "VRExperienceHelper"
  40219. */
  40220. getClassName(): string;
  40221. }
  40222. }
  40223. declare module "babylonjs/Cameras/VR/index" {
  40224. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40225. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40226. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40227. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40228. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40229. export * from "babylonjs/Cameras/VR/webVRCamera";
  40230. }
  40231. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40232. import { Observable } from "babylonjs/Misc/observable";
  40233. import { Nullable } from "babylonjs/types";
  40234. import { IDisposable, Scene } from "babylonjs/scene";
  40235. import { Vector3 } from "babylonjs/Maths/math";
  40236. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40237. import { Ray } from "babylonjs/Culling/ray";
  40238. /**
  40239. * Manages an XRSession
  40240. * @see https://doc.babylonjs.com/how_to/webxr
  40241. */
  40242. export class WebXRSessionManager implements IDisposable {
  40243. private scene;
  40244. /**
  40245. * Fires every time a new xrFrame arrives which can be used to update the camera
  40246. */
  40247. onXRFrameObservable: Observable<any>;
  40248. /**
  40249. * Fires when the xr session is ended either by the device or manually done
  40250. */
  40251. onXRSessionEnded: Observable<any>;
  40252. /** @hidden */
  40253. _xrSession: XRSession;
  40254. /** @hidden */
  40255. _frameOfReference: XRFrameOfReference;
  40256. /** @hidden */
  40257. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40258. /** @hidden */
  40259. _currentXRFrame: Nullable<XRFrame>;
  40260. private _xrNavigator;
  40261. private _xrDevice;
  40262. private _tmpMatrix;
  40263. /**
  40264. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40265. * @param scene The scene which the session should be created for
  40266. */
  40267. constructor(scene: Scene);
  40268. /**
  40269. * Initializes the manager
  40270. * After initialization enterXR can be called to start an XR session
  40271. * @returns Promise which resolves after it is initialized
  40272. */
  40273. initializeAsync(): Promise<void>;
  40274. /**
  40275. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40276. * @param sessionCreationOptions xr options to create the session with
  40277. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40278. * @returns Promise which resolves after it enters XR
  40279. */
  40280. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40281. /**
  40282. * Stops the xrSession and restores the renderloop
  40283. * @returns Promise which resolves after it exits XR
  40284. */
  40285. exitXRAsync(): Promise<void>;
  40286. /**
  40287. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40288. * @param ray ray to cast into the environment
  40289. * @returns Promise which resolves with a collision point in the environment if it exists
  40290. */
  40291. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40292. /**
  40293. * Checks if a session would be supported for the creation options specified
  40294. * @param options creation options to check if they are supported
  40295. * @returns true if supported
  40296. */
  40297. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40298. /**
  40299. * @hidden
  40300. * Converts the render layer of xrSession to a render target
  40301. * @param session session to create render target for
  40302. * @param scene scene the new render target should be created for
  40303. */
  40304. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40305. /**
  40306. * Disposes of the session manager
  40307. */
  40308. dispose(): void;
  40309. }
  40310. }
  40311. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40312. import { Scene } from "babylonjs/scene";
  40313. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40314. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40315. /**
  40316. * WebXR Camera which holds the views for the xrSession
  40317. * @see https://doc.babylonjs.com/how_to/webxr
  40318. */
  40319. export class WebXRCamera extends FreeCamera {
  40320. private static _TmpMatrix;
  40321. /**
  40322. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40323. * @param name the name of the camera
  40324. * @param scene the scene to add the camera to
  40325. */
  40326. constructor(name: string, scene: Scene);
  40327. private _updateNumberOfRigCameras;
  40328. /** @hidden */
  40329. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40330. /**
  40331. * Updates the cameras position from the current pose information of the XR session
  40332. * @param xrSessionManager the session containing pose information
  40333. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40334. */
  40335. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40336. }
  40337. }
  40338. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40339. import { Nullable } from "babylonjs/types";
  40340. import { Observable } from "babylonjs/Misc/observable";
  40341. import { IDisposable, Scene } from "babylonjs/scene";
  40342. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40344. import { Ray } from "babylonjs/Culling/ray";
  40345. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40346. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40347. /**
  40348. * States of the webXR experience
  40349. */
  40350. export enum WebXRState {
  40351. /**
  40352. * Transitioning to being in XR mode
  40353. */
  40354. ENTERING_XR = 0,
  40355. /**
  40356. * Transitioning to non XR mode
  40357. */
  40358. EXITING_XR = 1,
  40359. /**
  40360. * In XR mode and presenting
  40361. */
  40362. IN_XR = 2,
  40363. /**
  40364. * Not entered XR mode
  40365. */
  40366. NOT_IN_XR = 3
  40367. }
  40368. /**
  40369. * Helper class used to enable XR
  40370. * @see https://doc.babylonjs.com/how_to/webxr
  40371. */
  40372. export class WebXRExperienceHelper implements IDisposable {
  40373. private scene;
  40374. /**
  40375. * 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
  40376. */
  40377. container: AbstractMesh;
  40378. /**
  40379. * Camera used to render xr content
  40380. */
  40381. camera: WebXRCamera;
  40382. /**
  40383. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40384. */
  40385. state: WebXRState;
  40386. private _setState;
  40387. private static _TmpVector;
  40388. /**
  40389. * Fires when the state of the experience helper has changed
  40390. */
  40391. onStateChangedObservable: Observable<WebXRState>;
  40392. /** @hidden */
  40393. _sessionManager: WebXRSessionManager;
  40394. private _nonVRCamera;
  40395. private _originalSceneAutoClear;
  40396. private _supported;
  40397. /**
  40398. * Creates the experience helper
  40399. * @param scene the scene to attach the experience helper to
  40400. * @returns a promise for the experience helper
  40401. */
  40402. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40403. /**
  40404. * Creates a WebXRExperienceHelper
  40405. * @param scene The scene the helper should be created in
  40406. */
  40407. private constructor();
  40408. /**
  40409. * Exits XR mode and returns the scene to its original state
  40410. * @returns promise that resolves after xr mode has exited
  40411. */
  40412. exitXRAsync(): Promise<void>;
  40413. /**
  40414. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40415. * @param sessionCreationOptions options for the XR session
  40416. * @param frameOfReference frame of reference of the XR session
  40417. * @returns promise that resolves after xr mode has entered
  40418. */
  40419. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40420. /**
  40421. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40422. * @param ray ray to cast into the environment
  40423. * @returns Promise which resolves with a collision point in the environment if it exists
  40424. */
  40425. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40426. /**
  40427. * Updates the global position of the camera by moving the camera's container
  40428. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40429. * @param position The desired global position of the camera
  40430. */
  40431. setPositionOfCameraUsingContainer(position: Vector3): void;
  40432. /**
  40433. * Rotates the xr camera by rotating the camera's container around the camera's position
  40434. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40435. * @param rotation the desired quaternion rotation to apply to the camera
  40436. */
  40437. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40438. /**
  40439. * Checks if the creation options are supported by the xr session
  40440. * @param options creation options
  40441. * @returns true if supported
  40442. */
  40443. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40444. /**
  40445. * Disposes of the experience helper
  40446. */
  40447. dispose(): void;
  40448. }
  40449. }
  40450. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40451. import { Nullable } from "babylonjs/types";
  40452. import { Observable } from "babylonjs/Misc/observable";
  40453. import { IDisposable, Scene } from "babylonjs/scene";
  40454. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40455. /**
  40456. * Button which can be used to enter a different mode of XR
  40457. */
  40458. export class WebXREnterExitUIButton {
  40459. /** button element */
  40460. element: HTMLElement;
  40461. /** XR initialization options for the button */
  40462. initializationOptions: XRSessionCreationOptions;
  40463. /**
  40464. * Creates a WebXREnterExitUIButton
  40465. * @param element button element
  40466. * @param initializationOptions XR initialization options for the button
  40467. */
  40468. constructor(
  40469. /** button element */
  40470. element: HTMLElement,
  40471. /** XR initialization options for the button */
  40472. initializationOptions: XRSessionCreationOptions);
  40473. /**
  40474. * Overwritable function which can be used to update the button's visuals when the state changes
  40475. * @param activeButton the current active button in the UI
  40476. */
  40477. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40478. }
  40479. /**
  40480. * Options to create the webXR UI
  40481. */
  40482. export class WebXREnterExitUIOptions {
  40483. /**
  40484. * Context to enter xr with
  40485. */
  40486. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40487. /**
  40488. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40489. */
  40490. customButtons?: Array<WebXREnterExitUIButton>;
  40491. }
  40492. /**
  40493. * UI to allow the user to enter/exit XR mode
  40494. */
  40495. export class WebXREnterExitUI implements IDisposable {
  40496. private scene;
  40497. private _overlay;
  40498. private _buttons;
  40499. private _activeButton;
  40500. /**
  40501. * Fired every time the active button is changed.
  40502. *
  40503. * When xr is entered via a button that launches xr that button will be the callback parameter
  40504. *
  40505. * When exiting xr the callback parameter will be null)
  40506. */
  40507. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40508. /**
  40509. * Creates UI to allow the user to enter/exit XR mode
  40510. * @param scene the scene to add the ui to
  40511. * @param helper the xr experience helper to enter/exit xr with
  40512. * @param options options to configure the UI
  40513. * @returns the created ui
  40514. */
  40515. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40516. private constructor();
  40517. private _updateButtons;
  40518. /**
  40519. * Disposes of the object
  40520. */
  40521. dispose(): void;
  40522. }
  40523. }
  40524. declare module "babylonjs/Cameras/XR/webXRInput" {
  40525. import { IDisposable, Scene } from "babylonjs/scene";
  40526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40527. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40528. /**
  40529. * Represents an XR input
  40530. */
  40531. export class WebXRController {
  40532. /**
  40533. * 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
  40534. */
  40535. grip?: AbstractMesh;
  40536. /**
  40537. * Pointer which can be used to select objects or attach a visible laser to
  40538. */
  40539. pointer: AbstractMesh;
  40540. /**
  40541. * Creates the controller
  40542. * @see https://doc.babylonjs.com/how_to/webxr
  40543. * @param scene the scene which the controller should be associated to
  40544. */
  40545. constructor(scene: Scene);
  40546. /**
  40547. * Disposes of the object
  40548. */
  40549. dispose(): void;
  40550. }
  40551. /**
  40552. * XR input used to track XR inputs such as controllers/rays
  40553. */
  40554. export class WebXRInput implements IDisposable {
  40555. private helper;
  40556. /**
  40557. * XR controllers being tracked
  40558. */
  40559. controllers: Array<WebXRController>;
  40560. private _tmpMatrix;
  40561. private _frameObserver;
  40562. /**
  40563. * Initializes the WebXRInput
  40564. * @param helper experience helper which the input should be created for
  40565. */
  40566. constructor(helper: WebXRExperienceHelper);
  40567. /**
  40568. * Disposes of the object
  40569. */
  40570. dispose(): void;
  40571. }
  40572. }
  40573. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40574. import { Nullable } from "babylonjs/types";
  40575. import { IDisposable } from "babylonjs/scene";
  40576. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40577. /**
  40578. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40579. */
  40580. export class WebXRManagedOutputCanvas implements IDisposable {
  40581. private _canvas;
  40582. /**
  40583. * xrpresent context of the canvas which can be used to display/mirror xr content
  40584. */
  40585. canvasContext: Nullable<WebGLRenderingContext>;
  40586. /**
  40587. * Initializes the canvas to be added/removed upon entering/exiting xr
  40588. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40589. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40590. */
  40591. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40592. /**
  40593. * Disposes of the object
  40594. */
  40595. dispose(): void;
  40596. private _setManagedOutputCanvas;
  40597. private _addCanvas;
  40598. private _removeCanvas;
  40599. }
  40600. }
  40601. declare module "babylonjs/Cameras/XR/index" {
  40602. export * from "babylonjs/Cameras/XR/webXRCamera";
  40603. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40604. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40605. export * from "babylonjs/Cameras/XR/webXRInput";
  40606. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40607. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40608. }
  40609. declare module "babylonjs/Cameras/RigModes/index" {
  40610. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40611. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40612. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40613. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40614. }
  40615. declare module "babylonjs/Cameras/index" {
  40616. export * from "babylonjs/Cameras/Inputs/index";
  40617. export * from "babylonjs/Cameras/cameraInputsManager";
  40618. export * from "babylonjs/Cameras/camera";
  40619. export * from "babylonjs/Cameras/targetCamera";
  40620. export * from "babylonjs/Cameras/freeCamera";
  40621. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40622. export * from "babylonjs/Cameras/touchCamera";
  40623. export * from "babylonjs/Cameras/arcRotateCamera";
  40624. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40625. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40626. export * from "babylonjs/Cameras/flyCamera";
  40627. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40628. export * from "babylonjs/Cameras/followCamera";
  40629. export * from "babylonjs/Cameras/gamepadCamera";
  40630. export * from "babylonjs/Cameras/Stereoscopic/index";
  40631. export * from "babylonjs/Cameras/universalCamera";
  40632. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40633. export * from "babylonjs/Cameras/VR/index";
  40634. export * from "babylonjs/Cameras/XR/index";
  40635. export * from "babylonjs/Cameras/RigModes/index";
  40636. }
  40637. declare module "babylonjs/Collisions/index" {
  40638. export * from "babylonjs/Collisions/collider";
  40639. export * from "babylonjs/Collisions/collisionCoordinator";
  40640. export * from "babylonjs/Collisions/pickingInfo";
  40641. export * from "babylonjs/Collisions/intersectionInfo";
  40642. }
  40643. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40644. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40645. import { Vector3, Plane } from "babylonjs/Maths/math";
  40646. import { Ray } from "babylonjs/Culling/ray";
  40647. /**
  40648. * Contains an array of blocks representing the octree
  40649. */
  40650. export interface IOctreeContainer<T> {
  40651. /**
  40652. * Blocks within the octree
  40653. */
  40654. blocks: Array<OctreeBlock<T>>;
  40655. }
  40656. /**
  40657. * Class used to store a cell in an octree
  40658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40659. */
  40660. export class OctreeBlock<T> {
  40661. /**
  40662. * Gets the content of the current block
  40663. */
  40664. entries: T[];
  40665. /**
  40666. * Gets the list of block children
  40667. */
  40668. blocks: Array<OctreeBlock<T>>;
  40669. private _depth;
  40670. private _maxDepth;
  40671. private _capacity;
  40672. private _minPoint;
  40673. private _maxPoint;
  40674. private _boundingVectors;
  40675. private _creationFunc;
  40676. /**
  40677. * Creates a new block
  40678. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40679. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40680. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40681. * @param depth defines the current depth of this block in the octree
  40682. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40683. * @param creationFunc defines a callback to call when an element is added to the block
  40684. */
  40685. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40686. /**
  40687. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40688. */
  40689. readonly capacity: number;
  40690. /**
  40691. * Gets the minimum vector (in world space) of the block's bounding box
  40692. */
  40693. readonly minPoint: Vector3;
  40694. /**
  40695. * Gets the maximum vector (in world space) of the block's bounding box
  40696. */
  40697. readonly maxPoint: Vector3;
  40698. /**
  40699. * Add a new element to this block
  40700. * @param entry defines the element to add
  40701. */
  40702. addEntry(entry: T): void;
  40703. /**
  40704. * Remove an element from this block
  40705. * @param entry defines the element to remove
  40706. */
  40707. removeEntry(entry: T): void;
  40708. /**
  40709. * Add an array of elements to this block
  40710. * @param entries defines the array of elements to add
  40711. */
  40712. addEntries(entries: T[]): void;
  40713. /**
  40714. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40715. * @param frustumPlanes defines the frustum planes to test
  40716. * @param selection defines the array to store current content if selection is positive
  40717. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40718. */
  40719. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40720. /**
  40721. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40722. * @param sphereCenter defines the bounding sphere center
  40723. * @param sphereRadius defines the bounding sphere radius
  40724. * @param selection defines the array to store current content if selection is positive
  40725. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40726. */
  40727. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40728. /**
  40729. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40730. * @param ray defines the ray to test with
  40731. * @param selection defines the array to store current content if selection is positive
  40732. */
  40733. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40734. /**
  40735. * Subdivide the content into child blocks (this block will then be empty)
  40736. */
  40737. createInnerBlocks(): void;
  40738. /**
  40739. * @hidden
  40740. */
  40741. 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;
  40742. }
  40743. }
  40744. declare module "babylonjs/Culling/Octrees/octree" {
  40745. import { SmartArray } from "babylonjs/Misc/smartArray";
  40746. import { Vector3, Plane } from "babylonjs/Maths/math";
  40747. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40749. import { Ray } from "babylonjs/Culling/ray";
  40750. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40751. /**
  40752. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40753. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40754. */
  40755. export class Octree<T> {
  40756. /** 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.) */
  40757. maxDepth: number;
  40758. /**
  40759. * Blocks within the octree containing objects
  40760. */
  40761. blocks: Array<OctreeBlock<T>>;
  40762. /**
  40763. * Content stored in the octree
  40764. */
  40765. dynamicContent: T[];
  40766. private _maxBlockCapacity;
  40767. private _selectionContent;
  40768. private _creationFunc;
  40769. /**
  40770. * Creates a octree
  40771. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40772. * @param creationFunc function to be used to instatiate the octree
  40773. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40774. * @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.)
  40775. */
  40776. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40777. /** 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.) */
  40778. maxDepth?: number);
  40779. /**
  40780. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40781. * @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);
  40782. * @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);
  40783. * @param entries meshes to be added to the octree blocks
  40784. */
  40785. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40786. /**
  40787. * Adds a mesh to the octree
  40788. * @param entry Mesh to add to the octree
  40789. */
  40790. addMesh(entry: T): void;
  40791. /**
  40792. * Remove an element from the octree
  40793. * @param entry defines the element to remove
  40794. */
  40795. removeMesh(entry: T): void;
  40796. /**
  40797. * Selects an array of meshes within the frustum
  40798. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40799. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40800. * @returns array of meshes within the frustum
  40801. */
  40802. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40803. /**
  40804. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40805. * @param sphereCenter defines the bounding sphere center
  40806. * @param sphereRadius defines the bounding sphere radius
  40807. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40808. * @returns an array of objects that intersect the sphere
  40809. */
  40810. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40811. /**
  40812. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40813. * @param ray defines the ray to test with
  40814. * @returns array of intersected objects
  40815. */
  40816. intersectsRay(ray: Ray): SmartArray<T>;
  40817. /**
  40818. * Adds a mesh into the octree block if it intersects the block
  40819. */
  40820. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40821. /**
  40822. * Adds a submesh into the octree block if it intersects the block
  40823. */
  40824. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40825. }
  40826. }
  40827. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40828. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40829. import { Scene } from "babylonjs/scene";
  40830. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40832. import { Ray } from "babylonjs/Culling/ray";
  40833. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40834. import { Collider } from "babylonjs/Collisions/collider";
  40835. module "babylonjs/scene" {
  40836. interface Scene {
  40837. /**
  40838. * @hidden
  40839. * Backing Filed
  40840. */
  40841. _selectionOctree: Octree<AbstractMesh>;
  40842. /**
  40843. * Gets the octree used to boost mesh selection (picking)
  40844. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40845. */
  40846. selectionOctree: Octree<AbstractMesh>;
  40847. /**
  40848. * Creates or updates the octree used to boost selection (picking)
  40849. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40850. * @param maxCapacity defines the maximum capacity per leaf
  40851. * @param maxDepth defines the maximum depth of the octree
  40852. * @returns an octree of AbstractMesh
  40853. */
  40854. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40855. }
  40856. }
  40857. module "babylonjs/Meshes/abstractMesh" {
  40858. interface AbstractMesh {
  40859. /**
  40860. * @hidden
  40861. * Backing Field
  40862. */
  40863. _submeshesOctree: Octree<SubMesh>;
  40864. /**
  40865. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40866. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40867. * @param maxCapacity defines the maximum size of each block (64 by default)
  40868. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40869. * @returns the new octree
  40870. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40871. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40872. */
  40873. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40874. }
  40875. }
  40876. /**
  40877. * Defines the octree scene component responsible to manage any octrees
  40878. * in a given scene.
  40879. */
  40880. export class OctreeSceneComponent {
  40881. /**
  40882. * The component name helpfull to identify the component in the list of scene components.
  40883. */
  40884. readonly name: string;
  40885. /**
  40886. * The scene the component belongs to.
  40887. */
  40888. scene: Scene;
  40889. /**
  40890. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40891. */
  40892. readonly checksIsEnabled: boolean;
  40893. /**
  40894. * Creates a new instance of the component for the given scene
  40895. * @param scene Defines the scene to register the component in
  40896. */
  40897. constructor(scene: Scene);
  40898. /**
  40899. * Registers the component in a given scene
  40900. */
  40901. register(): void;
  40902. /**
  40903. * Return the list of active meshes
  40904. * @returns the list of active meshes
  40905. */
  40906. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40907. /**
  40908. * Return the list of active sub meshes
  40909. * @param mesh The mesh to get the candidates sub meshes from
  40910. * @returns the list of active sub meshes
  40911. */
  40912. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40913. private _tempRay;
  40914. /**
  40915. * Return the list of sub meshes intersecting with a given local ray
  40916. * @param mesh defines the mesh to find the submesh for
  40917. * @param localRay defines the ray in local space
  40918. * @returns the list of intersecting sub meshes
  40919. */
  40920. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40921. /**
  40922. * Return the list of sub meshes colliding with a collider
  40923. * @param mesh defines the mesh to find the submesh for
  40924. * @param collider defines the collider to evaluate the collision against
  40925. * @returns the list of colliding sub meshes
  40926. */
  40927. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40928. /**
  40929. * Rebuilds the elements related to this component in case of
  40930. * context lost for instance.
  40931. */
  40932. rebuild(): void;
  40933. /**
  40934. * Disposes the component and the associated ressources.
  40935. */
  40936. dispose(): void;
  40937. }
  40938. }
  40939. declare module "babylonjs/Culling/Octrees/index" {
  40940. export * from "babylonjs/Culling/Octrees/octree";
  40941. export * from "babylonjs/Culling/Octrees/octreeBlock";
  40942. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  40943. }
  40944. declare module "babylonjs/Culling/index" {
  40945. export * from "babylonjs/Culling/boundingBox";
  40946. export * from "babylonjs/Culling/boundingInfo";
  40947. export * from "babylonjs/Culling/boundingSphere";
  40948. export * from "babylonjs/Culling/Octrees/index";
  40949. export * from "babylonjs/Culling/ray";
  40950. }
  40951. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  40952. import { Vector3, Color4 } from "babylonjs/Maths/math";
  40953. import { Nullable } from "babylonjs/types";
  40954. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  40955. import { Scene } from "babylonjs/scene";
  40956. /**
  40957. * Class containing static functions to help procedurally build meshes
  40958. */
  40959. export class LinesBuilder {
  40960. /**
  40961. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40962. * * 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
  40963. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40964. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40965. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40966. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40967. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40968. * * 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
  40969. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40971. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40972. * @param name defines the name of the new line system
  40973. * @param options defines the options used to create the line system
  40974. * @param scene defines the hosting scene
  40975. * @returns a new line system mesh
  40976. */
  40977. static CreateLineSystem(name: string, options: {
  40978. lines: Vector3[][];
  40979. updatable?: boolean;
  40980. instance?: Nullable<LinesMesh>;
  40981. colors?: Nullable<Color4[][]>;
  40982. useVertexAlpha?: boolean;
  40983. }, scene: Nullable<Scene>): LinesMesh;
  40984. /**
  40985. * Creates a line mesh
  40986. * 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
  40987. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40988. * * The parameter `points` is an array successive Vector3
  40989. * * 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
  40990. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40991. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40992. * * When updating an instance, remember that only point positions can change, not the number of points
  40993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40995. * @param name defines the name of the new line system
  40996. * @param options defines the options used to create the line system
  40997. * @param scene defines the hosting scene
  40998. * @returns a new line mesh
  40999. */
  41000. static CreateLines(name: string, options: {
  41001. points: Vector3[];
  41002. updatable?: boolean;
  41003. instance?: Nullable<LinesMesh>;
  41004. colors?: Color4[];
  41005. useVertexAlpha?: boolean;
  41006. }, scene?: Nullable<Scene>): LinesMesh;
  41007. /**
  41008. * Creates a dashed line mesh
  41009. * * 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
  41010. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41011. * * The parameter `points` is an array successive Vector3
  41012. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41013. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41014. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41015. * * 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
  41016. * * When updating an instance, remember that only point positions can change, not the number of points
  41017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41018. * @param name defines the name of the mesh
  41019. * @param options defines the options used to create the mesh
  41020. * @param scene defines the hosting scene
  41021. * @returns the dashed line mesh
  41022. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41023. */
  41024. static CreateDashedLines(name: string, options: {
  41025. points: Vector3[];
  41026. dashSize?: number;
  41027. gapSize?: number;
  41028. dashNb?: number;
  41029. updatable?: boolean;
  41030. instance?: LinesMesh;
  41031. }, scene?: Nullable<Scene>): LinesMesh;
  41032. }
  41033. }
  41034. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41035. import { IDisposable, Scene } from "babylonjs/scene";
  41036. import { Nullable } from "babylonjs/types";
  41037. import { Observable } from "babylonjs/Misc/observable";
  41038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41039. /**
  41040. * Renders a layer on top of an existing scene
  41041. */
  41042. export class UtilityLayerRenderer implements IDisposable {
  41043. /** the original scene that will be rendered on top of */
  41044. originalScene: Scene;
  41045. private _pointerCaptures;
  41046. private _lastPointerEvents;
  41047. private static _DefaultUtilityLayer;
  41048. private static _DefaultKeepDepthUtilityLayer;
  41049. /**
  41050. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41051. */
  41052. pickUtilitySceneFirst: boolean;
  41053. /**
  41054. * 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)
  41055. */
  41056. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41057. /**
  41058. * 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)
  41059. */
  41060. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41061. /**
  41062. * The scene that is rendered on top of the original scene
  41063. */
  41064. utilityLayerScene: Scene;
  41065. /**
  41066. * If the utility layer should automatically be rendered on top of existing scene
  41067. */
  41068. shouldRender: boolean;
  41069. /**
  41070. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41071. */
  41072. onlyCheckPointerDownEvents: boolean;
  41073. /**
  41074. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41075. */
  41076. processAllEvents: boolean;
  41077. /**
  41078. * Observable raised when the pointer move from the utility layer scene to the main scene
  41079. */
  41080. onPointerOutObservable: Observable<number>;
  41081. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41082. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41083. private _afterRenderObserver;
  41084. private _sceneDisposeObserver;
  41085. private _originalPointerObserver;
  41086. /**
  41087. * Instantiates a UtilityLayerRenderer
  41088. * @param originalScene the original scene that will be rendered on top of
  41089. * @param handleEvents boolean indicating if the utility layer should handle events
  41090. */
  41091. constructor(
  41092. /** the original scene that will be rendered on top of */
  41093. originalScene: Scene, handleEvents?: boolean);
  41094. private _notifyObservers;
  41095. /**
  41096. * Renders the utility layers scene on top of the original scene
  41097. */
  41098. render(): void;
  41099. /**
  41100. * Disposes of the renderer
  41101. */
  41102. dispose(): void;
  41103. private _updateCamera;
  41104. }
  41105. }
  41106. declare module "babylonjs/Gizmos/gizmo" {
  41107. import { Nullable } from "babylonjs/types";
  41108. import { IDisposable } from "babylonjs/scene";
  41109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41110. import { Mesh } from "babylonjs/Meshes/mesh";
  41111. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41112. /**
  41113. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41114. */
  41115. export class Gizmo implements IDisposable {
  41116. /** The utility layer the gizmo will be added to */
  41117. gizmoLayer: UtilityLayerRenderer;
  41118. /**
  41119. * The root mesh of the gizmo
  41120. */
  41121. _rootMesh: Mesh;
  41122. private _attachedMesh;
  41123. /**
  41124. * Ratio for the scale of the gizmo (Default: 1)
  41125. */
  41126. scaleRatio: number;
  41127. private _tmpMatrix;
  41128. /**
  41129. * If a custom mesh has been set (Default: false)
  41130. */
  41131. protected _customMeshSet: boolean;
  41132. /**
  41133. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41134. * * When set, interactions will be enabled
  41135. */
  41136. attachedMesh: Nullable<AbstractMesh>;
  41137. /**
  41138. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41139. * @param mesh The mesh to replace the default mesh of the gizmo
  41140. */
  41141. setCustomMesh(mesh: Mesh): void;
  41142. /**
  41143. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41144. */
  41145. updateGizmoRotationToMatchAttachedMesh: boolean;
  41146. /**
  41147. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41148. */
  41149. updateGizmoPositionToMatchAttachedMesh: boolean;
  41150. /**
  41151. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41152. */
  41153. protected _updateScale: boolean;
  41154. protected _interactionsEnabled: boolean;
  41155. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41156. private _beforeRenderObserver;
  41157. /**
  41158. * Creates a gizmo
  41159. * @param gizmoLayer The utility layer the gizmo will be added to
  41160. */
  41161. constructor(
  41162. /** The utility layer the gizmo will be added to */
  41163. gizmoLayer?: UtilityLayerRenderer);
  41164. private _tempVector;
  41165. /**
  41166. * @hidden
  41167. * Updates the gizmo to match the attached mesh's position/rotation
  41168. */
  41169. protected _update(): void;
  41170. /**
  41171. * Disposes of the gizmo
  41172. */
  41173. dispose(): void;
  41174. }
  41175. }
  41176. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41177. import { Observable } from "babylonjs/Misc/observable";
  41178. import { Nullable } from "babylonjs/types";
  41179. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41180. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41182. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41183. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41184. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41185. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41186. import { Scene } from "babylonjs/scene";
  41187. /**
  41188. * Single axis drag gizmo
  41189. */
  41190. export class AxisDragGizmo extends Gizmo {
  41191. /**
  41192. * Drag behavior responsible for the gizmos dragging interactions
  41193. */
  41194. dragBehavior: PointerDragBehavior;
  41195. private _pointerObserver;
  41196. /**
  41197. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41198. */
  41199. snapDistance: number;
  41200. /**
  41201. * Event that fires each time the gizmo snaps to a new location.
  41202. * * snapDistance is the the change in distance
  41203. */
  41204. onSnapObservable: Observable<{
  41205. snapDistance: number;
  41206. }>;
  41207. /** @hidden */
  41208. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41209. /** @hidden */
  41210. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41211. /**
  41212. * Creates an AxisDragGizmo
  41213. * @param gizmoLayer The utility layer the gizmo will be added to
  41214. * @param dragAxis The axis which the gizmo will be able to drag on
  41215. * @param color The color of the gizmo
  41216. */
  41217. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41218. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41219. /**
  41220. * Disposes of the gizmo
  41221. */
  41222. dispose(): void;
  41223. }
  41224. }
  41225. declare module "babylonjs/Debug/axesViewer" {
  41226. import { Vector3 } from "babylonjs/Maths/math";
  41227. import { Nullable } from "babylonjs/types";
  41228. import { Scene } from "babylonjs/scene";
  41229. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41230. /**
  41231. * The Axes viewer will show 3 axes in a specific point in space
  41232. */
  41233. export class AxesViewer {
  41234. private _xAxis;
  41235. private _yAxis;
  41236. private _zAxis;
  41237. private _scaleLinesFactor;
  41238. private _instanced;
  41239. /**
  41240. * Gets the hosting scene
  41241. */
  41242. scene: Scene;
  41243. /**
  41244. * Gets or sets a number used to scale line length
  41245. */
  41246. scaleLines: number;
  41247. /** Gets the node hierarchy used to render x-axis */
  41248. readonly xAxis: TransformNode;
  41249. /** Gets the node hierarchy used to render y-axis */
  41250. readonly yAxis: TransformNode;
  41251. /** Gets the node hierarchy used to render z-axis */
  41252. readonly zAxis: TransformNode;
  41253. /**
  41254. * Creates a new AxesViewer
  41255. * @param scene defines the hosting scene
  41256. * @param scaleLines defines a number used to scale line length (1 by default)
  41257. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41258. * @param xAxis defines the node hierarchy used to render the x-axis
  41259. * @param yAxis defines the node hierarchy used to render the y-axis
  41260. * @param zAxis defines the node hierarchy used to render the z-axis
  41261. */
  41262. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41263. /**
  41264. * Force the viewer to update
  41265. * @param position defines the position of the viewer
  41266. * @param xaxis defines the x axis of the viewer
  41267. * @param yaxis defines the y axis of the viewer
  41268. * @param zaxis defines the z axis of the viewer
  41269. */
  41270. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41271. /**
  41272. * Creates an instance of this axes viewer.
  41273. * @returns a new axes viewer with instanced meshes
  41274. */
  41275. createInstance(): AxesViewer;
  41276. /** Releases resources */
  41277. dispose(): void;
  41278. private static _SetRenderingGroupId;
  41279. }
  41280. }
  41281. declare module "babylonjs/Debug/boneAxesViewer" {
  41282. import { Nullable } from "babylonjs/types";
  41283. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41284. import { Vector3 } from "babylonjs/Maths/math";
  41285. import { Mesh } from "babylonjs/Meshes/mesh";
  41286. import { Bone } from "babylonjs/Bones/bone";
  41287. import { Scene } from "babylonjs/scene";
  41288. /**
  41289. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41290. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41291. */
  41292. export class BoneAxesViewer extends AxesViewer {
  41293. /**
  41294. * Gets or sets the target mesh where to display the axes viewer
  41295. */
  41296. mesh: Nullable<Mesh>;
  41297. /**
  41298. * Gets or sets the target bone where to display the axes viewer
  41299. */
  41300. bone: Nullable<Bone>;
  41301. /** Gets current position */
  41302. pos: Vector3;
  41303. /** Gets direction of X axis */
  41304. xaxis: Vector3;
  41305. /** Gets direction of Y axis */
  41306. yaxis: Vector3;
  41307. /** Gets direction of Z axis */
  41308. zaxis: Vector3;
  41309. /**
  41310. * Creates a new BoneAxesViewer
  41311. * @param scene defines the hosting scene
  41312. * @param bone defines the target bone
  41313. * @param mesh defines the target mesh
  41314. * @param scaleLines defines a scaling factor for line length (1 by default)
  41315. */
  41316. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41317. /**
  41318. * Force the viewer to update
  41319. */
  41320. update(): void;
  41321. /** Releases resources */
  41322. dispose(): void;
  41323. }
  41324. }
  41325. declare module "babylonjs/Debug/debugLayer" {
  41326. import { Observable } from "babylonjs/Misc/observable";
  41327. import { Scene } from "babylonjs/scene";
  41328. /**
  41329. * Interface used to define scene explorer extensibility option
  41330. */
  41331. export interface IExplorerExtensibilityOption {
  41332. /**
  41333. * Define the option label
  41334. */
  41335. label: string;
  41336. /**
  41337. * Defines the action to execute on click
  41338. */
  41339. action: (entity: any) => void;
  41340. }
  41341. /**
  41342. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41343. */
  41344. export interface IExplorerExtensibilityGroup {
  41345. /**
  41346. * Defines a predicate to test if a given type mut be extended
  41347. */
  41348. predicate: (entity: any) => boolean;
  41349. /**
  41350. * Gets the list of options added to a type
  41351. */
  41352. entries: IExplorerExtensibilityOption[];
  41353. }
  41354. /**
  41355. * Interface used to define the options to use to create the Inspector
  41356. */
  41357. export interface IInspectorOptions {
  41358. /**
  41359. * Display in overlay mode (default: false)
  41360. */
  41361. overlay?: boolean;
  41362. /**
  41363. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41364. */
  41365. globalRoot?: HTMLElement;
  41366. /**
  41367. * Display the Scene explorer
  41368. */
  41369. showExplorer?: boolean;
  41370. /**
  41371. * Display the property inspector
  41372. */
  41373. showInspector?: boolean;
  41374. /**
  41375. * Display in embed mode (both panes on the right)
  41376. */
  41377. embedMode?: boolean;
  41378. /**
  41379. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41380. */
  41381. handleResize?: boolean;
  41382. /**
  41383. * Allow the panes to popup (default: true)
  41384. */
  41385. enablePopup?: boolean;
  41386. /**
  41387. * Allow the panes to be closed by users (default: true)
  41388. */
  41389. enableClose?: boolean;
  41390. /**
  41391. * Optional list of extensibility entries
  41392. */
  41393. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41394. /**
  41395. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41396. */
  41397. inspectorURL?: string;
  41398. }
  41399. module "babylonjs/scene" {
  41400. interface Scene {
  41401. /**
  41402. * @hidden
  41403. * Backing field
  41404. */
  41405. _debugLayer: DebugLayer;
  41406. /**
  41407. * Gets the debug layer (aka Inspector) associated with the scene
  41408. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41409. */
  41410. debugLayer: DebugLayer;
  41411. }
  41412. }
  41413. /**
  41414. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41415. * what is happening in your scene
  41416. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41417. */
  41418. export class DebugLayer {
  41419. /**
  41420. * Define the url to get the inspector script from.
  41421. * By default it uses the babylonjs CDN.
  41422. * @ignoreNaming
  41423. */
  41424. static InspectorURL: string;
  41425. private _scene;
  41426. private BJSINSPECTOR;
  41427. /**
  41428. * Observable triggered when a property is changed through the inspector.
  41429. */
  41430. onPropertyChangedObservable: Observable<{
  41431. object: any;
  41432. property: string;
  41433. value: any;
  41434. initialValue: any;
  41435. }>;
  41436. /**
  41437. * Instantiates a new debug layer.
  41438. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41439. * what is happening in your scene
  41440. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41441. * @param scene Defines the scene to inspect
  41442. */
  41443. constructor(scene: Scene);
  41444. /** Creates the inspector window. */
  41445. private _createInspector;
  41446. /**
  41447. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41448. * @param entity defines the entity to select
  41449. * @param lineContainerTitle defines the specific block to highlight
  41450. */
  41451. select(entity: any, lineContainerTitle?: string): void;
  41452. /** Get the inspector from bundle or global */
  41453. private _getGlobalInspector;
  41454. /**
  41455. * Get if the inspector is visible or not.
  41456. * @returns true if visible otherwise, false
  41457. */
  41458. isVisible(): boolean;
  41459. /**
  41460. * Hide the inspector and close its window.
  41461. */
  41462. hide(): void;
  41463. /**
  41464. * Launch the debugLayer.
  41465. * @param config Define the configuration of the inspector
  41466. * @return a promise fulfilled when the debug layer is visible
  41467. */
  41468. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41469. }
  41470. }
  41471. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41472. import { Nullable } from "babylonjs/types";
  41473. import { Scene } from "babylonjs/scene";
  41474. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41475. import { Mesh } from "babylonjs/Meshes/mesh";
  41476. /**
  41477. * Class containing static functions to help procedurally build meshes
  41478. */
  41479. export class BoxBuilder {
  41480. /**
  41481. * Creates a box mesh
  41482. * * The parameter `size` sets the size (float) of each box side (default 1)
  41483. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41484. * * 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)
  41485. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41489. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41490. * @param name defines the name of the mesh
  41491. * @param options defines the options used to create the mesh
  41492. * @param scene defines the hosting scene
  41493. * @returns the box mesh
  41494. */
  41495. static CreateBox(name: string, options: {
  41496. size?: number;
  41497. width?: number;
  41498. height?: number;
  41499. depth?: number;
  41500. faceUV?: Vector4[];
  41501. faceColors?: Color4[];
  41502. sideOrientation?: number;
  41503. frontUVs?: Vector4;
  41504. backUVs?: Vector4;
  41505. updatable?: boolean;
  41506. }, scene?: Nullable<Scene>): Mesh;
  41507. }
  41508. }
  41509. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41510. import { Vector4 } from "babylonjs/Maths/math";
  41511. import { Mesh } from "babylonjs/Meshes/mesh";
  41512. /**
  41513. * Class containing static functions to help procedurally build meshes
  41514. */
  41515. export class SphereBuilder {
  41516. /**
  41517. * Creates a sphere mesh
  41518. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41519. * * 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`)
  41520. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41521. * * 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
  41522. * * 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)
  41523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41524. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41526. * @param name defines the name of the mesh
  41527. * @param options defines the options used to create the mesh
  41528. * @param scene defines the hosting scene
  41529. * @returns the sphere mesh
  41530. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41531. */
  41532. static CreateSphere(name: string, options: {
  41533. segments?: number;
  41534. diameter?: number;
  41535. diameterX?: number;
  41536. diameterY?: number;
  41537. diameterZ?: number;
  41538. arc?: number;
  41539. slice?: number;
  41540. sideOrientation?: number;
  41541. frontUVs?: Vector4;
  41542. backUVs?: Vector4;
  41543. updatable?: boolean;
  41544. }, scene: any): Mesh;
  41545. }
  41546. }
  41547. declare module "babylonjs/Debug/physicsViewer" {
  41548. import { Nullable } from "babylonjs/types";
  41549. import { Scene } from "babylonjs/scene";
  41550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41551. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41552. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41553. /**
  41554. * Used to show the physics impostor around the specific mesh
  41555. */
  41556. export class PhysicsViewer {
  41557. /** @hidden */
  41558. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41559. /** @hidden */
  41560. protected _meshes: Array<Nullable<AbstractMesh>>;
  41561. /** @hidden */
  41562. protected _scene: Nullable<Scene>;
  41563. /** @hidden */
  41564. protected _numMeshes: number;
  41565. /** @hidden */
  41566. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41567. private _renderFunction;
  41568. private _utilityLayer;
  41569. private _debugBoxMesh;
  41570. private _debugSphereMesh;
  41571. private _debugMaterial;
  41572. /**
  41573. * Creates a new PhysicsViewer
  41574. * @param scene defines the hosting scene
  41575. */
  41576. constructor(scene: Scene);
  41577. /** @hidden */
  41578. protected _updateDebugMeshes(): void;
  41579. /**
  41580. * Renders a specified physic impostor
  41581. * @param impostor defines the impostor to render
  41582. * @returns the new debug mesh used to render the impostor
  41583. */
  41584. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41585. /**
  41586. * Hides a specified physic impostor
  41587. * @param impostor defines the impostor to hide
  41588. */
  41589. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41590. private _getDebugMaterial;
  41591. private _getDebugBoxMesh;
  41592. private _getDebugSphereMesh;
  41593. private _getDebugMesh;
  41594. /** Releases all resources */
  41595. dispose(): void;
  41596. }
  41597. }
  41598. declare module "babylonjs/Debug/rayHelper" {
  41599. import { Nullable } from "babylonjs/types";
  41600. import { Ray } from "babylonjs/Culling/ray";
  41601. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41602. import { Scene } from "babylonjs/scene";
  41603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41604. import "babylonjs/Meshes/Builders/linesBuilder";
  41605. /**
  41606. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41607. * in order to better appreciate the issue one might have.
  41608. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41609. */
  41610. export class RayHelper {
  41611. /**
  41612. * Defines the ray we are currently tryin to visualize.
  41613. */
  41614. ray: Nullable<Ray>;
  41615. private _renderPoints;
  41616. private _renderLine;
  41617. private _renderFunction;
  41618. private _scene;
  41619. private _updateToMeshFunction;
  41620. private _attachedToMesh;
  41621. private _meshSpaceDirection;
  41622. private _meshSpaceOrigin;
  41623. /**
  41624. * Helper function to create a colored helper in a scene in one line.
  41625. * @param ray Defines the ray we are currently tryin to visualize
  41626. * @param scene Defines the scene the ray is used in
  41627. * @param color Defines the color we want to see the ray in
  41628. * @returns The newly created ray helper.
  41629. */
  41630. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41631. /**
  41632. * Instantiate a new ray helper.
  41633. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41634. * in order to better appreciate the issue one might have.
  41635. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41636. * @param ray Defines the ray we are currently tryin to visualize
  41637. */
  41638. constructor(ray: Ray);
  41639. /**
  41640. * Shows the ray we are willing to debug.
  41641. * @param scene Defines the scene the ray needs to be rendered in
  41642. * @param color Defines the color the ray needs to be rendered in
  41643. */
  41644. show(scene: Scene, color?: Color3): void;
  41645. /**
  41646. * Hides the ray we are debugging.
  41647. */
  41648. hide(): void;
  41649. private _render;
  41650. /**
  41651. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41652. * @param mesh Defines the mesh we want the helper attached to
  41653. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41654. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41655. * @param length Defines the length of the ray
  41656. */
  41657. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41658. /**
  41659. * Detach the ray helper from the mesh it has previously been attached to.
  41660. */
  41661. detachFromMesh(): void;
  41662. private _updateToMesh;
  41663. /**
  41664. * Dispose the helper and release its associated resources.
  41665. */
  41666. dispose(): void;
  41667. }
  41668. }
  41669. declare module "babylonjs/Debug/skeletonViewer" {
  41670. import { Color3 } from "babylonjs/Maths/math";
  41671. import { Scene } from "babylonjs/scene";
  41672. import { Nullable } from "babylonjs/types";
  41673. import { Skeleton } from "babylonjs/Bones/skeleton";
  41674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41675. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41676. /**
  41677. * Class used to render a debug view of a given skeleton
  41678. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41679. */
  41680. export class SkeletonViewer {
  41681. /** defines the skeleton to render */
  41682. skeleton: Skeleton;
  41683. /** defines the mesh attached to the skeleton */
  41684. mesh: AbstractMesh;
  41685. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41686. autoUpdateBonesMatrices: boolean;
  41687. /** defines the rendering group id to use with the viewer */
  41688. renderingGroupId: number;
  41689. /** Gets or sets the color used to render the skeleton */
  41690. color: Color3;
  41691. private _scene;
  41692. private _debugLines;
  41693. private _debugMesh;
  41694. private _isEnabled;
  41695. private _renderFunction;
  41696. private _utilityLayer;
  41697. /**
  41698. * Returns the mesh used to render the bones
  41699. */
  41700. readonly debugMesh: Nullable<LinesMesh>;
  41701. /**
  41702. * Creates a new SkeletonViewer
  41703. * @param skeleton defines the skeleton to render
  41704. * @param mesh defines the mesh attached to the skeleton
  41705. * @param scene defines the hosting scene
  41706. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41707. * @param renderingGroupId defines the rendering group id to use with the viewer
  41708. */
  41709. constructor(
  41710. /** defines the skeleton to render */
  41711. skeleton: Skeleton,
  41712. /** defines the mesh attached to the skeleton */
  41713. mesh: AbstractMesh, scene: Scene,
  41714. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41715. autoUpdateBonesMatrices?: boolean,
  41716. /** defines the rendering group id to use with the viewer */
  41717. renderingGroupId?: number);
  41718. /** Gets or sets a boolean indicating if the viewer is enabled */
  41719. isEnabled: boolean;
  41720. private _getBonePosition;
  41721. private _getLinesForBonesWithLength;
  41722. private _getLinesForBonesNoLength;
  41723. /** Update the viewer to sync with current skeleton state */
  41724. update(): void;
  41725. /** Release associated resources */
  41726. dispose(): void;
  41727. }
  41728. }
  41729. declare module "babylonjs/Debug/index" {
  41730. export * from "babylonjs/Debug/axesViewer";
  41731. export * from "babylonjs/Debug/boneAxesViewer";
  41732. export * from "babylonjs/Debug/debugLayer";
  41733. export * from "babylonjs/Debug/physicsViewer";
  41734. export * from "babylonjs/Debug/rayHelper";
  41735. export * from "babylonjs/Debug/skeletonViewer";
  41736. }
  41737. declare module "babylonjs/Engines/nullEngine" {
  41738. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41739. import { Scene } from "babylonjs/scene";
  41740. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41741. import { Engine } from "babylonjs/Engines/engine";
  41742. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41743. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41744. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41745. import { Effect } from "babylonjs/Materials/effect";
  41746. /**
  41747. * Options to create the null engine
  41748. */
  41749. export class NullEngineOptions {
  41750. /**
  41751. * Render width (Default: 512)
  41752. */
  41753. renderWidth: number;
  41754. /**
  41755. * Render height (Default: 256)
  41756. */
  41757. renderHeight: number;
  41758. /**
  41759. * Texture size (Default: 512)
  41760. */
  41761. textureSize: number;
  41762. /**
  41763. * If delta time between frames should be constant
  41764. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41765. */
  41766. deterministicLockstep: boolean;
  41767. /**
  41768. * Maximum about of steps between frames (Default: 4)
  41769. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41770. */
  41771. lockstepMaxSteps: number;
  41772. }
  41773. /**
  41774. * The null engine class provides support for headless version of babylon.js.
  41775. * This can be used in server side scenario or for testing purposes
  41776. */
  41777. export class NullEngine extends Engine {
  41778. private _options;
  41779. /**
  41780. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41781. */
  41782. isDeterministicLockStep(): boolean;
  41783. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41784. getLockstepMaxSteps(): number;
  41785. /**
  41786. * Sets hardware scaling, used to save performance if needed
  41787. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41788. */
  41789. getHardwareScalingLevel(): number;
  41790. constructor(options?: NullEngineOptions);
  41791. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41792. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41793. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41794. getRenderWidth(useScreen?: boolean): number;
  41795. getRenderHeight(useScreen?: boolean): number;
  41796. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41797. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41798. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41799. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41800. bindSamplers(effect: Effect): void;
  41801. enableEffect(effect: Effect): void;
  41802. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41803. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41804. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41805. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41806. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41807. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41808. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41809. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41810. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41811. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41812. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41813. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41814. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41815. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41816. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41817. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41818. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41819. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41820. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41821. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41822. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41823. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41824. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41825. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41826. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41827. bindBuffers(vertexBuffers: {
  41828. [key: string]: VertexBuffer;
  41829. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41830. wipeCaches(bruteForce?: boolean): void;
  41831. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41832. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41833. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41834. /** @hidden */
  41835. _createTexture(): WebGLTexture;
  41836. /** @hidden */
  41837. _releaseTexture(texture: InternalTexture): void;
  41838. 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;
  41839. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41840. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41841. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41842. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41843. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41844. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41845. areAllEffectsReady(): boolean;
  41846. /**
  41847. * @hidden
  41848. * Get the current error code of the webGL context
  41849. * @returns the error code
  41850. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41851. */
  41852. getError(): number;
  41853. /** @hidden */
  41854. _getUnpackAlignement(): number;
  41855. /** @hidden */
  41856. _unpackFlipY(value: boolean): void;
  41857. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41858. /**
  41859. * Updates a dynamic vertex buffer.
  41860. * @param vertexBuffer the vertex buffer to update
  41861. * @param data the data used to update the vertex buffer
  41862. * @param byteOffset the byte offset of the data (optional)
  41863. * @param byteLength the byte length of the data (optional)
  41864. */
  41865. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41866. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41867. /** @hidden */
  41868. _bindTexture(channel: number, texture: InternalTexture): void;
  41869. /** @hidden */
  41870. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41871. releaseEffects(): void;
  41872. displayLoadingUI(): void;
  41873. hideLoadingUI(): void;
  41874. /** @hidden */
  41875. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41876. /** @hidden */
  41877. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41878. /** @hidden */
  41879. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41880. /** @hidden */
  41881. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41882. }
  41883. }
  41884. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41885. import { Nullable, int } from "babylonjs/types";
  41886. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41887. /** @hidden */
  41888. export class _OcclusionDataStorage {
  41889. /** @hidden */
  41890. occlusionInternalRetryCounter: number;
  41891. /** @hidden */
  41892. isOcclusionQueryInProgress: boolean;
  41893. /** @hidden */
  41894. isOccluded: boolean;
  41895. /** @hidden */
  41896. occlusionRetryCount: number;
  41897. /** @hidden */
  41898. occlusionType: number;
  41899. /** @hidden */
  41900. occlusionQueryAlgorithmType: number;
  41901. }
  41902. module "babylonjs/Engines/engine" {
  41903. interface Engine {
  41904. /**
  41905. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41906. * @return the new query
  41907. */
  41908. createQuery(): WebGLQuery;
  41909. /**
  41910. * Delete and release a webGL query
  41911. * @param query defines the query to delete
  41912. * @return the current engine
  41913. */
  41914. deleteQuery(query: WebGLQuery): Engine;
  41915. /**
  41916. * Check if a given query has resolved and got its value
  41917. * @param query defines the query to check
  41918. * @returns true if the query got its value
  41919. */
  41920. isQueryResultAvailable(query: WebGLQuery): boolean;
  41921. /**
  41922. * Gets the value of a given query
  41923. * @param query defines the query to check
  41924. * @returns the value of the query
  41925. */
  41926. getQueryResult(query: WebGLQuery): number;
  41927. /**
  41928. * Initiates an occlusion query
  41929. * @param algorithmType defines the algorithm to use
  41930. * @param query defines the query to use
  41931. * @returns the current engine
  41932. * @see http://doc.babylonjs.com/features/occlusionquery
  41933. */
  41934. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41935. /**
  41936. * Ends an occlusion query
  41937. * @see http://doc.babylonjs.com/features/occlusionquery
  41938. * @param algorithmType defines the algorithm to use
  41939. * @returns the current engine
  41940. */
  41941. endOcclusionQuery(algorithmType: number): Engine;
  41942. /**
  41943. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41944. * Please note that only one query can be issued at a time
  41945. * @returns a time token used to track the time span
  41946. */
  41947. startTimeQuery(): Nullable<_TimeToken>;
  41948. /**
  41949. * Ends a time query
  41950. * @param token defines the token used to measure the time span
  41951. * @returns the time spent (in ns)
  41952. */
  41953. endTimeQuery(token: _TimeToken): int;
  41954. /** @hidden */
  41955. _currentNonTimestampToken: Nullable<_TimeToken>;
  41956. /** @hidden */
  41957. _createTimeQuery(): WebGLQuery;
  41958. /** @hidden */
  41959. _deleteTimeQuery(query: WebGLQuery): void;
  41960. /** @hidden */
  41961. _getGlAlgorithmType(algorithmType: number): number;
  41962. /** @hidden */
  41963. _getTimeQueryResult(query: WebGLQuery): any;
  41964. /** @hidden */
  41965. _getTimeQueryAvailability(query: WebGLQuery): any;
  41966. }
  41967. }
  41968. module "babylonjs/Meshes/abstractMesh" {
  41969. interface AbstractMesh {
  41970. /**
  41971. * Backing filed
  41972. * @hidden
  41973. */
  41974. __occlusionDataStorage: _OcclusionDataStorage;
  41975. /**
  41976. * Access property
  41977. * @hidden
  41978. */
  41979. _occlusionDataStorage: _OcclusionDataStorage;
  41980. /**
  41981. * 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.
  41982. * The default value is -1 which means don't break the query and wait till the result
  41983. * @see http://doc.babylonjs.com/features/occlusionquery
  41984. */
  41985. occlusionRetryCount: number;
  41986. /**
  41987. * 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:
  41988. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41989. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41990. * * 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.
  41991. * @see http://doc.babylonjs.com/features/occlusionquery
  41992. */
  41993. occlusionType: number;
  41994. /**
  41995. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41996. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41997. * * 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.
  41998. * @see http://doc.babylonjs.com/features/occlusionquery
  41999. */
  42000. occlusionQueryAlgorithmType: number;
  42001. /**
  42002. * 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
  42003. * @see http://doc.babylonjs.com/features/occlusionquery
  42004. */
  42005. isOccluded: boolean;
  42006. /**
  42007. * Flag to check the progress status of the query
  42008. * @see http://doc.babylonjs.com/features/occlusionquery
  42009. */
  42010. isOcclusionQueryInProgress: boolean;
  42011. }
  42012. }
  42013. }
  42014. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42015. import { Nullable } from "babylonjs/types";
  42016. /** @hidden */
  42017. export var _forceTransformFeedbackToBundle: boolean;
  42018. module "babylonjs/Engines/engine" {
  42019. interface Engine {
  42020. /**
  42021. * Creates a webGL transform feedback object
  42022. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42023. * @returns the webGL transform feedback object
  42024. */
  42025. createTransformFeedback(): WebGLTransformFeedback;
  42026. /**
  42027. * Delete a webGL transform feedback object
  42028. * @param value defines the webGL transform feedback object to delete
  42029. */
  42030. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42031. /**
  42032. * Bind a webGL transform feedback object to the webgl context
  42033. * @param value defines the webGL transform feedback object to bind
  42034. */
  42035. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42036. /**
  42037. * Begins a transform feedback operation
  42038. * @param usePoints defines if points or triangles must be used
  42039. */
  42040. beginTransformFeedback(usePoints: boolean): void;
  42041. /**
  42042. * Ends a transform feedback operation
  42043. */
  42044. endTransformFeedback(): void;
  42045. /**
  42046. * Specify the varyings to use with transform feedback
  42047. * @param program defines the associated webGL program
  42048. * @param value defines the list of strings representing the varying names
  42049. */
  42050. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42051. /**
  42052. * Bind a webGL buffer for a transform feedback operation
  42053. * @param value defines the webGL buffer to bind
  42054. */
  42055. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42056. }
  42057. }
  42058. }
  42059. declare module "babylonjs/Engines/Extensions/index" {
  42060. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42061. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42062. }
  42063. declare module "babylonjs/Engines/index" {
  42064. export * from "babylonjs/Engines/constants";
  42065. export * from "babylonjs/Engines/engine";
  42066. export * from "babylonjs/Engines/engineStore";
  42067. export * from "babylonjs/Engines/nullEngine";
  42068. export * from "babylonjs/Engines/Extensions/index";
  42069. }
  42070. declare module "babylonjs/Events/clipboardEvents" {
  42071. /**
  42072. * Gather the list of clipboard event types as constants.
  42073. */
  42074. export class ClipboardEventTypes {
  42075. /**
  42076. * The clipboard event is fired when a copy command is active (pressed).
  42077. */
  42078. static readonly COPY: number;
  42079. /**
  42080. * The clipboard event is fired when a cut command is active (pressed).
  42081. */
  42082. static readonly CUT: number;
  42083. /**
  42084. * The clipboard event is fired when a paste command is active (pressed).
  42085. */
  42086. static readonly PASTE: number;
  42087. }
  42088. /**
  42089. * This class is used to store clipboard related info for the onClipboardObservable event.
  42090. */
  42091. export class ClipboardInfo {
  42092. /**
  42093. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42094. */
  42095. type: number;
  42096. /**
  42097. * Defines the related dom event
  42098. */
  42099. event: ClipboardEvent;
  42100. /**
  42101. *Creates an instance of ClipboardInfo.
  42102. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42103. * @param event Defines the related dom event
  42104. */
  42105. constructor(
  42106. /**
  42107. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42108. */
  42109. type: number,
  42110. /**
  42111. * Defines the related dom event
  42112. */
  42113. event: ClipboardEvent);
  42114. /**
  42115. * Get the clipboard event's type from the keycode.
  42116. * @param keyCode Defines the keyCode for the current keyboard event.
  42117. * @return {number}
  42118. */
  42119. static GetTypeFromCharacter(keyCode: number): number;
  42120. }
  42121. }
  42122. declare module "babylonjs/Events/index" {
  42123. export * from "babylonjs/Events/keyboardEvents";
  42124. export * from "babylonjs/Events/pointerEvents";
  42125. export * from "babylonjs/Events/clipboardEvents";
  42126. }
  42127. declare module "babylonjs/Loading/sceneLoader" {
  42128. import { Observable } from "babylonjs/Misc/observable";
  42129. import { Nullable } from "babylonjs/types";
  42130. import { Scene } from "babylonjs/scene";
  42131. import { Engine } from "babylonjs/Engines/engine";
  42132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42133. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42134. import { AssetContainer } from "babylonjs/assetContainer";
  42135. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42136. import { Skeleton } from "babylonjs/Bones/skeleton";
  42137. /**
  42138. * Class used to represent data loading progression
  42139. */
  42140. export class SceneLoaderProgressEvent {
  42141. /** defines if data length to load can be evaluated */
  42142. readonly lengthComputable: boolean;
  42143. /** defines the loaded data length */
  42144. readonly loaded: number;
  42145. /** defines the data length to load */
  42146. readonly total: number;
  42147. /**
  42148. * Create a new progress event
  42149. * @param lengthComputable defines if data length to load can be evaluated
  42150. * @param loaded defines the loaded data length
  42151. * @param total defines the data length to load
  42152. */
  42153. constructor(
  42154. /** defines if data length to load can be evaluated */
  42155. lengthComputable: boolean,
  42156. /** defines the loaded data length */
  42157. loaded: number,
  42158. /** defines the data length to load */
  42159. total: number);
  42160. /**
  42161. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42162. * @param event defines the source event
  42163. * @returns a new SceneLoaderProgressEvent
  42164. */
  42165. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42166. }
  42167. /**
  42168. * Interface used by SceneLoader plugins to define supported file extensions
  42169. */
  42170. export interface ISceneLoaderPluginExtensions {
  42171. /**
  42172. * Defines the list of supported extensions
  42173. */
  42174. [extension: string]: {
  42175. isBinary: boolean;
  42176. };
  42177. }
  42178. /**
  42179. * Interface used by SceneLoader plugin factory
  42180. */
  42181. export interface ISceneLoaderPluginFactory {
  42182. /**
  42183. * Defines the name of the factory
  42184. */
  42185. name: string;
  42186. /**
  42187. * Function called to create a new plugin
  42188. * @return the new plugin
  42189. */
  42190. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42191. /**
  42192. * Boolean indicating if the plugin can direct load specific data
  42193. */
  42194. canDirectLoad?: (data: string) => boolean;
  42195. }
  42196. /**
  42197. * Interface used to define a SceneLoader plugin
  42198. */
  42199. export interface ISceneLoaderPlugin {
  42200. /**
  42201. * The friendly name of this plugin.
  42202. */
  42203. name: string;
  42204. /**
  42205. * The file extensions supported by this plugin.
  42206. */
  42207. extensions: string | ISceneLoaderPluginExtensions;
  42208. /**
  42209. * Import meshes into a scene.
  42210. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42211. * @param scene The scene to import into
  42212. * @param data The data to import
  42213. * @param rootUrl The root url for scene and resources
  42214. * @param meshes The meshes array to import into
  42215. * @param particleSystems The particle systems array to import into
  42216. * @param skeletons The skeletons array to import into
  42217. * @param onError The callback when import fails
  42218. * @returns True if successful or false otherwise
  42219. */
  42220. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42221. /**
  42222. * Load into a scene.
  42223. * @param scene The scene to load into
  42224. * @param data The data to import
  42225. * @param rootUrl The root url for scene and resources
  42226. * @param onError The callback when import fails
  42227. * @returns true if successful or false otherwise
  42228. */
  42229. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42230. /**
  42231. * The callback that returns true if the data can be directly loaded.
  42232. */
  42233. canDirectLoad?: (data: string) => boolean;
  42234. /**
  42235. * The callback that allows custom handling of the root url based on the response url.
  42236. */
  42237. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42238. /**
  42239. * Load into an asset container.
  42240. * @param scene The scene to load into
  42241. * @param data The data to import
  42242. * @param rootUrl The root url for scene and resources
  42243. * @param onError The callback when import fails
  42244. * @returns The loaded asset container
  42245. */
  42246. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42247. }
  42248. /**
  42249. * Interface used to define an async SceneLoader plugin
  42250. */
  42251. export interface ISceneLoaderPluginAsync {
  42252. /**
  42253. * The friendly name of this plugin.
  42254. */
  42255. name: string;
  42256. /**
  42257. * The file extensions supported by this plugin.
  42258. */
  42259. extensions: string | ISceneLoaderPluginExtensions;
  42260. /**
  42261. * Import meshes into a scene.
  42262. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42263. * @param scene The scene to import into
  42264. * @param data The data to import
  42265. * @param rootUrl The root url for scene and resources
  42266. * @param onProgress The callback when the load progresses
  42267. * @param fileName Defines the name of the file to load
  42268. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42269. */
  42270. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42271. meshes: AbstractMesh[];
  42272. particleSystems: IParticleSystem[];
  42273. skeletons: Skeleton[];
  42274. animationGroups: AnimationGroup[];
  42275. }>;
  42276. /**
  42277. * Load into a scene.
  42278. * @param scene The scene to load into
  42279. * @param data The data to import
  42280. * @param rootUrl The root url for scene and resources
  42281. * @param onProgress The callback when the load progresses
  42282. * @param fileName Defines the name of the file to load
  42283. * @returns Nothing
  42284. */
  42285. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42286. /**
  42287. * The callback that returns true if the data can be directly loaded.
  42288. */
  42289. canDirectLoad?: (data: string) => boolean;
  42290. /**
  42291. * The callback that allows custom handling of the root url based on the response url.
  42292. */
  42293. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42294. /**
  42295. * Load into an asset container.
  42296. * @param scene The scene to load into
  42297. * @param data The data to import
  42298. * @param rootUrl The root url for scene and resources
  42299. * @param onProgress The callback when the load progresses
  42300. * @param fileName Defines the name of the file to load
  42301. * @returns The loaded asset container
  42302. */
  42303. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42304. }
  42305. /**
  42306. * Class used to load scene from various file formats using registered plugins
  42307. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42308. */
  42309. export class SceneLoader {
  42310. /**
  42311. * No logging while loading
  42312. */
  42313. static readonly NO_LOGGING: number;
  42314. /**
  42315. * Minimal logging while loading
  42316. */
  42317. static readonly MINIMAL_LOGGING: number;
  42318. /**
  42319. * Summary logging while loading
  42320. */
  42321. static readonly SUMMARY_LOGGING: number;
  42322. /**
  42323. * Detailled logging while loading
  42324. */
  42325. static readonly DETAILED_LOGGING: number;
  42326. /**
  42327. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42328. */
  42329. static ForceFullSceneLoadingForIncremental: boolean;
  42330. /**
  42331. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42332. */
  42333. static ShowLoadingScreen: boolean;
  42334. /**
  42335. * Defines the current logging level (while loading the scene)
  42336. * @ignorenaming
  42337. */
  42338. static loggingLevel: number;
  42339. /**
  42340. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42341. */
  42342. static CleanBoneMatrixWeights: boolean;
  42343. /**
  42344. * Event raised when a plugin is used to load a scene
  42345. */
  42346. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42347. private static _registeredPlugins;
  42348. private static _getDefaultPlugin;
  42349. private static _getPluginForExtension;
  42350. private static _getPluginForDirectLoad;
  42351. private static _getPluginForFilename;
  42352. private static _getDirectLoad;
  42353. private static _loadData;
  42354. private static _getFileInfo;
  42355. /**
  42356. * Gets a plugin that can load the given extension
  42357. * @param extension defines the extension to load
  42358. * @returns a plugin or null if none works
  42359. */
  42360. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42361. /**
  42362. * Gets a boolean indicating that the given extension can be loaded
  42363. * @param extension defines the extension to load
  42364. * @returns true if the extension is supported
  42365. */
  42366. static IsPluginForExtensionAvailable(extension: string): boolean;
  42367. /**
  42368. * Adds a new plugin to the list of registered plugins
  42369. * @param plugin defines the plugin to add
  42370. */
  42371. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42372. /**
  42373. * Import meshes into a scene
  42374. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42375. * @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)
  42376. * @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)
  42377. * @param scene the instance of BABYLON.Scene to append to
  42378. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42379. * @param onProgress a callback with a progress event for each file being loaded
  42380. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42381. * @param pluginExtension the extension used to determine the plugin
  42382. * @returns The loaded plugin
  42383. */
  42384. 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>;
  42385. /**
  42386. * Import meshes into a scene
  42387. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42388. * @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)
  42389. * @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)
  42390. * @param scene the instance of BABYLON.Scene to append to
  42391. * @param onProgress a callback with a progress event for each file being loaded
  42392. * @param pluginExtension the extension used to determine the plugin
  42393. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42394. */
  42395. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42396. meshes: AbstractMesh[];
  42397. particleSystems: IParticleSystem[];
  42398. skeletons: Skeleton[];
  42399. animationGroups: AnimationGroup[];
  42400. }>;
  42401. /**
  42402. * Load a scene
  42403. * @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)
  42404. * @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)
  42405. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42406. * @param onSuccess a callback with the scene when import succeeds
  42407. * @param onProgress a callback with a progress event for each file being loaded
  42408. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42409. * @param pluginExtension the extension used to determine the plugin
  42410. * @returns The loaded plugin
  42411. */
  42412. 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>;
  42413. /**
  42414. * Load a scene
  42415. * @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)
  42416. * @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)
  42417. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42418. * @param onProgress a callback with a progress event for each file being loaded
  42419. * @param pluginExtension the extension used to determine the plugin
  42420. * @returns The loaded scene
  42421. */
  42422. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42423. /**
  42424. * Append a scene
  42425. * @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)
  42426. * @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)
  42427. * @param scene is the instance of BABYLON.Scene to append to
  42428. * @param onSuccess a callback with the scene when import succeeds
  42429. * @param onProgress a callback with a progress event for each file being loaded
  42430. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42431. * @param pluginExtension the extension used to determine the plugin
  42432. * @returns The loaded plugin
  42433. */
  42434. 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>;
  42435. /**
  42436. * Append a scene
  42437. * @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)
  42438. * @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)
  42439. * @param scene is the instance of BABYLON.Scene to append to
  42440. * @param onProgress a callback with a progress event for each file being loaded
  42441. * @param pluginExtension the extension used to determine the plugin
  42442. * @returns The given scene
  42443. */
  42444. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42445. /**
  42446. * Load a scene into an asset container
  42447. * @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)
  42448. * @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)
  42449. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42450. * @param onSuccess a callback with the scene when import succeeds
  42451. * @param onProgress a callback with a progress event for each file being loaded
  42452. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42453. * @param pluginExtension the extension used to determine the plugin
  42454. * @returns The loaded plugin
  42455. */
  42456. 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>;
  42457. /**
  42458. * Load a scene into an asset container
  42459. * @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)
  42460. * @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)
  42461. * @param scene is the instance of Scene to append to
  42462. * @param onProgress a callback with a progress event for each file being loaded
  42463. * @param pluginExtension the extension used to determine the plugin
  42464. * @returns The loaded asset container
  42465. */
  42466. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42467. }
  42468. }
  42469. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42470. import { Scene } from "babylonjs/scene";
  42471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42472. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42473. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42474. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42475. /**
  42476. * Google Daydream controller
  42477. */
  42478. export class DaydreamController extends WebVRController {
  42479. /**
  42480. * Base Url for the controller model.
  42481. */
  42482. static MODEL_BASE_URL: string;
  42483. /**
  42484. * File name for the controller model.
  42485. */
  42486. static MODEL_FILENAME: string;
  42487. /**
  42488. * Gamepad Id prefix used to identify Daydream Controller.
  42489. */
  42490. static readonly GAMEPAD_ID_PREFIX: string;
  42491. /**
  42492. * Creates a new DaydreamController from a gamepad
  42493. * @param vrGamepad the gamepad that the controller should be created from
  42494. */
  42495. constructor(vrGamepad: any);
  42496. /**
  42497. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42498. * @param scene scene in which to add meshes
  42499. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42500. */
  42501. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42502. /**
  42503. * Called once for each button that changed state since the last frame
  42504. * @param buttonIdx Which button index changed
  42505. * @param state New state of the button
  42506. * @param changes Which properties on the state changed since last frame
  42507. */
  42508. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42509. }
  42510. }
  42511. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42512. import { Scene } from "babylonjs/scene";
  42513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42514. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42515. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42516. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42517. /**
  42518. * Gear VR Controller
  42519. */
  42520. export class GearVRController extends WebVRController {
  42521. /**
  42522. * Base Url for the controller model.
  42523. */
  42524. static MODEL_BASE_URL: string;
  42525. /**
  42526. * File name for the controller model.
  42527. */
  42528. static MODEL_FILENAME: string;
  42529. /**
  42530. * Gamepad Id prefix used to identify this controller.
  42531. */
  42532. static readonly GAMEPAD_ID_PREFIX: string;
  42533. private readonly _buttonIndexToObservableNameMap;
  42534. /**
  42535. * Creates a new GearVRController from a gamepad
  42536. * @param vrGamepad the gamepad that the controller should be created from
  42537. */
  42538. constructor(vrGamepad: any);
  42539. /**
  42540. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42541. * @param scene scene in which to add meshes
  42542. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42543. */
  42544. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42545. /**
  42546. * Called once for each button that changed state since the last frame
  42547. * @param buttonIdx Which button index changed
  42548. * @param state New state of the button
  42549. * @param changes Which properties on the state changed since last frame
  42550. */
  42551. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42552. }
  42553. }
  42554. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42555. import { Scene } from "babylonjs/scene";
  42556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42557. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42558. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42559. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42560. /**
  42561. * Generic Controller
  42562. */
  42563. export class GenericController extends WebVRController {
  42564. /**
  42565. * Base Url for the controller model.
  42566. */
  42567. static readonly MODEL_BASE_URL: string;
  42568. /**
  42569. * File name for the controller model.
  42570. */
  42571. static readonly MODEL_FILENAME: string;
  42572. /**
  42573. * Creates a new GenericController from a gamepad
  42574. * @param vrGamepad the gamepad that the controller should be created from
  42575. */
  42576. constructor(vrGamepad: any);
  42577. /**
  42578. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42579. * @param scene scene in which to add meshes
  42580. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42581. */
  42582. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42583. /**
  42584. * Called once for each button that changed state since the last frame
  42585. * @param buttonIdx Which button index changed
  42586. * @param state New state of the button
  42587. * @param changes Which properties on the state changed since last frame
  42588. */
  42589. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42590. }
  42591. }
  42592. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42593. import { Observable } from "babylonjs/Misc/observable";
  42594. import { Scene } from "babylonjs/scene";
  42595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42596. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42597. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42598. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42599. /**
  42600. * Oculus Touch Controller
  42601. */
  42602. export class OculusTouchController extends WebVRController {
  42603. /**
  42604. * Base Url for the controller model.
  42605. */
  42606. static MODEL_BASE_URL: string;
  42607. /**
  42608. * File name for the left controller model.
  42609. */
  42610. static MODEL_LEFT_FILENAME: string;
  42611. /**
  42612. * File name for the right controller model.
  42613. */
  42614. static MODEL_RIGHT_FILENAME: string;
  42615. /**
  42616. * Fired when the secondary trigger on this controller is modified
  42617. */
  42618. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42619. /**
  42620. * Fired when the thumb rest on this controller is modified
  42621. */
  42622. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42623. /**
  42624. * Creates a new OculusTouchController from a gamepad
  42625. * @param vrGamepad the gamepad that the controller should be created from
  42626. */
  42627. constructor(vrGamepad: any);
  42628. /**
  42629. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42630. * @param scene scene in which to add meshes
  42631. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42632. */
  42633. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42634. /**
  42635. * Fired when the A button on this controller is modified
  42636. */
  42637. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42638. /**
  42639. * Fired when the B button on this controller is modified
  42640. */
  42641. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42642. /**
  42643. * Fired when the X button on this controller is modified
  42644. */
  42645. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42646. /**
  42647. * Fired when the Y button on this controller is modified
  42648. */
  42649. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42650. /**
  42651. * Called once for each button that changed state since the last frame
  42652. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42653. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42654. * 2) secondary trigger (same)
  42655. * 3) A (right) X (left), touch, pressed = value
  42656. * 4) B / Y
  42657. * 5) thumb rest
  42658. * @param buttonIdx Which button index changed
  42659. * @param state New state of the button
  42660. * @param changes Which properties on the state changed since last frame
  42661. */
  42662. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42663. }
  42664. }
  42665. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42666. import { Scene } from "babylonjs/scene";
  42667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42668. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42669. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42670. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42671. import { Observable } from "babylonjs/Misc/observable";
  42672. /**
  42673. * Vive Controller
  42674. */
  42675. export class ViveController extends WebVRController {
  42676. /**
  42677. * Base Url for the controller model.
  42678. */
  42679. static MODEL_BASE_URL: string;
  42680. /**
  42681. * File name for the controller model.
  42682. */
  42683. static MODEL_FILENAME: string;
  42684. /**
  42685. * Creates a new ViveController from a gamepad
  42686. * @param vrGamepad the gamepad that the controller should be created from
  42687. */
  42688. constructor(vrGamepad: any);
  42689. /**
  42690. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42691. * @param scene scene in which to add meshes
  42692. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42693. */
  42694. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42695. /**
  42696. * Fired when the left button on this controller is modified
  42697. */
  42698. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42699. /**
  42700. * Fired when the right button on this controller is modified
  42701. */
  42702. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42703. /**
  42704. * Fired when the menu button on this controller is modified
  42705. */
  42706. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42707. /**
  42708. * Called once for each button that changed state since the last frame
  42709. * Vive mapping:
  42710. * 0: touchpad
  42711. * 1: trigger
  42712. * 2: left AND right buttons
  42713. * 3: menu button
  42714. * @param buttonIdx Which button index changed
  42715. * @param state New state of the button
  42716. * @param changes Which properties on the state changed since last frame
  42717. */
  42718. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42719. }
  42720. }
  42721. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42722. import { Observable } from "babylonjs/Misc/observable";
  42723. import { Scene } from "babylonjs/scene";
  42724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42725. import { Ray } from "babylonjs/Culling/ray";
  42726. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42727. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42728. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42729. /**
  42730. * Defines the WindowsMotionController object that the state of the windows motion controller
  42731. */
  42732. export class WindowsMotionController extends WebVRController {
  42733. /**
  42734. * The base url used to load the left and right controller models
  42735. */
  42736. static MODEL_BASE_URL: string;
  42737. /**
  42738. * The name of the left controller model file
  42739. */
  42740. static MODEL_LEFT_FILENAME: string;
  42741. /**
  42742. * The name of the right controller model file
  42743. */
  42744. static MODEL_RIGHT_FILENAME: string;
  42745. /**
  42746. * The controller name prefix for this controller type
  42747. */
  42748. static readonly GAMEPAD_ID_PREFIX: string;
  42749. /**
  42750. * The controller id pattern for this controller type
  42751. */
  42752. private static readonly GAMEPAD_ID_PATTERN;
  42753. private _loadedMeshInfo;
  42754. private readonly _mapping;
  42755. /**
  42756. * Fired when the trackpad on this controller is clicked
  42757. */
  42758. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42759. /**
  42760. * Fired when the trackpad on this controller is modified
  42761. */
  42762. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42763. /**
  42764. * The current x and y values of this controller's trackpad
  42765. */
  42766. trackpad: StickValues;
  42767. /**
  42768. * Creates a new WindowsMotionController from a gamepad
  42769. * @param vrGamepad the gamepad that the controller should be created from
  42770. */
  42771. constructor(vrGamepad: any);
  42772. /**
  42773. * Fired when the trigger on this controller is modified
  42774. */
  42775. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42776. /**
  42777. * Fired when the menu button on this controller is modified
  42778. */
  42779. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42780. /**
  42781. * Fired when the grip button on this controller is modified
  42782. */
  42783. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42784. /**
  42785. * Fired when the thumbstick button on this controller is modified
  42786. */
  42787. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42788. /**
  42789. * Fired when the touchpad button on this controller is modified
  42790. */
  42791. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42792. /**
  42793. * Fired when the touchpad values on this controller are modified
  42794. */
  42795. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42796. private _updateTrackpad;
  42797. /**
  42798. * Called once per frame by the engine.
  42799. */
  42800. update(): void;
  42801. /**
  42802. * Called once for each button that changed state since the last frame
  42803. * @param buttonIdx Which button index changed
  42804. * @param state New state of the button
  42805. * @param changes Which properties on the state changed since last frame
  42806. */
  42807. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42808. /**
  42809. * Moves the buttons on the controller mesh based on their current state
  42810. * @param buttonName the name of the button to move
  42811. * @param buttonValue the value of the button which determines the buttons new position
  42812. */
  42813. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42814. /**
  42815. * Moves the axis on the controller mesh based on its current state
  42816. * @param axis the index of the axis
  42817. * @param axisValue the value of the axis which determines the meshes new position
  42818. * @hidden
  42819. */
  42820. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42821. /**
  42822. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42823. * @param scene scene in which to add meshes
  42824. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42825. */
  42826. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42827. /**
  42828. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42829. * can be transformed by button presses and axes values, based on this._mapping.
  42830. *
  42831. * @param scene scene in which the meshes exist
  42832. * @param meshes list of meshes that make up the controller model to process
  42833. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42834. */
  42835. private processModel;
  42836. private createMeshInfo;
  42837. /**
  42838. * Gets the ray of the controller in the direction the controller is pointing
  42839. * @param length the length the resulting ray should be
  42840. * @returns a ray in the direction the controller is pointing
  42841. */
  42842. getForwardRay(length?: number): Ray;
  42843. /**
  42844. * Disposes of the controller
  42845. */
  42846. dispose(): void;
  42847. }
  42848. }
  42849. declare module "babylonjs/Gamepads/Controllers/index" {
  42850. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42851. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42852. export * from "babylonjs/Gamepads/Controllers/genericController";
  42853. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42854. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42855. export * from "babylonjs/Gamepads/Controllers/viveController";
  42856. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42857. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42858. }
  42859. declare module "babylonjs/Gamepads/index" {
  42860. export * from "babylonjs/Gamepads/Controllers/index";
  42861. export * from "babylonjs/Gamepads/gamepad";
  42862. export * from "babylonjs/Gamepads/gamepadManager";
  42863. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42864. export * from "babylonjs/Gamepads/xboxGamepad";
  42865. }
  42866. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42867. import { Observable } from "babylonjs/Misc/observable";
  42868. import { Nullable } from "babylonjs/types";
  42869. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42871. import { Mesh } from "babylonjs/Meshes/mesh";
  42872. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42873. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42874. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42875. /**
  42876. * Single axis scale gizmo
  42877. */
  42878. export class AxisScaleGizmo extends Gizmo {
  42879. private _coloredMaterial;
  42880. /**
  42881. * Drag behavior responsible for the gizmos dragging interactions
  42882. */
  42883. dragBehavior: PointerDragBehavior;
  42884. private _pointerObserver;
  42885. /**
  42886. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42887. */
  42888. snapDistance: number;
  42889. /**
  42890. * Event that fires each time the gizmo snaps to a new location.
  42891. * * snapDistance is the the change in distance
  42892. */
  42893. onSnapObservable: Observable<{
  42894. snapDistance: number;
  42895. }>;
  42896. /**
  42897. * If the scaling operation should be done on all axis (default: false)
  42898. */
  42899. uniformScaling: boolean;
  42900. /**
  42901. * Creates an AxisScaleGizmo
  42902. * @param gizmoLayer The utility layer the gizmo will be added to
  42903. * @param dragAxis The axis which the gizmo will be able to scale on
  42904. * @param color The color of the gizmo
  42905. */
  42906. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42907. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42908. /**
  42909. * Disposes of the gizmo
  42910. */
  42911. dispose(): void;
  42912. /**
  42913. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42914. * @param mesh The mesh to replace the default mesh of the gizmo
  42915. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42916. */
  42917. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42918. }
  42919. }
  42920. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  42921. import { Observable } from "babylonjs/Misc/observable";
  42922. import { Nullable } from "babylonjs/types";
  42923. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42925. import { Mesh } from "babylonjs/Meshes/mesh";
  42926. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42927. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42928. import "babylonjs/Meshes/Builders/boxBuilder";
  42929. /**
  42930. * Bounding box gizmo
  42931. */
  42932. export class BoundingBoxGizmo extends Gizmo {
  42933. private _lineBoundingBox;
  42934. private _rotateSpheresParent;
  42935. private _scaleBoxesParent;
  42936. private _boundingDimensions;
  42937. private _renderObserver;
  42938. private _pointerObserver;
  42939. private _scaleDragSpeed;
  42940. private _tmpQuaternion;
  42941. private _tmpVector;
  42942. private _tmpRotationMatrix;
  42943. /**
  42944. * 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)
  42945. */
  42946. ignoreChildren: boolean;
  42947. /**
  42948. * 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)
  42949. */
  42950. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42951. /**
  42952. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42953. */
  42954. rotationSphereSize: number;
  42955. /**
  42956. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42957. */
  42958. scaleBoxSize: number;
  42959. /**
  42960. * 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)
  42961. */
  42962. fixedDragMeshScreenSize: boolean;
  42963. /**
  42964. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42965. */
  42966. fixedDragMeshScreenSizeDistanceFactor: number;
  42967. /**
  42968. * Fired when a rotation sphere or scale box is dragged
  42969. */
  42970. onDragStartObservable: Observable<{}>;
  42971. /**
  42972. * Fired when a scale box is dragged
  42973. */
  42974. onScaleBoxDragObservable: Observable<{}>;
  42975. /**
  42976. * Fired when a scale box drag is ended
  42977. */
  42978. onScaleBoxDragEndObservable: Observable<{}>;
  42979. /**
  42980. * Fired when a rotation sphere is dragged
  42981. */
  42982. onRotationSphereDragObservable: Observable<{}>;
  42983. /**
  42984. * Fired when a rotation sphere drag is ended
  42985. */
  42986. onRotationSphereDragEndObservable: Observable<{}>;
  42987. /**
  42988. * 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)
  42989. */
  42990. scalePivot: Nullable<Vector3>;
  42991. private _anchorMesh;
  42992. private _existingMeshScale;
  42993. private _dragMesh;
  42994. private pointerDragBehavior;
  42995. private coloredMaterial;
  42996. private hoverColoredMaterial;
  42997. /**
  42998. * Sets the color of the bounding box gizmo
  42999. * @param color the color to set
  43000. */
  43001. setColor(color: Color3): void;
  43002. /**
  43003. * Creates an BoundingBoxGizmo
  43004. * @param gizmoLayer The utility layer the gizmo will be added to
  43005. * @param color The color of the gizmo
  43006. */
  43007. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43008. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43009. private _selectNode;
  43010. /**
  43011. * Updates the bounding box information for the Gizmo
  43012. */
  43013. updateBoundingBox(): void;
  43014. private _updateRotationSpheres;
  43015. private _updateScaleBoxes;
  43016. /**
  43017. * Enables rotation on the specified axis and disables rotation on the others
  43018. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43019. */
  43020. setEnabledRotationAxis(axis: string): void;
  43021. /**
  43022. * Enables/disables scaling
  43023. * @param enable if scaling should be enabled
  43024. */
  43025. setEnabledScaling(enable: boolean): void;
  43026. private _updateDummy;
  43027. /**
  43028. * Enables a pointer drag behavior on the bounding box of the gizmo
  43029. */
  43030. enableDragBehavior(): void;
  43031. /**
  43032. * Disposes of the gizmo
  43033. */
  43034. dispose(): void;
  43035. /**
  43036. * 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)
  43037. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43038. * @returns the bounding box mesh with the passed in mesh as a child
  43039. */
  43040. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43041. /**
  43042. * CustomMeshes are not supported by this gizmo
  43043. * @param mesh The mesh to replace the default mesh of the gizmo
  43044. */
  43045. setCustomMesh(mesh: Mesh): void;
  43046. }
  43047. }
  43048. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43049. import { Observable } from "babylonjs/Misc/observable";
  43050. import { Nullable } from "babylonjs/types";
  43051. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43053. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43054. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43055. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43056. import "babylonjs/Meshes/Builders/linesBuilder";
  43057. /**
  43058. * Single plane rotation gizmo
  43059. */
  43060. export class PlaneRotationGizmo extends Gizmo {
  43061. /**
  43062. * Drag behavior responsible for the gizmos dragging interactions
  43063. */
  43064. dragBehavior: PointerDragBehavior;
  43065. private _pointerObserver;
  43066. /**
  43067. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43068. */
  43069. snapDistance: number;
  43070. /**
  43071. * Event that fires each time the gizmo snaps to a new location.
  43072. * * snapDistance is the the change in distance
  43073. */
  43074. onSnapObservable: Observable<{
  43075. snapDistance: number;
  43076. }>;
  43077. /**
  43078. * Creates a PlaneRotationGizmo
  43079. * @param gizmoLayer The utility layer the gizmo will be added to
  43080. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43081. * @param color The color of the gizmo
  43082. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43083. */
  43084. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43085. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43086. /**
  43087. * Disposes of the gizmo
  43088. */
  43089. dispose(): void;
  43090. }
  43091. }
  43092. declare module "babylonjs/Gizmos/rotationGizmo" {
  43093. import { Observable } from "babylonjs/Misc/observable";
  43094. import { Nullable } from "babylonjs/types";
  43095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43096. import { Mesh } from "babylonjs/Meshes/mesh";
  43097. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43098. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43099. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43100. /**
  43101. * Gizmo that enables rotating a mesh along 3 axis
  43102. */
  43103. export class RotationGizmo extends Gizmo {
  43104. /**
  43105. * Internal gizmo used for interactions on the x axis
  43106. */
  43107. xGizmo: PlaneRotationGizmo;
  43108. /**
  43109. * Internal gizmo used for interactions on the y axis
  43110. */
  43111. yGizmo: PlaneRotationGizmo;
  43112. /**
  43113. * Internal gizmo used for interactions on the z axis
  43114. */
  43115. zGizmo: PlaneRotationGizmo;
  43116. /** Fires an event when any of it's sub gizmos are dragged */
  43117. onDragStartObservable: Observable<{}>;
  43118. /** Fires an event when any of it's sub gizmos are released from dragging */
  43119. onDragEndObservable: Observable<{}>;
  43120. attachedMesh: Nullable<AbstractMesh>;
  43121. /**
  43122. * Creates a RotationGizmo
  43123. * @param gizmoLayer The utility layer the gizmo will be added to
  43124. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43125. */
  43126. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43127. updateGizmoRotationToMatchAttachedMesh: boolean;
  43128. /**
  43129. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43130. */
  43131. snapDistance: number;
  43132. /**
  43133. * Ratio for the scale of the gizmo (Default: 1)
  43134. */
  43135. scaleRatio: number;
  43136. /**
  43137. * Disposes of the gizmo
  43138. */
  43139. dispose(): void;
  43140. /**
  43141. * CustomMeshes are not supported by this gizmo
  43142. * @param mesh The mesh to replace the default mesh of the gizmo
  43143. */
  43144. setCustomMesh(mesh: Mesh): void;
  43145. }
  43146. }
  43147. declare module "babylonjs/Gizmos/positionGizmo" {
  43148. import { Observable } from "babylonjs/Misc/observable";
  43149. import { Nullable } from "babylonjs/types";
  43150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43151. import { Mesh } from "babylonjs/Meshes/mesh";
  43152. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43153. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43154. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43155. /**
  43156. * Gizmo that enables dragging a mesh along 3 axis
  43157. */
  43158. export class PositionGizmo extends Gizmo {
  43159. /**
  43160. * Internal gizmo used for interactions on the x axis
  43161. */
  43162. xGizmo: AxisDragGizmo;
  43163. /**
  43164. * Internal gizmo used for interactions on the y axis
  43165. */
  43166. yGizmo: AxisDragGizmo;
  43167. /**
  43168. * Internal gizmo used for interactions on the z axis
  43169. */
  43170. zGizmo: AxisDragGizmo;
  43171. /** Fires an event when any of it's sub gizmos are dragged */
  43172. onDragStartObservable: Observable<{}>;
  43173. /** Fires an event when any of it's sub gizmos are released from dragging */
  43174. onDragEndObservable: Observable<{}>;
  43175. attachedMesh: Nullable<AbstractMesh>;
  43176. /**
  43177. * Creates a PositionGizmo
  43178. * @param gizmoLayer The utility layer the gizmo will be added to
  43179. */
  43180. constructor(gizmoLayer?: UtilityLayerRenderer);
  43181. updateGizmoRotationToMatchAttachedMesh: boolean;
  43182. /**
  43183. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43184. */
  43185. snapDistance: number;
  43186. /**
  43187. * Ratio for the scale of the gizmo (Default: 1)
  43188. */
  43189. scaleRatio: number;
  43190. /**
  43191. * Disposes of the gizmo
  43192. */
  43193. dispose(): void;
  43194. /**
  43195. * CustomMeshes are not supported by this gizmo
  43196. * @param mesh The mesh to replace the default mesh of the gizmo
  43197. */
  43198. setCustomMesh(mesh: Mesh): void;
  43199. }
  43200. }
  43201. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43202. import { Scene } from "babylonjs/scene";
  43203. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43204. import { Mesh } from "babylonjs/Meshes/mesh";
  43205. /**
  43206. * Class containing static functions to help procedurally build meshes
  43207. */
  43208. export class PolyhedronBuilder {
  43209. /**
  43210. * Creates a polyhedron mesh
  43211. * * 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
  43212. * * The parameter `size` (positive float, default 1) sets the polygon size
  43213. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43214. * * 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`
  43215. * * 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
  43216. * * 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)`)
  43217. * * 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
  43218. * * 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
  43219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43220. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43222. * @param name defines the name of the mesh
  43223. * @param options defines the options used to create the mesh
  43224. * @param scene defines the hosting scene
  43225. * @returns the polyhedron mesh
  43226. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43227. */
  43228. static CreatePolyhedron(name: string, options: {
  43229. type?: number;
  43230. size?: number;
  43231. sizeX?: number;
  43232. sizeY?: number;
  43233. sizeZ?: number;
  43234. custom?: any;
  43235. faceUV?: Vector4[];
  43236. faceColors?: Color4[];
  43237. flat?: boolean;
  43238. updatable?: boolean;
  43239. sideOrientation?: number;
  43240. frontUVs?: Vector4;
  43241. backUVs?: Vector4;
  43242. }, scene: Scene): Mesh;
  43243. }
  43244. }
  43245. declare module "babylonjs/Gizmos/scaleGizmo" {
  43246. import { Observable } from "babylonjs/Misc/observable";
  43247. import { Nullable } from "babylonjs/types";
  43248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43249. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43250. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43251. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43252. /**
  43253. * Gizmo that enables scaling a mesh along 3 axis
  43254. */
  43255. export class ScaleGizmo extends Gizmo {
  43256. /**
  43257. * Internal gizmo used for interactions on the x axis
  43258. */
  43259. xGizmo: AxisScaleGizmo;
  43260. /**
  43261. * Internal gizmo used for interactions on the y axis
  43262. */
  43263. yGizmo: AxisScaleGizmo;
  43264. /**
  43265. * Internal gizmo used for interactions on the z axis
  43266. */
  43267. zGizmo: AxisScaleGizmo;
  43268. /**
  43269. * Internal gizmo used to scale all axis equally
  43270. */
  43271. uniformScaleGizmo: AxisScaleGizmo;
  43272. /** Fires an event when any of it's sub gizmos are dragged */
  43273. onDragStartObservable: Observable<{}>;
  43274. /** Fires an event when any of it's sub gizmos are released from dragging */
  43275. onDragEndObservable: Observable<{}>;
  43276. attachedMesh: Nullable<AbstractMesh>;
  43277. /**
  43278. * Creates a ScaleGizmo
  43279. * @param gizmoLayer The utility layer the gizmo will be added to
  43280. */
  43281. constructor(gizmoLayer?: UtilityLayerRenderer);
  43282. updateGizmoRotationToMatchAttachedMesh: boolean;
  43283. /**
  43284. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43285. */
  43286. snapDistance: number;
  43287. /**
  43288. * Ratio for the scale of the gizmo (Default: 1)
  43289. */
  43290. scaleRatio: number;
  43291. /**
  43292. * Disposes of the gizmo
  43293. */
  43294. dispose(): void;
  43295. }
  43296. }
  43297. declare module "babylonjs/Gizmos/gizmoManager" {
  43298. import { Observable } from "babylonjs/Misc/observable";
  43299. import { Nullable } from "babylonjs/types";
  43300. import { Scene, IDisposable } from "babylonjs/scene";
  43301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43302. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43303. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43304. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43305. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43306. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43307. /**
  43308. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43309. */
  43310. export class GizmoManager implements IDisposable {
  43311. private scene;
  43312. /**
  43313. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43314. */
  43315. gizmos: {
  43316. positionGizmo: Nullable<PositionGizmo>;
  43317. rotationGizmo: Nullable<RotationGizmo>;
  43318. scaleGizmo: Nullable<ScaleGizmo>;
  43319. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43320. };
  43321. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43322. clearGizmoOnEmptyPointerEvent: boolean;
  43323. /** Fires an event when the manager is attached to a mesh */
  43324. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43325. private _gizmosEnabled;
  43326. private _pointerObserver;
  43327. private _attachedMesh;
  43328. private _boundingBoxColor;
  43329. private _defaultUtilityLayer;
  43330. private _defaultKeepDepthUtilityLayer;
  43331. /**
  43332. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43333. */
  43334. boundingBoxDragBehavior: SixDofDragBehavior;
  43335. /**
  43336. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43337. */
  43338. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43339. /**
  43340. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43341. */
  43342. usePointerToAttachGizmos: boolean;
  43343. /**
  43344. * Instatiates a gizmo manager
  43345. * @param scene the scene to overlay the gizmos on top of
  43346. */
  43347. constructor(scene: Scene);
  43348. /**
  43349. * Attaches a set of gizmos to the specified mesh
  43350. * @param mesh The mesh the gizmo's should be attached to
  43351. */
  43352. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43353. /**
  43354. * If the position gizmo is enabled
  43355. */
  43356. positionGizmoEnabled: boolean;
  43357. /**
  43358. * If the rotation gizmo is enabled
  43359. */
  43360. rotationGizmoEnabled: boolean;
  43361. /**
  43362. * If the scale gizmo is enabled
  43363. */
  43364. scaleGizmoEnabled: boolean;
  43365. /**
  43366. * If the boundingBox gizmo is enabled
  43367. */
  43368. boundingBoxGizmoEnabled: boolean;
  43369. /**
  43370. * Disposes of the gizmo manager
  43371. */
  43372. dispose(): void;
  43373. }
  43374. }
  43375. declare module "babylonjs/Gizmos/lightGizmo" {
  43376. import { Nullable } from "babylonjs/types";
  43377. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43378. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43379. import { Light } from "babylonjs/Lights/light";
  43380. /**
  43381. * Gizmo that enables viewing a light
  43382. */
  43383. export class LightGizmo extends Gizmo {
  43384. private _box;
  43385. /**
  43386. * Creates a LightGizmo
  43387. * @param gizmoLayer The utility layer the gizmo will be added to
  43388. */
  43389. constructor(gizmoLayer?: UtilityLayerRenderer);
  43390. private _light;
  43391. /**
  43392. * The light that the gizmo is attached to
  43393. */
  43394. light: Nullable<Light>;
  43395. /**
  43396. * @hidden
  43397. * Updates the gizmo to match the attached mesh's position/rotation
  43398. */
  43399. protected _update(): void;
  43400. }
  43401. }
  43402. declare module "babylonjs/Gizmos/index" {
  43403. export * from "babylonjs/Gizmos/axisDragGizmo";
  43404. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43405. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43406. export * from "babylonjs/Gizmos/gizmo";
  43407. export * from "babylonjs/Gizmos/gizmoManager";
  43408. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43409. export * from "babylonjs/Gizmos/positionGizmo";
  43410. export * from "babylonjs/Gizmos/rotationGizmo";
  43411. export * from "babylonjs/Gizmos/scaleGizmo";
  43412. export * from "babylonjs/Gizmos/lightGizmo";
  43413. }
  43414. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43415. /** @hidden */
  43416. export var backgroundFragmentDeclaration: {
  43417. name: string;
  43418. shader: string;
  43419. };
  43420. }
  43421. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43422. /** @hidden */
  43423. export var backgroundUboDeclaration: {
  43424. name: string;
  43425. shader: string;
  43426. };
  43427. }
  43428. declare module "babylonjs/Shaders/background.fragment" {
  43429. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43430. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43431. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43432. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43433. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43434. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43435. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43436. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43437. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43438. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43439. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43440. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43441. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43442. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43443. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43444. /** @hidden */
  43445. export var backgroundPixelShader: {
  43446. name: string;
  43447. shader: string;
  43448. };
  43449. }
  43450. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43451. /** @hidden */
  43452. export var backgroundVertexDeclaration: {
  43453. name: string;
  43454. shader: string;
  43455. };
  43456. }
  43457. declare module "babylonjs/Shaders/background.vertex" {
  43458. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43459. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43460. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43461. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43462. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43463. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43464. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43465. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43466. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43467. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43468. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43469. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43470. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43471. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43472. /** @hidden */
  43473. export var backgroundVertexShader: {
  43474. name: string;
  43475. shader: string;
  43476. };
  43477. }
  43478. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43479. import { Nullable, int, float } from "babylonjs/types";
  43480. import { Scene } from "babylonjs/scene";
  43481. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43482. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43484. import { Mesh } from "babylonjs/Meshes/mesh";
  43485. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43486. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43487. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43488. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43489. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43490. import "babylonjs/Shaders/background.fragment";
  43491. import "babylonjs/Shaders/background.vertex";
  43492. /**
  43493. * Background material used to create an efficient environement around your scene.
  43494. */
  43495. export class BackgroundMaterial extends PushMaterial {
  43496. /**
  43497. * Standard reflectance value at parallel view angle.
  43498. */
  43499. static StandardReflectance0: number;
  43500. /**
  43501. * Standard reflectance value at grazing angle.
  43502. */
  43503. static StandardReflectance90: number;
  43504. protected _primaryColor: Color3;
  43505. /**
  43506. * Key light Color (multiply against the environement texture)
  43507. */
  43508. primaryColor: Color3;
  43509. protected __perceptualColor: Nullable<Color3>;
  43510. /**
  43511. * Experimental Internal Use Only.
  43512. *
  43513. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43514. * This acts as a helper to set the primary color to a more "human friendly" value.
  43515. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43516. * output color as close as possible from the chosen value.
  43517. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43518. * part of lighting setup.)
  43519. */
  43520. _perceptualColor: Nullable<Color3>;
  43521. protected _primaryColorShadowLevel: float;
  43522. /**
  43523. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43524. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43525. */
  43526. primaryColorShadowLevel: float;
  43527. protected _primaryColorHighlightLevel: float;
  43528. /**
  43529. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43530. * The primary color is used at the level chosen to define what the white area would look.
  43531. */
  43532. primaryColorHighlightLevel: float;
  43533. protected _reflectionTexture: Nullable<BaseTexture>;
  43534. /**
  43535. * Reflection Texture used in the material.
  43536. * Should be author in a specific way for the best result (refer to the documentation).
  43537. */
  43538. reflectionTexture: Nullable<BaseTexture>;
  43539. protected _reflectionBlur: float;
  43540. /**
  43541. * Reflection Texture level of blur.
  43542. *
  43543. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43544. * texture twice.
  43545. */
  43546. reflectionBlur: float;
  43547. protected _diffuseTexture: Nullable<BaseTexture>;
  43548. /**
  43549. * Diffuse Texture used in the material.
  43550. * Should be author in a specific way for the best result (refer to the documentation).
  43551. */
  43552. diffuseTexture: Nullable<BaseTexture>;
  43553. protected _shadowLights: Nullable<IShadowLight[]>;
  43554. /**
  43555. * Specify the list of lights casting shadow on the material.
  43556. * All scene shadow lights will be included if null.
  43557. */
  43558. shadowLights: Nullable<IShadowLight[]>;
  43559. protected _shadowLevel: float;
  43560. /**
  43561. * Helps adjusting the shadow to a softer level if required.
  43562. * 0 means black shadows and 1 means no shadows.
  43563. */
  43564. shadowLevel: float;
  43565. protected _sceneCenter: Vector3;
  43566. /**
  43567. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43568. * It is usually zero but might be interesting to modify according to your setup.
  43569. */
  43570. sceneCenter: Vector3;
  43571. protected _opacityFresnel: boolean;
  43572. /**
  43573. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43574. * This helps ensuring a nice transition when the camera goes under the ground.
  43575. */
  43576. opacityFresnel: boolean;
  43577. protected _reflectionFresnel: boolean;
  43578. /**
  43579. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43580. * This helps adding a mirror texture on the ground.
  43581. */
  43582. reflectionFresnel: boolean;
  43583. protected _reflectionFalloffDistance: number;
  43584. /**
  43585. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43586. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43587. */
  43588. reflectionFalloffDistance: number;
  43589. protected _reflectionAmount: number;
  43590. /**
  43591. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43592. */
  43593. reflectionAmount: number;
  43594. protected _reflectionReflectance0: number;
  43595. /**
  43596. * This specifies the weight of the reflection at grazing angle.
  43597. */
  43598. reflectionReflectance0: number;
  43599. protected _reflectionReflectance90: number;
  43600. /**
  43601. * This specifies the weight of the reflection at a perpendicular point of view.
  43602. */
  43603. reflectionReflectance90: number;
  43604. /**
  43605. * Sets the reflection reflectance fresnel values according to the default standard
  43606. * empirically know to work well :-)
  43607. */
  43608. reflectionStandardFresnelWeight: number;
  43609. protected _useRGBColor: boolean;
  43610. /**
  43611. * Helps to directly use the maps channels instead of their level.
  43612. */
  43613. useRGBColor: boolean;
  43614. protected _enableNoise: boolean;
  43615. /**
  43616. * This helps reducing the banding effect that could occur on the background.
  43617. */
  43618. enableNoise: boolean;
  43619. /**
  43620. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43621. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43622. * Recommended to be keep at 1.0 except for special cases.
  43623. */
  43624. fovMultiplier: number;
  43625. private _fovMultiplier;
  43626. /**
  43627. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43628. */
  43629. useEquirectangularFOV: boolean;
  43630. private _maxSimultaneousLights;
  43631. /**
  43632. * Number of Simultaneous lights allowed on the material.
  43633. */
  43634. maxSimultaneousLights: int;
  43635. /**
  43636. * Default configuration related to image processing available in the Background Material.
  43637. */
  43638. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43639. /**
  43640. * Keep track of the image processing observer to allow dispose and replace.
  43641. */
  43642. private _imageProcessingObserver;
  43643. /**
  43644. * Attaches a new image processing configuration to the PBR Material.
  43645. * @param configuration (if null the scene configuration will be use)
  43646. */
  43647. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43648. /**
  43649. * Gets the image processing configuration used either in this material.
  43650. */
  43651. /**
  43652. * Sets the Default image processing configuration used either in the this material.
  43653. *
  43654. * If sets to null, the scene one is in use.
  43655. */
  43656. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43657. /**
  43658. * Gets wether the color curves effect is enabled.
  43659. */
  43660. /**
  43661. * Sets wether the color curves effect is enabled.
  43662. */
  43663. cameraColorCurvesEnabled: boolean;
  43664. /**
  43665. * Gets wether the color grading effect is enabled.
  43666. */
  43667. /**
  43668. * Gets wether the color grading effect is enabled.
  43669. */
  43670. cameraColorGradingEnabled: boolean;
  43671. /**
  43672. * Gets wether tonemapping is enabled or not.
  43673. */
  43674. /**
  43675. * Sets wether tonemapping is enabled or not
  43676. */
  43677. cameraToneMappingEnabled: boolean;
  43678. /**
  43679. * The camera exposure used on this material.
  43680. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43681. * This corresponds to a photographic exposure.
  43682. */
  43683. /**
  43684. * The camera exposure used on this material.
  43685. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43686. * This corresponds to a photographic exposure.
  43687. */
  43688. cameraExposure: float;
  43689. /**
  43690. * Gets The camera contrast used on this material.
  43691. */
  43692. /**
  43693. * Sets The camera contrast used on this material.
  43694. */
  43695. cameraContrast: float;
  43696. /**
  43697. * Gets the Color Grading 2D Lookup Texture.
  43698. */
  43699. /**
  43700. * Sets the Color Grading 2D Lookup Texture.
  43701. */
  43702. cameraColorGradingTexture: Nullable<BaseTexture>;
  43703. /**
  43704. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43705. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43706. * 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;
  43707. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43708. */
  43709. /**
  43710. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43711. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43712. * 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;
  43713. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43714. */
  43715. cameraColorCurves: Nullable<ColorCurves>;
  43716. /**
  43717. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43718. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43719. */
  43720. switchToBGR: boolean;
  43721. private _renderTargets;
  43722. private _reflectionControls;
  43723. private _white;
  43724. private _primaryShadowColor;
  43725. private _primaryHighlightColor;
  43726. /**
  43727. * Instantiates a Background Material in the given scene
  43728. * @param name The friendly name of the material
  43729. * @param scene The scene to add the material to
  43730. */
  43731. constructor(name: string, scene: Scene);
  43732. /**
  43733. * Gets a boolean indicating that current material needs to register RTT
  43734. */
  43735. readonly hasRenderTargetTextures: boolean;
  43736. /**
  43737. * The entire material has been created in order to prevent overdraw.
  43738. * @returns false
  43739. */
  43740. needAlphaTesting(): boolean;
  43741. /**
  43742. * The entire material has been created in order to prevent overdraw.
  43743. * @returns true if blending is enable
  43744. */
  43745. needAlphaBlending(): boolean;
  43746. /**
  43747. * Checks wether the material is ready to be rendered for a given mesh.
  43748. * @param mesh The mesh to render
  43749. * @param subMesh The submesh to check against
  43750. * @param useInstances Specify wether or not the material is used with instances
  43751. * @returns true if all the dependencies are ready (Textures, Effects...)
  43752. */
  43753. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43754. /**
  43755. * Compute the primary color according to the chosen perceptual color.
  43756. */
  43757. private _computePrimaryColorFromPerceptualColor;
  43758. /**
  43759. * Compute the highlights and shadow colors according to their chosen levels.
  43760. */
  43761. private _computePrimaryColors;
  43762. /**
  43763. * Build the uniform buffer used in the material.
  43764. */
  43765. buildUniformLayout(): void;
  43766. /**
  43767. * Unbind the material.
  43768. */
  43769. unbind(): void;
  43770. /**
  43771. * Bind only the world matrix to the material.
  43772. * @param world The world matrix to bind.
  43773. */
  43774. bindOnlyWorldMatrix(world: Matrix): void;
  43775. /**
  43776. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43777. * @param world The world matrix to bind.
  43778. * @param subMesh The submesh to bind for.
  43779. */
  43780. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43781. /**
  43782. * Dispose the material.
  43783. * @param forceDisposeEffect Force disposal of the associated effect.
  43784. * @param forceDisposeTextures Force disposal of the associated textures.
  43785. */
  43786. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43787. /**
  43788. * Clones the material.
  43789. * @param name The cloned name.
  43790. * @returns The cloned material.
  43791. */
  43792. clone(name: string): BackgroundMaterial;
  43793. /**
  43794. * Serializes the current material to its JSON representation.
  43795. * @returns The JSON representation.
  43796. */
  43797. serialize(): any;
  43798. /**
  43799. * Gets the class name of the material
  43800. * @returns "BackgroundMaterial"
  43801. */
  43802. getClassName(): string;
  43803. /**
  43804. * Parse a JSON input to create back a background material.
  43805. * @param source The JSON data to parse
  43806. * @param scene The scene to create the parsed material in
  43807. * @param rootUrl The root url of the assets the material depends upon
  43808. * @returns the instantiated BackgroundMaterial.
  43809. */
  43810. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43811. }
  43812. }
  43813. declare module "babylonjs/Helpers/environmentHelper" {
  43814. import { Observable } from "babylonjs/Misc/observable";
  43815. import { Nullable } from "babylonjs/types";
  43816. import { Scene } from "babylonjs/scene";
  43817. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43819. import { Mesh } from "babylonjs/Meshes/mesh";
  43820. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43821. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43822. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43823. import "babylonjs/Meshes/Builders/planeBuilder";
  43824. import "babylonjs/Meshes/Builders/boxBuilder";
  43825. /**
  43826. * Represents the different options available during the creation of
  43827. * a Environment helper.
  43828. *
  43829. * This can control the default ground, skybox and image processing setup of your scene.
  43830. */
  43831. export interface IEnvironmentHelperOptions {
  43832. /**
  43833. * Specifies wether or not to create a ground.
  43834. * True by default.
  43835. */
  43836. createGround: boolean;
  43837. /**
  43838. * Specifies the ground size.
  43839. * 15 by default.
  43840. */
  43841. groundSize: number;
  43842. /**
  43843. * The texture used on the ground for the main color.
  43844. * Comes from the BabylonJS CDN by default.
  43845. *
  43846. * Remarks: Can be either a texture or a url.
  43847. */
  43848. groundTexture: string | BaseTexture;
  43849. /**
  43850. * The color mixed in the ground texture by default.
  43851. * BabylonJS clearColor by default.
  43852. */
  43853. groundColor: Color3;
  43854. /**
  43855. * Specifies the ground opacity.
  43856. * 1 by default.
  43857. */
  43858. groundOpacity: number;
  43859. /**
  43860. * Enables the ground to receive shadows.
  43861. * True by default.
  43862. */
  43863. enableGroundShadow: boolean;
  43864. /**
  43865. * Helps preventing the shadow to be fully black on the ground.
  43866. * 0.5 by default.
  43867. */
  43868. groundShadowLevel: number;
  43869. /**
  43870. * Creates a mirror texture attach to the ground.
  43871. * false by default.
  43872. */
  43873. enableGroundMirror: boolean;
  43874. /**
  43875. * Specifies the ground mirror size ratio.
  43876. * 0.3 by default as the default kernel is 64.
  43877. */
  43878. groundMirrorSizeRatio: number;
  43879. /**
  43880. * Specifies the ground mirror blur kernel size.
  43881. * 64 by default.
  43882. */
  43883. groundMirrorBlurKernel: number;
  43884. /**
  43885. * Specifies the ground mirror visibility amount.
  43886. * 1 by default
  43887. */
  43888. groundMirrorAmount: number;
  43889. /**
  43890. * Specifies the ground mirror reflectance weight.
  43891. * This uses the standard weight of the background material to setup the fresnel effect
  43892. * of the mirror.
  43893. * 1 by default.
  43894. */
  43895. groundMirrorFresnelWeight: number;
  43896. /**
  43897. * Specifies the ground mirror Falloff distance.
  43898. * This can helps reducing the size of the reflection.
  43899. * 0 by Default.
  43900. */
  43901. groundMirrorFallOffDistance: number;
  43902. /**
  43903. * Specifies the ground mirror texture type.
  43904. * Unsigned Int by Default.
  43905. */
  43906. groundMirrorTextureType: number;
  43907. /**
  43908. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43909. * the shown objects.
  43910. */
  43911. groundYBias: number;
  43912. /**
  43913. * Specifies wether or not to create a skybox.
  43914. * True by default.
  43915. */
  43916. createSkybox: boolean;
  43917. /**
  43918. * Specifies the skybox size.
  43919. * 20 by default.
  43920. */
  43921. skyboxSize: number;
  43922. /**
  43923. * The texture used on the skybox for the main color.
  43924. * Comes from the BabylonJS CDN by default.
  43925. *
  43926. * Remarks: Can be either a texture or a url.
  43927. */
  43928. skyboxTexture: string | BaseTexture;
  43929. /**
  43930. * The color mixed in the skybox texture by default.
  43931. * BabylonJS clearColor by default.
  43932. */
  43933. skyboxColor: Color3;
  43934. /**
  43935. * The background rotation around the Y axis of the scene.
  43936. * This helps aligning the key lights of your scene with the background.
  43937. * 0 by default.
  43938. */
  43939. backgroundYRotation: number;
  43940. /**
  43941. * Compute automatically the size of the elements to best fit with the scene.
  43942. */
  43943. sizeAuto: boolean;
  43944. /**
  43945. * Default position of the rootMesh if autoSize is not true.
  43946. */
  43947. rootPosition: Vector3;
  43948. /**
  43949. * Sets up the image processing in the scene.
  43950. * true by default.
  43951. */
  43952. setupImageProcessing: boolean;
  43953. /**
  43954. * The texture used as your environment texture in the scene.
  43955. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43956. *
  43957. * Remarks: Can be either a texture or a url.
  43958. */
  43959. environmentTexture: string | BaseTexture;
  43960. /**
  43961. * The value of the exposure to apply to the scene.
  43962. * 0.6 by default if setupImageProcessing is true.
  43963. */
  43964. cameraExposure: number;
  43965. /**
  43966. * The value of the contrast to apply to the scene.
  43967. * 1.6 by default if setupImageProcessing is true.
  43968. */
  43969. cameraContrast: number;
  43970. /**
  43971. * Specifies wether or not tonemapping should be enabled in the scene.
  43972. * true by default if setupImageProcessing is true.
  43973. */
  43974. toneMappingEnabled: boolean;
  43975. }
  43976. /**
  43977. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43978. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43979. * It also helps with the default setup of your imageProcessing configuration.
  43980. */
  43981. export class EnvironmentHelper {
  43982. /**
  43983. * Default ground texture URL.
  43984. */
  43985. private static _groundTextureCDNUrl;
  43986. /**
  43987. * Default skybox texture URL.
  43988. */
  43989. private static _skyboxTextureCDNUrl;
  43990. /**
  43991. * Default environment texture URL.
  43992. */
  43993. private static _environmentTextureCDNUrl;
  43994. /**
  43995. * Creates the default options for the helper.
  43996. */
  43997. private static _getDefaultOptions;
  43998. private _rootMesh;
  43999. /**
  44000. * Gets the root mesh created by the helper.
  44001. */
  44002. readonly rootMesh: Mesh;
  44003. private _skybox;
  44004. /**
  44005. * Gets the skybox created by the helper.
  44006. */
  44007. readonly skybox: Nullable<Mesh>;
  44008. private _skyboxTexture;
  44009. /**
  44010. * Gets the skybox texture created by the helper.
  44011. */
  44012. readonly skyboxTexture: Nullable<BaseTexture>;
  44013. private _skyboxMaterial;
  44014. /**
  44015. * Gets the skybox material created by the helper.
  44016. */
  44017. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44018. private _ground;
  44019. /**
  44020. * Gets the ground mesh created by the helper.
  44021. */
  44022. readonly ground: Nullable<Mesh>;
  44023. private _groundTexture;
  44024. /**
  44025. * Gets the ground texture created by the helper.
  44026. */
  44027. readonly groundTexture: Nullable<BaseTexture>;
  44028. private _groundMirror;
  44029. /**
  44030. * Gets the ground mirror created by the helper.
  44031. */
  44032. readonly groundMirror: Nullable<MirrorTexture>;
  44033. /**
  44034. * Gets the ground mirror render list to helps pushing the meshes
  44035. * you wish in the ground reflection.
  44036. */
  44037. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44038. private _groundMaterial;
  44039. /**
  44040. * Gets the ground material created by the helper.
  44041. */
  44042. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44043. /**
  44044. * Stores the creation options.
  44045. */
  44046. private readonly _scene;
  44047. private _options;
  44048. /**
  44049. * This observable will be notified with any error during the creation of the environment,
  44050. * mainly texture creation errors.
  44051. */
  44052. onErrorObservable: Observable<{
  44053. message?: string;
  44054. exception?: any;
  44055. }>;
  44056. /**
  44057. * constructor
  44058. * @param options Defines the options we want to customize the helper
  44059. * @param scene The scene to add the material to
  44060. */
  44061. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44062. /**
  44063. * Updates the background according to the new options
  44064. * @param options
  44065. */
  44066. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44067. /**
  44068. * Sets the primary color of all the available elements.
  44069. * @param color the main color to affect to the ground and the background
  44070. */
  44071. setMainColor(color: Color3): void;
  44072. /**
  44073. * Setup the image processing according to the specified options.
  44074. */
  44075. private _setupImageProcessing;
  44076. /**
  44077. * Setup the environment texture according to the specified options.
  44078. */
  44079. private _setupEnvironmentTexture;
  44080. /**
  44081. * Setup the background according to the specified options.
  44082. */
  44083. private _setupBackground;
  44084. /**
  44085. * Get the scene sizes according to the setup.
  44086. */
  44087. private _getSceneSize;
  44088. /**
  44089. * Setup the ground according to the specified options.
  44090. */
  44091. private _setupGround;
  44092. /**
  44093. * Setup the ground material according to the specified options.
  44094. */
  44095. private _setupGroundMaterial;
  44096. /**
  44097. * Setup the ground diffuse texture according to the specified options.
  44098. */
  44099. private _setupGroundDiffuseTexture;
  44100. /**
  44101. * Setup the ground mirror texture according to the specified options.
  44102. */
  44103. private _setupGroundMirrorTexture;
  44104. /**
  44105. * Setup the ground to receive the mirror texture.
  44106. */
  44107. private _setupMirrorInGroundMaterial;
  44108. /**
  44109. * Setup the skybox according to the specified options.
  44110. */
  44111. private _setupSkybox;
  44112. /**
  44113. * Setup the skybox material according to the specified options.
  44114. */
  44115. private _setupSkyboxMaterial;
  44116. /**
  44117. * Setup the skybox reflection texture according to the specified options.
  44118. */
  44119. private _setupSkyboxReflectionTexture;
  44120. private _errorHandler;
  44121. /**
  44122. * Dispose all the elements created by the Helper.
  44123. */
  44124. dispose(): void;
  44125. }
  44126. }
  44127. declare module "babylonjs/Helpers/photoDome" {
  44128. import { Observable } from "babylonjs/Misc/observable";
  44129. import { Nullable } from "babylonjs/types";
  44130. import { Scene } from "babylonjs/scene";
  44131. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44132. import { Mesh } from "babylonjs/Meshes/mesh";
  44133. import { Texture } from "babylonjs/Materials/Textures/texture";
  44134. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44135. import "babylonjs/Meshes/Builders/sphereBuilder";
  44136. /**
  44137. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44138. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44139. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44140. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44141. */
  44142. export class PhotoDome extends TransformNode {
  44143. private _useDirectMapping;
  44144. /**
  44145. * The texture being displayed on the sphere
  44146. */
  44147. protected _photoTexture: Texture;
  44148. /**
  44149. * Gets or sets the texture being displayed on the sphere
  44150. */
  44151. photoTexture: Texture;
  44152. /**
  44153. * Observable raised when an error occured while loading the 360 image
  44154. */
  44155. onLoadErrorObservable: Observable<string>;
  44156. /**
  44157. * The skybox material
  44158. */
  44159. protected _material: BackgroundMaterial;
  44160. /**
  44161. * The surface used for the skybox
  44162. */
  44163. protected _mesh: Mesh;
  44164. /**
  44165. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44166. * Also see the options.resolution property.
  44167. */
  44168. fovMultiplier: number;
  44169. /**
  44170. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44171. * @param name Element's name, child elements will append suffixes for their own names.
  44172. * @param urlsOfPhoto defines the url of the photo to display
  44173. * @param options defines an object containing optional or exposed sub element properties
  44174. * @param onError defines a callback called when an error occured while loading the texture
  44175. */
  44176. constructor(name: string, urlOfPhoto: string, options: {
  44177. resolution?: number;
  44178. size?: number;
  44179. useDirectMapping?: boolean;
  44180. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44181. /**
  44182. * Releases resources associated with this node.
  44183. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44184. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44185. */
  44186. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44187. }
  44188. }
  44189. declare module "babylonjs/Misc/textureTools" {
  44190. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44191. import { Texture } from "babylonjs/Materials/Textures/texture";
  44192. import { Scene } from "babylonjs/scene";
  44193. /**
  44194. * Class used to host texture specific utilities
  44195. */
  44196. export class TextureTools {
  44197. /**
  44198. * Uses the GPU to create a copy texture rescaled at a given size
  44199. * @param texture Texture to copy from
  44200. * @param width defines the desired width
  44201. * @param height defines the desired height
  44202. * @param useBilinearMode defines if bilinear mode has to be used
  44203. * @return the generated texture
  44204. */
  44205. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44206. /**
  44207. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44208. * @param scene defines the hosting scene
  44209. * @returns the environment BRDF texture
  44210. */
  44211. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44212. private static _environmentBRDFBase64Texture;
  44213. }
  44214. }
  44215. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44216. import { Nullable } from "babylonjs/types";
  44217. import { IAnimatable } from "babylonjs/Misc/tools";
  44218. import { Color3 } from "babylonjs/Maths/math";
  44219. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44220. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44221. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44222. import { Engine } from "babylonjs/Engines/engine";
  44223. import { Scene } from "babylonjs/scene";
  44224. /**
  44225. * @hidden
  44226. */
  44227. export interface IMaterialClearCoatDefines {
  44228. CLEARCOAT: boolean;
  44229. CLEARCOAT_DEFAULTIOR: boolean;
  44230. CLEARCOAT_TEXTURE: boolean;
  44231. CLEARCOAT_TEXTUREDIRECTUV: number;
  44232. CLEARCOAT_BUMP: boolean;
  44233. CLEARCOAT_BUMPDIRECTUV: number;
  44234. CLEARCOAT_TINT: boolean;
  44235. CLEARCOAT_TINT_TEXTURE: boolean;
  44236. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44237. /** @hidden */
  44238. _areTexturesDirty: boolean;
  44239. }
  44240. /**
  44241. * Define the code related to the clear coat parameters of the pbr material.
  44242. */
  44243. export class PBRClearCoatConfiguration {
  44244. /**
  44245. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44246. * The default fits with a polyurethane material.
  44247. */
  44248. private static readonly _DefaultIndiceOfRefraction;
  44249. private _isEnabled;
  44250. /**
  44251. * Defines if the clear coat is enabled in the material.
  44252. */
  44253. isEnabled: boolean;
  44254. /**
  44255. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44256. */
  44257. intensity: number;
  44258. /**
  44259. * Defines the clear coat layer roughness.
  44260. */
  44261. roughness: number;
  44262. private _indiceOfRefraction;
  44263. /**
  44264. * Defines the indice of refraction of the clear coat.
  44265. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44266. * The default fits with a polyurethane material.
  44267. * Changing the default value is more performance intensive.
  44268. */
  44269. indiceOfRefraction: number;
  44270. private _texture;
  44271. /**
  44272. * Stores the clear coat values in a texture.
  44273. */
  44274. texture: Nullable<BaseTexture>;
  44275. private _bumpTexture;
  44276. /**
  44277. * Define the clear coat specific bump texture.
  44278. */
  44279. bumpTexture: Nullable<BaseTexture>;
  44280. private _isTintEnabled;
  44281. /**
  44282. * Defines if the clear coat tint is enabled in the material.
  44283. */
  44284. isTintEnabled: boolean;
  44285. /**
  44286. * Defines if the clear coat tint is enabled in the material.
  44287. * This is only use if tint is enabled
  44288. */
  44289. tintColor: Color3;
  44290. /**
  44291. * Defines if the distance at which the tint color should be found in the
  44292. * clear coat media.
  44293. * This is only use if tint is enabled
  44294. */
  44295. tintColorAtDistance: number;
  44296. /**
  44297. * Defines the clear coat layer thickness.
  44298. * This is only use if tint is enabled
  44299. */
  44300. tintThickness: number;
  44301. private _tintTexture;
  44302. /**
  44303. * Stores the clear tint values in a texture.
  44304. * rgb is tint
  44305. * a is a thickness factor
  44306. */
  44307. tintTexture: Nullable<BaseTexture>;
  44308. /** @hidden */
  44309. private _internalMarkAllSubMeshesAsTexturesDirty;
  44310. /** @hidden */
  44311. _markAllSubMeshesAsTexturesDirty(): void;
  44312. /**
  44313. * Instantiate a new istance of clear coat configuration.
  44314. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44315. */
  44316. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44317. /**
  44318. * Specifies that the submesh is ready to be used.
  44319. * @param defines the list of "defines" to update.
  44320. * @param scene defines the scene the material belongs to.
  44321. * @param engine defines the engine the material belongs to.
  44322. * @param disableBumpMap defines wether the material disables bump or not.
  44323. * @returns - boolean indicating that the submesh is ready or not.
  44324. */
  44325. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44326. /**
  44327. * Checks to see if a texture is used in the material.
  44328. * @param defines the list of "defines" to update.
  44329. * @param scene defines the scene to the material belongs to.
  44330. */
  44331. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44332. /**
  44333. * Binds the material data.
  44334. * @param uniformBuffer defines the Uniform buffer to fill in.
  44335. * @param scene defines the scene the material belongs to.
  44336. * @param engine defines the engine the material belongs to.
  44337. * @param disableBumpMap defines wether the material disables bump or not.
  44338. * @param isFrozen defines wether the material is frozen or not.
  44339. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44340. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44341. */
  44342. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44343. /**
  44344. * Checks to see if a texture is used in the material.
  44345. * @param texture - Base texture to use.
  44346. * @returns - Boolean specifying if a texture is used in the material.
  44347. */
  44348. hasTexture(texture: BaseTexture): boolean;
  44349. /**
  44350. * Returns an array of the actively used textures.
  44351. * @param activeTextures Array of BaseTextures
  44352. */
  44353. getActiveTextures(activeTextures: BaseTexture[]): void;
  44354. /**
  44355. * Returns the animatable textures.
  44356. * @param animatables Array of animatable textures.
  44357. */
  44358. getAnimatables(animatables: IAnimatable[]): void;
  44359. /**
  44360. * Disposes the resources of the material.
  44361. * @param forceDisposeTextures - Forces the disposal of all textures.
  44362. */
  44363. dispose(forceDisposeTextures?: boolean): void;
  44364. /**
  44365. * Get the current class name of the texture useful for serialization or dynamic coding.
  44366. * @returns "PBRClearCoatConfiguration"
  44367. */
  44368. getClassName(): string;
  44369. /**
  44370. * Makes a duplicate of the current configuration into another one.
  44371. * @param clearCoatConfiguration define the config where to copy the info
  44372. */
  44373. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44374. /**
  44375. * Serializes this clear coat configuration.
  44376. * @returns - An object with the serialized config.
  44377. */
  44378. serialize(): any;
  44379. /**
  44380. * Parses a Clear Coat Configuration from a serialized object.
  44381. * @param source - Serialized object.
  44382. */
  44383. parse(source: any): void;
  44384. /**
  44385. * Add fallbacks to the effect fallbacks list.
  44386. * @param defines defines the Base texture to use.
  44387. * @param fallbacks defines the current fallback list.
  44388. * @param currentRank defines the current fallback rank.
  44389. * @returns the new fallback rank.
  44390. */
  44391. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44392. /**
  44393. * Add the required uniforms to the current list.
  44394. * @param uniforms defines the current uniform list.
  44395. */
  44396. static AddUniforms(uniforms: string[]): void;
  44397. /**
  44398. * Add the required samplers to the current list.
  44399. * @param samplers defines the current sampler list.
  44400. */
  44401. static AddSamplers(samplers: string[]): void;
  44402. /**
  44403. * Add the required uniforms to the current buffer.
  44404. * @param uniformBuffer defines the current uniform buffer.
  44405. */
  44406. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44407. }
  44408. }
  44409. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44410. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44411. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44413. /**
  44414. * @hidden
  44415. */
  44416. export interface IMaterialAnisotropicDefines {
  44417. ANISOTROPIC: boolean;
  44418. MAINUV1: boolean;
  44419. _areMiscDirty: boolean;
  44420. _needUVs: boolean;
  44421. }
  44422. /**
  44423. * Define the code related to the anisotropic parameters of the pbr material.
  44424. */
  44425. export class PBRAnisotropicConfiguration {
  44426. private _isEnabled;
  44427. /**
  44428. * Defines if the anisotropy is enabled in the material.
  44429. */
  44430. isEnabled: boolean;
  44431. /**
  44432. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44433. */
  44434. intensity: number;
  44435. /**
  44436. * Defines if the effect is along the tangents or bitangents.
  44437. * By default, the effect is "strectching" the highlights along the tangents.
  44438. */
  44439. followTangents: boolean;
  44440. /** @hidden */
  44441. private _internalMarkAllSubMeshesAsMiscDirty;
  44442. /** @hidden */
  44443. _markAllSubMeshesAsMiscDirty(): void;
  44444. /**
  44445. * Instantiate a new istance of clear coat configuration.
  44446. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44447. */
  44448. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44449. /**
  44450. * Checks to see if a texture is used in the material.
  44451. * @param defines the list of "defines" to update.
  44452. * @param mesh the mesh we are preparing the defines for.
  44453. */
  44454. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  44455. /**
  44456. * Binds the material data.
  44457. * @param uniformBuffer defines the Uniform buffer to fill in.
  44458. * @param isFrozen defines wether the material is frozen or not.
  44459. */
  44460. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  44461. /**
  44462. * Get the current class name of the texture useful for serialization or dynamic coding.
  44463. * @returns "PBRAnisotropicConfiguration"
  44464. */
  44465. getClassName(): string;
  44466. /**
  44467. * Makes a duplicate of the current configuration into another one.
  44468. * @param anisotropicConfiguration define the config where to copy the info
  44469. */
  44470. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44471. /**
  44472. * Serializes this clear coat configuration.
  44473. * @returns - An object with the serialized config.
  44474. */
  44475. serialize(): any;
  44476. /**
  44477. * Parses a Clear Coat Configuration from a serialized object.
  44478. * @param source - Serialized object.
  44479. */
  44480. parse(source: any): void;
  44481. /**
  44482. * Add fallbacks to the effect fallbacks list.
  44483. * @param defines defines the Base texture to use.
  44484. * @param fallbacks defines the current fallback list.
  44485. * @param currentRank defines the current fallback rank.
  44486. * @returns the new fallback rank.
  44487. */
  44488. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44489. /**
  44490. * Add the required uniforms to the current list.
  44491. * @param uniforms defines the current uniform list.
  44492. */
  44493. static AddUniforms(uniforms: string[]): void;
  44494. /**
  44495. * Add the required uniforms to the current buffer.
  44496. * @param uniformBuffer defines the current uniform buffer.
  44497. */
  44498. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44499. }
  44500. }
  44501. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  44502. /**
  44503. * @hidden
  44504. */
  44505. export interface IMaterialBRDFDefines {
  44506. BRDF_V_HEIGHT_CORRELATED: boolean;
  44507. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44508. /** @hidden */
  44509. _areMiscDirty: boolean;
  44510. }
  44511. /**
  44512. * Define the code related to the BRDF parameters of the pbr material.
  44513. */
  44514. export class PBRBRDFConfiguration {
  44515. private _useEnergyConservation;
  44516. /**
  44517. * Defines if the material uses energy conservation.
  44518. */
  44519. useEnergyConservation: boolean;
  44520. private _useSmithVisibilityHeightCorrelated;
  44521. /**
  44522. * LEGACY Mode set to false
  44523. * Defines if the material uses height smith correlated visibility term.
  44524. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44525. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44526. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44527. * Not relying on height correlated will also disable energy conservation.
  44528. */
  44529. useSmithVisibilityHeightCorrelated: boolean;
  44530. /** @hidden */
  44531. private _internalMarkAllSubMeshesAsMiscDirty;
  44532. /** @hidden */
  44533. _markAllSubMeshesAsMiscDirty(): void;
  44534. /**
  44535. * Instantiate a new istance of clear coat configuration.
  44536. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44537. */
  44538. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44539. /**
  44540. * Checks to see if a texture is used in the material.
  44541. * @param defines the list of "defines" to update.
  44542. */
  44543. prepareDefines(defines: IMaterialBRDFDefines): void;
  44544. /**
  44545. * Get the current class name of the texture useful for serialization or dynamic coding.
  44546. * @returns "PBRClearCoatConfiguration"
  44547. */
  44548. getClassName(): string;
  44549. /**
  44550. * Makes a duplicate of the current configuration into another one.
  44551. * @param brdfConfiguration define the config where to copy the info
  44552. */
  44553. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44554. /**
  44555. * Serializes this BRDF configuration.
  44556. * @returns - An object with the serialized config.
  44557. */
  44558. serialize(): any;
  44559. /**
  44560. * Parses a BRDF Configuration from a serialized object.
  44561. * @param source - Serialized object.
  44562. */
  44563. parse(source: any): void;
  44564. }
  44565. }
  44566. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44567. /** @hidden */
  44568. export var pbrFragmentDeclaration: {
  44569. name: string;
  44570. shader: string;
  44571. };
  44572. }
  44573. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44574. /** @hidden */
  44575. export var pbrUboDeclaration: {
  44576. name: string;
  44577. shader: string;
  44578. };
  44579. }
  44580. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44581. /** @hidden */
  44582. export var pbrFunctions: {
  44583. name: string;
  44584. shader: string;
  44585. };
  44586. }
  44587. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44588. /** @hidden */
  44589. export var harmonicsFunctions: {
  44590. name: string;
  44591. shader: string;
  44592. };
  44593. }
  44594. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  44595. /** @hidden */
  44596. export var pbrPreLightingFunctions: {
  44597. name: string;
  44598. shader: string;
  44599. };
  44600. }
  44601. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  44602. /** @hidden */
  44603. export var pbrFalloffLightingFunctions: {
  44604. name: string;
  44605. shader: string;
  44606. };
  44607. }
  44608. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  44609. /** @hidden */
  44610. export var pbrLightingFunctions: {
  44611. name: string;
  44612. shader: string;
  44613. };
  44614. }
  44615. declare module "babylonjs/Shaders/pbr.fragment" {
  44616. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44617. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44618. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44619. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44620. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44621. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44622. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44623. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44624. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44625. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44626. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44627. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  44628. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  44629. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  44630. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44631. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44632. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44633. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44634. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44635. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  44636. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  44637. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44638. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  44639. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44640. /** @hidden */
  44641. export var pbrPixelShader: {
  44642. name: string;
  44643. shader: string;
  44644. };
  44645. }
  44646. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  44647. /** @hidden */
  44648. export var pbrVertexDeclaration: {
  44649. name: string;
  44650. shader: string;
  44651. };
  44652. }
  44653. declare module "babylonjs/Shaders/pbr.vertex" {
  44654. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  44655. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44656. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44657. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44658. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44659. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44660. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  44661. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44662. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44663. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44664. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44665. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  44666. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  44667. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44668. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  44669. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44670. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44671. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  44672. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44673. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44674. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44675. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  44676. /** @hidden */
  44677. export var pbrVertexShader: {
  44678. name: string;
  44679. shader: string;
  44680. };
  44681. }
  44682. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  44683. import { IAnimatable } from "babylonjs/Misc/tools";
  44684. import { Nullable } from "babylonjs/types";
  44685. import { Scene } from "babylonjs/scene";
  44686. import { Matrix, Color3 } from "babylonjs/Maths/math";
  44687. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44688. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44689. import { Mesh } from "babylonjs/Meshes/mesh";
  44690. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  44691. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  44692. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  44693. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44694. import { Material } from "babylonjs/Materials/material";
  44695. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44696. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44697. import "babylonjs/Shaders/pbr.fragment";
  44698. import "babylonjs/Shaders/pbr.vertex";
  44699. /**
  44700. * The Physically based material base class of BJS.
  44701. *
  44702. * This offers the main features of a standard PBR material.
  44703. * For more information, please refer to the documentation :
  44704. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44705. */
  44706. export abstract class PBRBaseMaterial extends PushMaterial {
  44707. /**
  44708. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44709. */
  44710. static readonly PBRMATERIAL_OPAQUE: number;
  44711. /**
  44712. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44713. */
  44714. static readonly PBRMATERIAL_ALPHATEST: number;
  44715. /**
  44716. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44717. */
  44718. static readonly PBRMATERIAL_ALPHABLEND: number;
  44719. /**
  44720. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44721. * They are also discarded below the alpha cutoff threshold to improve performances.
  44722. */
  44723. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44724. /**
  44725. * Defines the default value of how much AO map is occluding the analytical lights
  44726. * (point spot...).
  44727. */
  44728. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44729. /**
  44730. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44731. */
  44732. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44733. /**
  44734. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44735. * to enhance interoperability with other engines.
  44736. */
  44737. static readonly LIGHTFALLOFF_GLTF: number;
  44738. /**
  44739. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44740. * to enhance interoperability with other materials.
  44741. */
  44742. static readonly LIGHTFALLOFF_STANDARD: number;
  44743. /**
  44744. * Intensity of the direct lights e.g. the four lights available in your scene.
  44745. * This impacts both the direct diffuse and specular highlights.
  44746. */
  44747. protected _directIntensity: number;
  44748. /**
  44749. * Intensity of the emissive part of the material.
  44750. * This helps controlling the emissive effect without modifying the emissive color.
  44751. */
  44752. protected _emissiveIntensity: number;
  44753. /**
  44754. * Intensity of the environment e.g. how much the environment will light the object
  44755. * either through harmonics for rough material or through the refelction for shiny ones.
  44756. */
  44757. protected _environmentIntensity: number;
  44758. /**
  44759. * This is a special control allowing the reduction of the specular highlights coming from the
  44760. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44761. */
  44762. protected _specularIntensity: number;
  44763. /**
  44764. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44765. */
  44766. private _lightingInfos;
  44767. /**
  44768. * Debug Control allowing disabling the bump map on this material.
  44769. */
  44770. protected _disableBumpMap: boolean;
  44771. /**
  44772. * AKA Diffuse Texture in standard nomenclature.
  44773. */
  44774. protected _albedoTexture: BaseTexture;
  44775. /**
  44776. * AKA Occlusion Texture in other nomenclature.
  44777. */
  44778. protected _ambientTexture: BaseTexture;
  44779. /**
  44780. * AKA Occlusion Texture Intensity in other nomenclature.
  44781. */
  44782. protected _ambientTextureStrength: number;
  44783. /**
  44784. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44785. * 1 means it completely occludes it
  44786. * 0 mean it has no impact
  44787. */
  44788. protected _ambientTextureImpactOnAnalyticalLights: number;
  44789. /**
  44790. * Stores the alpha values in a texture.
  44791. */
  44792. protected _opacityTexture: BaseTexture;
  44793. /**
  44794. * Stores the reflection values in a texture.
  44795. */
  44796. protected _reflectionTexture: BaseTexture;
  44797. /**
  44798. * Stores the refraction values in a texture.
  44799. */
  44800. protected _refractionTexture: BaseTexture;
  44801. /**
  44802. * Stores the emissive values in a texture.
  44803. */
  44804. protected _emissiveTexture: BaseTexture;
  44805. /**
  44806. * AKA Specular texture in other nomenclature.
  44807. */
  44808. protected _reflectivityTexture: BaseTexture;
  44809. /**
  44810. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44811. */
  44812. protected _metallicTexture: BaseTexture;
  44813. /**
  44814. * Specifies the metallic scalar of the metallic/roughness workflow.
  44815. * Can also be used to scale the metalness values of the metallic texture.
  44816. */
  44817. protected _metallic: Nullable<number>;
  44818. /**
  44819. * Specifies the roughness scalar of the metallic/roughness workflow.
  44820. * Can also be used to scale the roughness values of the metallic texture.
  44821. */
  44822. protected _roughness: Nullable<number>;
  44823. /**
  44824. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44825. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44826. */
  44827. protected _microSurfaceTexture: BaseTexture;
  44828. /**
  44829. * Stores surface normal data used to displace a mesh in a texture.
  44830. */
  44831. protected _bumpTexture: BaseTexture;
  44832. /**
  44833. * Stores the pre-calculated light information of a mesh in a texture.
  44834. */
  44835. protected _lightmapTexture: BaseTexture;
  44836. /**
  44837. * The color of a material in ambient lighting.
  44838. */
  44839. protected _ambientColor: Color3;
  44840. /**
  44841. * AKA Diffuse Color in other nomenclature.
  44842. */
  44843. protected _albedoColor: Color3;
  44844. /**
  44845. * AKA Specular Color in other nomenclature.
  44846. */
  44847. protected _reflectivityColor: Color3;
  44848. /**
  44849. * The color applied when light is reflected from a material.
  44850. */
  44851. protected _reflectionColor: Color3;
  44852. /**
  44853. * The color applied when light is emitted from a material.
  44854. */
  44855. protected _emissiveColor: Color3;
  44856. /**
  44857. * AKA Glossiness in other nomenclature.
  44858. */
  44859. protected _microSurface: number;
  44860. /**
  44861. * source material index of refraction (IOR)' / 'destination material IOR.
  44862. */
  44863. protected _indexOfRefraction: number;
  44864. /**
  44865. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44866. */
  44867. protected _invertRefractionY: boolean;
  44868. /**
  44869. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44870. * Materials half opaque for instance using refraction could benefit from this control.
  44871. */
  44872. protected _linkRefractionWithTransparency: boolean;
  44873. /**
  44874. * Specifies that the material will use the light map as a show map.
  44875. */
  44876. protected _useLightmapAsShadowmap: boolean;
  44877. /**
  44878. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44879. * makes the reflect vector face the model (under horizon).
  44880. */
  44881. protected _useHorizonOcclusion: boolean;
  44882. /**
  44883. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44884. * too much the area relying on ambient texture to define their ambient occlusion.
  44885. */
  44886. protected _useRadianceOcclusion: boolean;
  44887. /**
  44888. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44889. */
  44890. protected _useAlphaFromAlbedoTexture: boolean;
  44891. /**
  44892. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44893. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44894. */
  44895. protected _useSpecularOverAlpha: boolean;
  44896. /**
  44897. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44898. */
  44899. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44900. /**
  44901. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44902. */
  44903. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44904. /**
  44905. * Specifies if the metallic texture contains the roughness information in its green channel.
  44906. */
  44907. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44908. /**
  44909. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44910. */
  44911. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44912. /**
  44913. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44914. */
  44915. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44916. /**
  44917. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44918. */
  44919. protected _useAmbientInGrayScale: boolean;
  44920. /**
  44921. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44922. * The material will try to infer what glossiness each pixel should be.
  44923. */
  44924. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44925. /**
  44926. * Defines the falloff type used in this material.
  44927. * It by default is Physical.
  44928. */
  44929. protected _lightFalloff: number;
  44930. /**
  44931. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44932. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44933. */
  44934. protected _useRadianceOverAlpha: boolean;
  44935. /**
  44936. * Allows using an object space normal map (instead of tangent space).
  44937. */
  44938. protected _useObjectSpaceNormalMap: boolean;
  44939. /**
  44940. * Allows using the bump map in parallax mode.
  44941. */
  44942. protected _useParallax: boolean;
  44943. /**
  44944. * Allows using the bump map in parallax occlusion mode.
  44945. */
  44946. protected _useParallaxOcclusion: boolean;
  44947. /**
  44948. * Controls the scale bias of the parallax mode.
  44949. */
  44950. protected _parallaxScaleBias: number;
  44951. /**
  44952. * If sets to true, disables all the lights affecting the material.
  44953. */
  44954. protected _disableLighting: boolean;
  44955. /**
  44956. * Number of Simultaneous lights allowed on the material.
  44957. */
  44958. protected _maxSimultaneousLights: number;
  44959. /**
  44960. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44961. */
  44962. protected _invertNormalMapX: boolean;
  44963. /**
  44964. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44965. */
  44966. protected _invertNormalMapY: boolean;
  44967. /**
  44968. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44969. */
  44970. protected _twoSidedLighting: boolean;
  44971. /**
  44972. * Defines the alpha limits in alpha test mode.
  44973. */
  44974. protected _alphaCutOff: number;
  44975. /**
  44976. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44977. */
  44978. protected _forceAlphaTest: boolean;
  44979. /**
  44980. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44981. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44982. */
  44983. protected _useAlphaFresnel: boolean;
  44984. /**
  44985. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44986. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44987. */
  44988. protected _useLinearAlphaFresnel: boolean;
  44989. /**
  44990. * The transparency mode of the material.
  44991. */
  44992. protected _transparencyMode: Nullable<number>;
  44993. /**
  44994. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44995. * from cos thetav and roughness:
  44996. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44997. */
  44998. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44999. /**
  45000. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45001. */
  45002. protected _forceIrradianceInFragment: boolean;
  45003. /**
  45004. * Force normal to face away from face.
  45005. */
  45006. protected _forceNormalForward: boolean;
  45007. /**
  45008. * Enables specular anti aliasing in the PBR shader.
  45009. * It will both interacts on the Geometry for analytical and IBL lighting.
  45010. * It also prefilter the roughness map based on the bump values.
  45011. */
  45012. protected _enableSpecularAntiAliasing: boolean;
  45013. /**
  45014. * Default configuration related to image processing available in the PBR Material.
  45015. */
  45016. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45017. /**
  45018. * Keep track of the image processing observer to allow dispose and replace.
  45019. */
  45020. private _imageProcessingObserver;
  45021. /**
  45022. * Attaches a new image processing configuration to the PBR Material.
  45023. * @param configuration
  45024. */
  45025. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45026. /**
  45027. * Stores the available render targets.
  45028. */
  45029. private _renderTargets;
  45030. /**
  45031. * Sets the global ambient color for the material used in lighting calculations.
  45032. */
  45033. private _globalAmbientColor;
  45034. /**
  45035. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45036. */
  45037. private _useLogarithmicDepth;
  45038. /**
  45039. * If set to true, no lighting calculations will be applied.
  45040. */
  45041. private _unlit;
  45042. /**
  45043. * Defines the clear coat layer parameters for the material.
  45044. */
  45045. readonly clearCoat: PBRClearCoatConfiguration;
  45046. /**
  45047. * Defines the anisotropic parameters for the material.
  45048. */
  45049. readonly anisotropy: PBRAnisotropicConfiguration;
  45050. /**
  45051. * Defines the BRDF parameters for the material.
  45052. */
  45053. readonly brdf: PBRBRDFConfiguration;
  45054. /**
  45055. * Instantiates a new PBRMaterial instance.
  45056. *
  45057. * @param name The material name
  45058. * @param scene The scene the material will be use in.
  45059. */
  45060. constructor(name: string, scene: Scene);
  45061. /**
  45062. * Gets a boolean indicating that current material needs to register RTT
  45063. */
  45064. readonly hasRenderTargetTextures: boolean;
  45065. /**
  45066. * Gets the name of the material class.
  45067. */
  45068. getClassName(): string;
  45069. /**
  45070. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45071. */
  45072. /**
  45073. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45074. */
  45075. useLogarithmicDepth: boolean;
  45076. /**
  45077. * Gets the current transparency mode.
  45078. */
  45079. /**
  45080. * Sets the transparency mode of the material.
  45081. *
  45082. * | Value | Type | Description |
  45083. * | ----- | ----------------------------------- | ----------- |
  45084. * | 0 | OPAQUE | |
  45085. * | 1 | ALPHATEST | |
  45086. * | 2 | ALPHABLEND | |
  45087. * | 3 | ALPHATESTANDBLEND | |
  45088. *
  45089. */
  45090. transparencyMode: Nullable<number>;
  45091. /**
  45092. * Returns true if alpha blending should be disabled.
  45093. */
  45094. private readonly _disableAlphaBlending;
  45095. /**
  45096. * Specifies whether or not this material should be rendered in alpha blend mode.
  45097. */
  45098. needAlphaBlending(): boolean;
  45099. /**
  45100. * Specifies if the mesh will require alpha blending.
  45101. * @param mesh - BJS mesh.
  45102. */
  45103. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45104. /**
  45105. * Specifies whether or not this material should be rendered in alpha test mode.
  45106. */
  45107. needAlphaTesting(): boolean;
  45108. /**
  45109. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45110. */
  45111. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45112. /**
  45113. * Gets the texture used for the alpha test.
  45114. */
  45115. getAlphaTestTexture(): BaseTexture;
  45116. /**
  45117. * Specifies that the submesh is ready to be used.
  45118. * @param mesh - BJS mesh.
  45119. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45120. * @param useInstances - Specifies that instances should be used.
  45121. * @returns - boolean indicating that the submesh is ready or not.
  45122. */
  45123. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45124. /**
  45125. * Specifies if the material uses metallic roughness workflow.
  45126. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45127. */
  45128. isMetallicWorkflow(): boolean;
  45129. private _prepareEffect;
  45130. private _prepareDefines;
  45131. /**
  45132. * Force shader compilation
  45133. */
  45134. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45135. clipPlane: boolean;
  45136. }>): void;
  45137. /**
  45138. * Initializes the uniform buffer layout for the shader.
  45139. */
  45140. buildUniformLayout(): void;
  45141. /**
  45142. * Unbinds the textures.
  45143. */
  45144. unbind(): void;
  45145. /**
  45146. * Binds the submesh data.
  45147. * @param world - The world matrix.
  45148. * @param mesh - The BJS mesh.
  45149. * @param subMesh - A submesh of the BJS mesh.
  45150. */
  45151. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45152. /**
  45153. * Returns the animatable textures.
  45154. * @returns - Array of animatable textures.
  45155. */
  45156. getAnimatables(): IAnimatable[];
  45157. /**
  45158. * Returns the texture used for reflections.
  45159. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45160. */
  45161. private _getReflectionTexture;
  45162. /**
  45163. * Returns the texture used for refraction or null if none is used.
  45164. * @returns - Refection texture if present. If no refraction texture and refraction
  45165. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45166. */
  45167. private _getRefractionTexture;
  45168. /**
  45169. * Returns an array of the actively used textures.
  45170. * @returns - Array of BaseTextures
  45171. */
  45172. getActiveTextures(): BaseTexture[];
  45173. /**
  45174. * Checks to see if a texture is used in the material.
  45175. * @param texture - Base texture to use.
  45176. * @returns - Boolean specifying if a texture is used in the material.
  45177. */
  45178. hasTexture(texture: BaseTexture): boolean;
  45179. /**
  45180. * Disposes the resources of the material.
  45181. * @param forceDisposeEffect - Forces the disposal of effects.
  45182. * @param forceDisposeTextures - Forces the disposal of all textures.
  45183. */
  45184. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45185. }
  45186. }
  45187. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45188. import { Nullable } from "babylonjs/types";
  45189. import { Scene } from "babylonjs/scene";
  45190. import { Color3 } from "babylonjs/Maths/math";
  45191. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45192. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45194. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45195. /**
  45196. * The Physically based material of BJS.
  45197. *
  45198. * This offers the main features of a standard PBR material.
  45199. * For more information, please refer to the documentation :
  45200. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45201. */
  45202. export class PBRMaterial extends PBRBaseMaterial {
  45203. /**
  45204. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45205. */
  45206. static readonly PBRMATERIAL_OPAQUE: number;
  45207. /**
  45208. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45209. */
  45210. static readonly PBRMATERIAL_ALPHATEST: number;
  45211. /**
  45212. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45213. */
  45214. static readonly PBRMATERIAL_ALPHABLEND: number;
  45215. /**
  45216. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45217. * They are also discarded below the alpha cutoff threshold to improve performances.
  45218. */
  45219. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45220. /**
  45221. * Defines the default value of how much AO map is occluding the analytical lights
  45222. * (point spot...).
  45223. */
  45224. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45225. /**
  45226. * Intensity of the direct lights e.g. the four lights available in your scene.
  45227. * This impacts both the direct diffuse and specular highlights.
  45228. */
  45229. directIntensity: number;
  45230. /**
  45231. * Intensity of the emissive part of the material.
  45232. * This helps controlling the emissive effect without modifying the emissive color.
  45233. */
  45234. emissiveIntensity: number;
  45235. /**
  45236. * Intensity of the environment e.g. how much the environment will light the object
  45237. * either through harmonics for rough material or through the refelction for shiny ones.
  45238. */
  45239. environmentIntensity: number;
  45240. /**
  45241. * This is a special control allowing the reduction of the specular highlights coming from the
  45242. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45243. */
  45244. specularIntensity: number;
  45245. /**
  45246. * Debug Control allowing disabling the bump map on this material.
  45247. */
  45248. disableBumpMap: boolean;
  45249. /**
  45250. * AKA Diffuse Texture in standard nomenclature.
  45251. */
  45252. albedoTexture: BaseTexture;
  45253. /**
  45254. * AKA Occlusion Texture in other nomenclature.
  45255. */
  45256. ambientTexture: BaseTexture;
  45257. /**
  45258. * AKA Occlusion Texture Intensity in other nomenclature.
  45259. */
  45260. ambientTextureStrength: number;
  45261. /**
  45262. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45263. * 1 means it completely occludes it
  45264. * 0 mean it has no impact
  45265. */
  45266. ambientTextureImpactOnAnalyticalLights: number;
  45267. /**
  45268. * Stores the alpha values in a texture.
  45269. */
  45270. opacityTexture: BaseTexture;
  45271. /**
  45272. * Stores the reflection values in a texture.
  45273. */
  45274. reflectionTexture: Nullable<BaseTexture>;
  45275. /**
  45276. * Stores the emissive values in a texture.
  45277. */
  45278. emissiveTexture: BaseTexture;
  45279. /**
  45280. * AKA Specular texture in other nomenclature.
  45281. */
  45282. reflectivityTexture: BaseTexture;
  45283. /**
  45284. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45285. */
  45286. metallicTexture: BaseTexture;
  45287. /**
  45288. * Specifies the metallic scalar of the metallic/roughness workflow.
  45289. * Can also be used to scale the metalness values of the metallic texture.
  45290. */
  45291. metallic: Nullable<number>;
  45292. /**
  45293. * Specifies the roughness scalar of the metallic/roughness workflow.
  45294. * Can also be used to scale the roughness values of the metallic texture.
  45295. */
  45296. roughness: Nullable<number>;
  45297. /**
  45298. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45299. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45300. */
  45301. microSurfaceTexture: BaseTexture;
  45302. /**
  45303. * Stores surface normal data used to displace a mesh in a texture.
  45304. */
  45305. bumpTexture: BaseTexture;
  45306. /**
  45307. * Stores the pre-calculated light information of a mesh in a texture.
  45308. */
  45309. lightmapTexture: BaseTexture;
  45310. /**
  45311. * Stores the refracted light information in a texture.
  45312. */
  45313. refractionTexture: BaseTexture;
  45314. /**
  45315. * The color of a material in ambient lighting.
  45316. */
  45317. ambientColor: Color3;
  45318. /**
  45319. * AKA Diffuse Color in other nomenclature.
  45320. */
  45321. albedoColor: Color3;
  45322. /**
  45323. * AKA Specular Color in other nomenclature.
  45324. */
  45325. reflectivityColor: Color3;
  45326. /**
  45327. * The color reflected from the material.
  45328. */
  45329. reflectionColor: Color3;
  45330. /**
  45331. * The color emitted from the material.
  45332. */
  45333. emissiveColor: Color3;
  45334. /**
  45335. * AKA Glossiness in other nomenclature.
  45336. */
  45337. microSurface: number;
  45338. /**
  45339. * source material index of refraction (IOR)' / 'destination material IOR.
  45340. */
  45341. indexOfRefraction: number;
  45342. /**
  45343. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45344. */
  45345. invertRefractionY: boolean;
  45346. /**
  45347. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45348. * Materials half opaque for instance using refraction could benefit from this control.
  45349. */
  45350. linkRefractionWithTransparency: boolean;
  45351. /**
  45352. * If true, the light map contains occlusion information instead of lighting info.
  45353. */
  45354. useLightmapAsShadowmap: boolean;
  45355. /**
  45356. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45357. */
  45358. useAlphaFromAlbedoTexture: boolean;
  45359. /**
  45360. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45361. */
  45362. forceAlphaTest: boolean;
  45363. /**
  45364. * Defines the alpha limits in alpha test mode.
  45365. */
  45366. alphaCutOff: number;
  45367. /**
  45368. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45369. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45370. */
  45371. useSpecularOverAlpha: boolean;
  45372. /**
  45373. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45374. */
  45375. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45376. /**
  45377. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45378. */
  45379. useRoughnessFromMetallicTextureAlpha: boolean;
  45380. /**
  45381. * Specifies if the metallic texture contains the roughness information in its green channel.
  45382. */
  45383. useRoughnessFromMetallicTextureGreen: boolean;
  45384. /**
  45385. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45386. */
  45387. useMetallnessFromMetallicTextureBlue: boolean;
  45388. /**
  45389. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45390. */
  45391. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45392. /**
  45393. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45394. */
  45395. useAmbientInGrayScale: boolean;
  45396. /**
  45397. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45398. * The material will try to infer what glossiness each pixel should be.
  45399. */
  45400. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45401. /**
  45402. * BJS is using an harcoded light falloff based on a manually sets up range.
  45403. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45404. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45405. */
  45406. /**
  45407. * BJS is using an harcoded light falloff based on a manually sets up range.
  45408. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45409. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45410. */
  45411. usePhysicalLightFalloff: boolean;
  45412. /**
  45413. * In order to support the falloff compatibility with gltf, a special mode has been added
  45414. * to reproduce the gltf light falloff.
  45415. */
  45416. /**
  45417. * In order to support the falloff compatibility with gltf, a special mode has been added
  45418. * to reproduce the gltf light falloff.
  45419. */
  45420. useGLTFLightFalloff: boolean;
  45421. /**
  45422. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45423. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45424. */
  45425. useRadianceOverAlpha: boolean;
  45426. /**
  45427. * Allows using an object space normal map (instead of tangent space).
  45428. */
  45429. useObjectSpaceNormalMap: boolean;
  45430. /**
  45431. * Allows using the bump map in parallax mode.
  45432. */
  45433. useParallax: boolean;
  45434. /**
  45435. * Allows using the bump map in parallax occlusion mode.
  45436. */
  45437. useParallaxOcclusion: boolean;
  45438. /**
  45439. * Controls the scale bias of the parallax mode.
  45440. */
  45441. parallaxScaleBias: number;
  45442. /**
  45443. * If sets to true, disables all the lights affecting the material.
  45444. */
  45445. disableLighting: boolean;
  45446. /**
  45447. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45448. */
  45449. forceIrradianceInFragment: boolean;
  45450. /**
  45451. * Number of Simultaneous lights allowed on the material.
  45452. */
  45453. maxSimultaneousLights: number;
  45454. /**
  45455. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45456. */
  45457. invertNormalMapX: boolean;
  45458. /**
  45459. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45460. */
  45461. invertNormalMapY: boolean;
  45462. /**
  45463. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45464. */
  45465. twoSidedLighting: boolean;
  45466. /**
  45467. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45468. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45469. */
  45470. useAlphaFresnel: boolean;
  45471. /**
  45472. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45473. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45474. */
  45475. useLinearAlphaFresnel: boolean;
  45476. /**
  45477. * Let user defines the brdf lookup texture used for IBL.
  45478. * A default 8bit version is embedded but you could point at :
  45479. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45480. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45481. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45482. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45483. */
  45484. environmentBRDFTexture: Nullable<BaseTexture>;
  45485. /**
  45486. * Force normal to face away from face.
  45487. */
  45488. forceNormalForward: boolean;
  45489. /**
  45490. * Enables specular anti aliasing in the PBR shader.
  45491. * It will both interacts on the Geometry for analytical and IBL lighting.
  45492. * It also prefilter the roughness map based on the bump values.
  45493. */
  45494. enableSpecularAntiAliasing: boolean;
  45495. /**
  45496. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45497. * makes the reflect vector face the model (under horizon).
  45498. */
  45499. useHorizonOcclusion: boolean;
  45500. /**
  45501. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45502. * too much the area relying on ambient texture to define their ambient occlusion.
  45503. */
  45504. useRadianceOcclusion: boolean;
  45505. /**
  45506. * If set to true, no lighting calculations will be applied.
  45507. */
  45508. unlit: boolean;
  45509. /**
  45510. * Gets the image processing configuration used either in this material.
  45511. */
  45512. /**
  45513. * Sets the Default image processing configuration used either in the this material.
  45514. *
  45515. * If sets to null, the scene one is in use.
  45516. */
  45517. imageProcessingConfiguration: ImageProcessingConfiguration;
  45518. /**
  45519. * Gets wether the color curves effect is enabled.
  45520. */
  45521. /**
  45522. * Sets wether the color curves effect is enabled.
  45523. */
  45524. cameraColorCurvesEnabled: boolean;
  45525. /**
  45526. * Gets wether the color grading effect is enabled.
  45527. */
  45528. /**
  45529. * Gets wether the color grading effect is enabled.
  45530. */
  45531. cameraColorGradingEnabled: boolean;
  45532. /**
  45533. * Gets wether tonemapping is enabled or not.
  45534. */
  45535. /**
  45536. * Sets wether tonemapping is enabled or not
  45537. */
  45538. cameraToneMappingEnabled: boolean;
  45539. /**
  45540. * The camera exposure used on this material.
  45541. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45542. * This corresponds to a photographic exposure.
  45543. */
  45544. /**
  45545. * The camera exposure used on this material.
  45546. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45547. * This corresponds to a photographic exposure.
  45548. */
  45549. cameraExposure: number;
  45550. /**
  45551. * Gets The camera contrast used on this material.
  45552. */
  45553. /**
  45554. * Sets The camera contrast used on this material.
  45555. */
  45556. cameraContrast: number;
  45557. /**
  45558. * Gets the Color Grading 2D Lookup Texture.
  45559. */
  45560. /**
  45561. * Sets the Color Grading 2D Lookup Texture.
  45562. */
  45563. cameraColorGradingTexture: Nullable<BaseTexture>;
  45564. /**
  45565. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45566. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45567. * 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;
  45568. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45569. */
  45570. /**
  45571. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45572. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45573. * 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;
  45574. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45575. */
  45576. cameraColorCurves: Nullable<ColorCurves>;
  45577. /**
  45578. * Instantiates a new PBRMaterial instance.
  45579. *
  45580. * @param name The material name
  45581. * @param scene The scene the material will be use in.
  45582. */
  45583. constructor(name: string, scene: Scene);
  45584. /**
  45585. * Returns the name of this material class.
  45586. */
  45587. getClassName(): string;
  45588. /**
  45589. * Makes a duplicate of the current material.
  45590. * @param name - name to use for the new material.
  45591. */
  45592. clone(name: string): PBRMaterial;
  45593. /**
  45594. * Serializes this PBR Material.
  45595. * @returns - An object with the serialized material.
  45596. */
  45597. serialize(): any;
  45598. /**
  45599. * Parses a PBR Material from a serialized object.
  45600. * @param source - Serialized object.
  45601. * @param scene - BJS scene instance.
  45602. * @param rootUrl - url for the scene object
  45603. * @returns - PBRMaterial
  45604. */
  45605. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45606. }
  45607. }
  45608. declare module "babylonjs/Helpers/sceneHelpers" {
  45609. import { Nullable } from "babylonjs/types";
  45610. import { Mesh } from "babylonjs/Meshes/mesh";
  45611. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45612. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  45613. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45614. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  45615. import "babylonjs/Meshes/Builders/boxBuilder";
  45616. /** @hidden */
  45617. export var _forceSceneHelpersToBundle: boolean;
  45618. module "babylonjs/scene" {
  45619. interface Scene {
  45620. /**
  45621. * Creates a default light for the scene.
  45622. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45623. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45624. */
  45625. createDefaultLight(replace?: boolean): void;
  45626. /**
  45627. * Creates a default camera for the scene.
  45628. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45629. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45630. * @param replace has default false, when true replaces the active camera in the scene
  45631. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45632. */
  45633. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45634. /**
  45635. * Creates a default camera and a default light.
  45636. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45637. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45638. * @param replace has the default false, when true replaces the active camera/light in the scene
  45639. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45640. */
  45641. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45642. /**
  45643. * Creates a new sky box
  45644. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45645. * @param environmentTexture defines the texture to use as environment texture
  45646. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45647. * @param scale defines the overall scale of the skybox
  45648. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45649. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45650. * @returns a new mesh holding the sky box
  45651. */
  45652. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45653. /**
  45654. * Creates a new environment
  45655. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45656. * @param options defines the options you can use to configure the environment
  45657. * @returns the new EnvironmentHelper
  45658. */
  45659. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45660. /**
  45661. * Creates a new VREXperienceHelper
  45662. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45663. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45664. * @returns a new VREXperienceHelper
  45665. */
  45666. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45667. /**
  45668. * Creates a new XREXperienceHelper
  45669. * @see http://doc.babylonjs.com/how_to/webxr
  45670. * @returns a promise for a new XREXperienceHelper
  45671. */
  45672. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45673. }
  45674. }
  45675. }
  45676. declare module "babylonjs/Helpers/videoDome" {
  45677. import { Scene } from "babylonjs/scene";
  45678. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45679. import { Mesh } from "babylonjs/Meshes/mesh";
  45680. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  45681. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45682. import "babylonjs/Meshes/Builders/sphereBuilder";
  45683. /**
  45684. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45685. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45686. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45687. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45688. */
  45689. export class VideoDome extends TransformNode {
  45690. /**
  45691. * Define the video source as a Monoscopic panoramic 360 video.
  45692. */
  45693. static readonly MODE_MONOSCOPIC: number;
  45694. /**
  45695. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45696. */
  45697. static readonly MODE_TOPBOTTOM: number;
  45698. /**
  45699. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45700. */
  45701. static readonly MODE_SIDEBYSIDE: number;
  45702. private _useDirectMapping;
  45703. /**
  45704. * The video texture being displayed on the sphere
  45705. */
  45706. protected _videoTexture: VideoTexture;
  45707. /**
  45708. * Gets the video texture being displayed on the sphere
  45709. */
  45710. readonly videoTexture: VideoTexture;
  45711. /**
  45712. * The skybox material
  45713. */
  45714. protected _material: BackgroundMaterial;
  45715. /**
  45716. * The surface used for the skybox
  45717. */
  45718. protected _mesh: Mesh;
  45719. /**
  45720. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45721. * Also see the options.resolution property.
  45722. */
  45723. fovMultiplier: number;
  45724. private _videoMode;
  45725. /**
  45726. * Gets or set the current video mode for the video. It can be:
  45727. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45728. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45729. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45730. */
  45731. videoMode: number;
  45732. /**
  45733. * Oberserver used in Stereoscopic VR Mode.
  45734. */
  45735. private _onBeforeCameraRenderObserver;
  45736. /**
  45737. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45738. * @param name Element's name, child elements will append suffixes for their own names.
  45739. * @param urlsOrVideo defines the url(s) or the video element to use
  45740. * @param options An object containing optional or exposed sub element properties
  45741. */
  45742. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45743. resolution?: number;
  45744. clickToPlay?: boolean;
  45745. autoPlay?: boolean;
  45746. loop?: boolean;
  45747. size?: number;
  45748. poster?: string;
  45749. useDirectMapping?: boolean;
  45750. }, scene: Scene);
  45751. private _changeVideoMode;
  45752. /**
  45753. * Releases resources associated with this node.
  45754. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45755. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45756. */
  45757. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45758. }
  45759. }
  45760. declare module "babylonjs/Helpers/index" {
  45761. export * from "babylonjs/Helpers/environmentHelper";
  45762. export * from "babylonjs/Helpers/photoDome";
  45763. export * from "babylonjs/Helpers/sceneHelpers";
  45764. export * from "babylonjs/Helpers/videoDome";
  45765. }
  45766. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  45767. import { PerfCounter } from "babylonjs/Misc/tools";
  45768. import { IDisposable } from "babylonjs/scene";
  45769. import { Engine } from "babylonjs/Engines/engine";
  45770. /**
  45771. * This class can be used to get instrumentation data from a Babylon engine
  45772. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45773. */
  45774. export class EngineInstrumentation implements IDisposable {
  45775. /**
  45776. * Define the instrumented engine.
  45777. */
  45778. engine: Engine;
  45779. private _captureGPUFrameTime;
  45780. private _gpuFrameTimeToken;
  45781. private _gpuFrameTime;
  45782. private _captureShaderCompilationTime;
  45783. private _shaderCompilationTime;
  45784. private _onBeginFrameObserver;
  45785. private _onEndFrameObserver;
  45786. private _onBeforeShaderCompilationObserver;
  45787. private _onAfterShaderCompilationObserver;
  45788. /**
  45789. * Gets the perf counter used for GPU frame time
  45790. */
  45791. readonly gpuFrameTimeCounter: PerfCounter;
  45792. /**
  45793. * Gets the GPU frame time capture status
  45794. */
  45795. /**
  45796. * Enable or disable the GPU frame time capture
  45797. */
  45798. captureGPUFrameTime: boolean;
  45799. /**
  45800. * Gets the perf counter used for shader compilation time
  45801. */
  45802. readonly shaderCompilationTimeCounter: PerfCounter;
  45803. /**
  45804. * Gets the shader compilation time capture status
  45805. */
  45806. /**
  45807. * Enable or disable the shader compilation time capture
  45808. */
  45809. captureShaderCompilationTime: boolean;
  45810. /**
  45811. * Instantiates a new engine instrumentation.
  45812. * This class can be used to get instrumentation data from a Babylon engine
  45813. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45814. * @param engine Defines the engine to instrument
  45815. */
  45816. constructor(
  45817. /**
  45818. * Define the instrumented engine.
  45819. */
  45820. engine: Engine);
  45821. /**
  45822. * Dispose and release associated resources.
  45823. */
  45824. dispose(): void;
  45825. }
  45826. }
  45827. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  45828. import { PerfCounter } from "babylonjs/Misc/tools";
  45829. import { Scene, IDisposable } from "babylonjs/scene";
  45830. /**
  45831. * This class can be used to get instrumentation data from a Babylon engine
  45832. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45833. */
  45834. export class SceneInstrumentation implements IDisposable {
  45835. /**
  45836. * Defines the scene to instrument
  45837. */
  45838. scene: Scene;
  45839. private _captureActiveMeshesEvaluationTime;
  45840. private _activeMeshesEvaluationTime;
  45841. private _captureRenderTargetsRenderTime;
  45842. private _renderTargetsRenderTime;
  45843. private _captureFrameTime;
  45844. private _frameTime;
  45845. private _captureRenderTime;
  45846. private _renderTime;
  45847. private _captureInterFrameTime;
  45848. private _interFrameTime;
  45849. private _captureParticlesRenderTime;
  45850. private _particlesRenderTime;
  45851. private _captureSpritesRenderTime;
  45852. private _spritesRenderTime;
  45853. private _capturePhysicsTime;
  45854. private _physicsTime;
  45855. private _captureAnimationsTime;
  45856. private _animationsTime;
  45857. private _captureCameraRenderTime;
  45858. private _cameraRenderTime;
  45859. private _onBeforeActiveMeshesEvaluationObserver;
  45860. private _onAfterActiveMeshesEvaluationObserver;
  45861. private _onBeforeRenderTargetsRenderObserver;
  45862. private _onAfterRenderTargetsRenderObserver;
  45863. private _onAfterRenderObserver;
  45864. private _onBeforeDrawPhaseObserver;
  45865. private _onAfterDrawPhaseObserver;
  45866. private _onBeforeAnimationsObserver;
  45867. private _onBeforeParticlesRenderingObserver;
  45868. private _onAfterParticlesRenderingObserver;
  45869. private _onBeforeSpritesRenderingObserver;
  45870. private _onAfterSpritesRenderingObserver;
  45871. private _onBeforePhysicsObserver;
  45872. private _onAfterPhysicsObserver;
  45873. private _onAfterAnimationsObserver;
  45874. private _onBeforeCameraRenderObserver;
  45875. private _onAfterCameraRenderObserver;
  45876. /**
  45877. * Gets the perf counter used for active meshes evaluation time
  45878. */
  45879. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45880. /**
  45881. * Gets the active meshes evaluation time capture status
  45882. */
  45883. /**
  45884. * Enable or disable the active meshes evaluation time capture
  45885. */
  45886. captureActiveMeshesEvaluationTime: boolean;
  45887. /**
  45888. * Gets the perf counter used for render targets render time
  45889. */
  45890. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45891. /**
  45892. * Gets the render targets render time capture status
  45893. */
  45894. /**
  45895. * Enable or disable the render targets render time capture
  45896. */
  45897. captureRenderTargetsRenderTime: boolean;
  45898. /**
  45899. * Gets the perf counter used for particles render time
  45900. */
  45901. readonly particlesRenderTimeCounter: PerfCounter;
  45902. /**
  45903. * Gets the particles render time capture status
  45904. */
  45905. /**
  45906. * Enable or disable the particles render time capture
  45907. */
  45908. captureParticlesRenderTime: boolean;
  45909. /**
  45910. * Gets the perf counter used for sprites render time
  45911. */
  45912. readonly spritesRenderTimeCounter: PerfCounter;
  45913. /**
  45914. * Gets the sprites render time capture status
  45915. */
  45916. /**
  45917. * Enable or disable the sprites render time capture
  45918. */
  45919. captureSpritesRenderTime: boolean;
  45920. /**
  45921. * Gets the perf counter used for physics time
  45922. */
  45923. readonly physicsTimeCounter: PerfCounter;
  45924. /**
  45925. * Gets the physics time capture status
  45926. */
  45927. /**
  45928. * Enable or disable the physics time capture
  45929. */
  45930. capturePhysicsTime: boolean;
  45931. /**
  45932. * Gets the perf counter used for animations time
  45933. */
  45934. readonly animationsTimeCounter: PerfCounter;
  45935. /**
  45936. * Gets the animations time capture status
  45937. */
  45938. /**
  45939. * Enable or disable the animations time capture
  45940. */
  45941. captureAnimationsTime: boolean;
  45942. /**
  45943. * Gets the perf counter used for frame time capture
  45944. */
  45945. readonly frameTimeCounter: PerfCounter;
  45946. /**
  45947. * Gets the frame time capture status
  45948. */
  45949. /**
  45950. * Enable or disable the frame time capture
  45951. */
  45952. captureFrameTime: boolean;
  45953. /**
  45954. * Gets the perf counter used for inter-frames time capture
  45955. */
  45956. readonly interFrameTimeCounter: PerfCounter;
  45957. /**
  45958. * Gets the inter-frames time capture status
  45959. */
  45960. /**
  45961. * Enable or disable the inter-frames time capture
  45962. */
  45963. captureInterFrameTime: boolean;
  45964. /**
  45965. * Gets the perf counter used for render time capture
  45966. */
  45967. readonly renderTimeCounter: PerfCounter;
  45968. /**
  45969. * Gets the render time capture status
  45970. */
  45971. /**
  45972. * Enable or disable the render time capture
  45973. */
  45974. captureRenderTime: boolean;
  45975. /**
  45976. * Gets the perf counter used for camera render time capture
  45977. */
  45978. readonly cameraRenderTimeCounter: PerfCounter;
  45979. /**
  45980. * Gets the camera render time capture status
  45981. */
  45982. /**
  45983. * Enable or disable the camera render time capture
  45984. */
  45985. captureCameraRenderTime: boolean;
  45986. /**
  45987. * Gets the perf counter used for draw calls
  45988. */
  45989. readonly drawCallsCounter: PerfCounter;
  45990. /**
  45991. * Gets the perf counter used for texture collisions
  45992. */
  45993. readonly textureCollisionsCounter: PerfCounter;
  45994. /**
  45995. * Instantiates a new scene instrumentation.
  45996. * This class can be used to get instrumentation data from a Babylon engine
  45997. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45998. * @param scene Defines the scene to instrument
  45999. */
  46000. constructor(
  46001. /**
  46002. * Defines the scene to instrument
  46003. */
  46004. scene: Scene);
  46005. /**
  46006. * Dispose and release associated resources.
  46007. */
  46008. dispose(): void;
  46009. }
  46010. }
  46011. declare module "babylonjs/Instrumentation/index" {
  46012. export * from "babylonjs/Instrumentation/engineInstrumentation";
  46013. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  46014. export * from "babylonjs/Instrumentation/timeToken";
  46015. }
  46016. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  46017. /** @hidden */
  46018. export var glowMapGenerationPixelShader: {
  46019. name: string;
  46020. shader: string;
  46021. };
  46022. }
  46023. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  46024. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46025. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46026. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46027. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46028. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46029. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46030. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46031. /** @hidden */
  46032. export var glowMapGenerationVertexShader: {
  46033. name: string;
  46034. shader: string;
  46035. };
  46036. }
  46037. declare module "babylonjs/Layers/effectLayer" {
  46038. import { Observable } from "babylonjs/Misc/observable";
  46039. import { Nullable } from "babylonjs/types";
  46040. import { Camera } from "babylonjs/Cameras/camera";
  46041. import { Scene } from "babylonjs/scene";
  46042. import { Color4, ISize } from "babylonjs/Maths/math";
  46043. import { Engine } from "babylonjs/Engines/engine";
  46044. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46046. import { Mesh } from "babylonjs/Meshes/mesh";
  46047. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46048. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46049. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46050. import { Effect } from "babylonjs/Materials/effect";
  46051. import { Material } from "babylonjs/Materials/material";
  46052. import "babylonjs/Shaders/glowMapGeneration.fragment";
  46053. import "babylonjs/Shaders/glowMapGeneration.vertex";
  46054. /**
  46055. * Effect layer options. This helps customizing the behaviour
  46056. * of the effect layer.
  46057. */
  46058. export interface IEffectLayerOptions {
  46059. /**
  46060. * Multiplication factor apply to the canvas size to compute the render target size
  46061. * used to generated the objects (the smaller the faster).
  46062. */
  46063. mainTextureRatio: number;
  46064. /**
  46065. * Enforces a fixed size texture to ensure effect stability across devices.
  46066. */
  46067. mainTextureFixedSize?: number;
  46068. /**
  46069. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46070. */
  46071. alphaBlendingMode: number;
  46072. /**
  46073. * The camera attached to the layer.
  46074. */
  46075. camera: Nullable<Camera>;
  46076. /**
  46077. * The rendering group to draw the layer in.
  46078. */
  46079. renderingGroupId: number;
  46080. }
  46081. /**
  46082. * The effect layer Helps adding post process effect blended with the main pass.
  46083. *
  46084. * This can be for instance use to generate glow or higlight effects on the scene.
  46085. *
  46086. * The effect layer class can not be used directly and is intented to inherited from to be
  46087. * customized per effects.
  46088. */
  46089. export abstract class EffectLayer {
  46090. private _vertexBuffers;
  46091. private _indexBuffer;
  46092. private _cachedDefines;
  46093. private _effectLayerMapGenerationEffect;
  46094. private _effectLayerOptions;
  46095. private _mergeEffect;
  46096. protected _scene: Scene;
  46097. protected _engine: Engine;
  46098. protected _maxSize: number;
  46099. protected _mainTextureDesiredSize: ISize;
  46100. protected _mainTexture: RenderTargetTexture;
  46101. protected _shouldRender: boolean;
  46102. protected _postProcesses: PostProcess[];
  46103. protected _textures: BaseTexture[];
  46104. protected _emissiveTextureAndColor: {
  46105. texture: Nullable<BaseTexture>;
  46106. color: Color4;
  46107. };
  46108. /**
  46109. * The name of the layer
  46110. */
  46111. name: string;
  46112. /**
  46113. * The clear color of the texture used to generate the glow map.
  46114. */
  46115. neutralColor: Color4;
  46116. /**
  46117. * Specifies wether the highlight layer is enabled or not.
  46118. */
  46119. isEnabled: boolean;
  46120. /**
  46121. * Gets the camera attached to the layer.
  46122. */
  46123. readonly camera: Nullable<Camera>;
  46124. /**
  46125. * Gets the rendering group id the layer should render in.
  46126. */
  46127. readonly renderingGroupId: number;
  46128. /**
  46129. * An event triggered when the effect layer has been disposed.
  46130. */
  46131. onDisposeObservable: Observable<EffectLayer>;
  46132. /**
  46133. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46134. */
  46135. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46136. /**
  46137. * An event triggered when the generated texture is being merged in the scene.
  46138. */
  46139. onBeforeComposeObservable: Observable<EffectLayer>;
  46140. /**
  46141. * An event triggered when the generated texture has been merged in the scene.
  46142. */
  46143. onAfterComposeObservable: Observable<EffectLayer>;
  46144. /**
  46145. * An event triggered when the efffect layer changes its size.
  46146. */
  46147. onSizeChangedObservable: Observable<EffectLayer>;
  46148. /** @hidden */
  46149. static _SceneComponentInitialization: (scene: Scene) => void;
  46150. /**
  46151. * Instantiates a new effect Layer and references it in the scene.
  46152. * @param name The name of the layer
  46153. * @param scene The scene to use the layer in
  46154. */
  46155. constructor(
  46156. /** The Friendly of the effect in the scene */
  46157. name: string, scene: Scene);
  46158. /**
  46159. * Get the effect name of the layer.
  46160. * @return The effect name
  46161. */
  46162. abstract getEffectName(): string;
  46163. /**
  46164. * Checks for the readiness of the element composing the layer.
  46165. * @param subMesh the mesh to check for
  46166. * @param useInstances specify wether or not to use instances to render the mesh
  46167. * @return true if ready otherwise, false
  46168. */
  46169. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46170. /**
  46171. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46172. * @returns true if the effect requires stencil during the main canvas render pass.
  46173. */
  46174. abstract needStencil(): boolean;
  46175. /**
  46176. * Create the merge effect. This is the shader use to blit the information back
  46177. * to the main canvas at the end of the scene rendering.
  46178. * @returns The effect containing the shader used to merge the effect on the main canvas
  46179. */
  46180. protected abstract _createMergeEffect(): Effect;
  46181. /**
  46182. * Creates the render target textures and post processes used in the effect layer.
  46183. */
  46184. protected abstract _createTextureAndPostProcesses(): void;
  46185. /**
  46186. * Implementation specific of rendering the generating effect on the main canvas.
  46187. * @param effect The effect used to render through
  46188. */
  46189. protected abstract _internalRender(effect: Effect): void;
  46190. /**
  46191. * Sets the required values for both the emissive texture and and the main color.
  46192. */
  46193. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46194. /**
  46195. * Free any resources and references associated to a mesh.
  46196. * Internal use
  46197. * @param mesh The mesh to free.
  46198. */
  46199. abstract _disposeMesh(mesh: Mesh): void;
  46200. /**
  46201. * Serializes this layer (Glow or Highlight for example)
  46202. * @returns a serialized layer object
  46203. */
  46204. abstract serialize?(): any;
  46205. /**
  46206. * Initializes the effect layer with the required options.
  46207. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46208. */
  46209. protected _init(options: Partial<IEffectLayerOptions>): void;
  46210. /**
  46211. * Generates the index buffer of the full screen quad blending to the main canvas.
  46212. */
  46213. private _generateIndexBuffer;
  46214. /**
  46215. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46216. */
  46217. private _genrateVertexBuffer;
  46218. /**
  46219. * Sets the main texture desired size which is the closest power of two
  46220. * of the engine canvas size.
  46221. */
  46222. private _setMainTextureSize;
  46223. /**
  46224. * Creates the main texture for the effect layer.
  46225. */
  46226. protected _createMainTexture(): void;
  46227. /**
  46228. * Adds specific effects defines.
  46229. * @param defines The defines to add specifics to.
  46230. */
  46231. protected _addCustomEffectDefines(defines: string[]): void;
  46232. /**
  46233. * Checks for the readiness of the element composing the layer.
  46234. * @param subMesh the mesh to check for
  46235. * @param useInstances specify wether or not to use instances to render the mesh
  46236. * @param emissiveTexture the associated emissive texture used to generate the glow
  46237. * @return true if ready otherwise, false
  46238. */
  46239. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46240. /**
  46241. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46242. */
  46243. render(): void;
  46244. /**
  46245. * Determine if a given mesh will be used in the current effect.
  46246. * @param mesh mesh to test
  46247. * @returns true if the mesh will be used
  46248. */
  46249. hasMesh(mesh: AbstractMesh): boolean;
  46250. /**
  46251. * Returns true if the layer contains information to display, otherwise false.
  46252. * @returns true if the glow layer should be rendered
  46253. */
  46254. shouldRender(): boolean;
  46255. /**
  46256. * Returns true if the mesh should render, otherwise false.
  46257. * @param mesh The mesh to render
  46258. * @returns true if it should render otherwise false
  46259. */
  46260. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46261. /**
  46262. * Returns true if the mesh can be rendered, otherwise false.
  46263. * @param mesh The mesh to render
  46264. * @param material The material used on the mesh
  46265. * @returns true if it can be rendered otherwise false
  46266. */
  46267. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46268. /**
  46269. * Returns true if the mesh should render, otherwise false.
  46270. * @param mesh The mesh to render
  46271. * @returns true if it should render otherwise false
  46272. */
  46273. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46274. /**
  46275. * Renders the submesh passed in parameter to the generation map.
  46276. */
  46277. protected _renderSubMesh(subMesh: SubMesh): void;
  46278. /**
  46279. * Rebuild the required buffers.
  46280. * @hidden Internal use only.
  46281. */
  46282. _rebuild(): void;
  46283. /**
  46284. * Dispose only the render target textures and post process.
  46285. */
  46286. private _disposeTextureAndPostProcesses;
  46287. /**
  46288. * Dispose the highlight layer and free resources.
  46289. */
  46290. dispose(): void;
  46291. /**
  46292. * Gets the class name of the effect layer
  46293. * @returns the string with the class name of the effect layer
  46294. */
  46295. getClassName(): string;
  46296. /**
  46297. * Creates an effect layer from parsed effect layer data
  46298. * @param parsedEffectLayer defines effect layer data
  46299. * @param scene defines the current scene
  46300. * @param rootUrl defines the root URL containing the effect layer information
  46301. * @returns a parsed effect Layer
  46302. */
  46303. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46304. }
  46305. }
  46306. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  46307. import { Scene } from "babylonjs/scene";
  46308. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46309. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46310. import { AbstractScene } from "babylonjs/abstractScene";
  46311. module "babylonjs/abstractScene" {
  46312. interface AbstractScene {
  46313. /**
  46314. * The list of effect layers (highlights/glow) added to the scene
  46315. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46316. * @see http://doc.babylonjs.com/how_to/glow_layer
  46317. */
  46318. effectLayers: Array<EffectLayer>;
  46319. /**
  46320. * Removes the given effect layer from this scene.
  46321. * @param toRemove defines the effect layer to remove
  46322. * @returns the index of the removed effect layer
  46323. */
  46324. removeEffectLayer(toRemove: EffectLayer): number;
  46325. /**
  46326. * Adds the given effect layer to this scene
  46327. * @param newEffectLayer defines the effect layer to add
  46328. */
  46329. addEffectLayer(newEffectLayer: EffectLayer): void;
  46330. }
  46331. }
  46332. /**
  46333. * Defines the layer scene component responsible to manage any effect layers
  46334. * in a given scene.
  46335. */
  46336. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46337. /**
  46338. * The component name helpfull to identify the component in the list of scene components.
  46339. */
  46340. readonly name: string;
  46341. /**
  46342. * The scene the component belongs to.
  46343. */
  46344. scene: Scene;
  46345. private _engine;
  46346. private _renderEffects;
  46347. private _needStencil;
  46348. private _previousStencilState;
  46349. /**
  46350. * Creates a new instance of the component for the given scene
  46351. * @param scene Defines the scene to register the component in
  46352. */
  46353. constructor(scene: Scene);
  46354. /**
  46355. * Registers the component in a given scene
  46356. */
  46357. register(): void;
  46358. /**
  46359. * Rebuilds the elements related to this component in case of
  46360. * context lost for instance.
  46361. */
  46362. rebuild(): void;
  46363. /**
  46364. * Serializes the component data to the specified json object
  46365. * @param serializationObject The object to serialize to
  46366. */
  46367. serialize(serializationObject: any): void;
  46368. /**
  46369. * Adds all the element from the container to the scene
  46370. * @param container the container holding the elements
  46371. */
  46372. addFromContainer(container: AbstractScene): void;
  46373. /**
  46374. * Removes all the elements in the container from the scene
  46375. * @param container contains the elements to remove
  46376. */
  46377. removeFromContainer(container: AbstractScene): void;
  46378. /**
  46379. * Disposes the component and the associated ressources.
  46380. */
  46381. dispose(): void;
  46382. private _isReadyForMesh;
  46383. private _renderMainTexture;
  46384. private _setStencil;
  46385. private _setStencilBack;
  46386. private _draw;
  46387. private _drawCamera;
  46388. private _drawRenderingGroup;
  46389. }
  46390. }
  46391. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  46392. /** @hidden */
  46393. export var glowMapMergePixelShader: {
  46394. name: string;
  46395. shader: string;
  46396. };
  46397. }
  46398. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  46399. /** @hidden */
  46400. export var glowMapMergeVertexShader: {
  46401. name: string;
  46402. shader: string;
  46403. };
  46404. }
  46405. declare module "babylonjs/Layers/glowLayer" {
  46406. import { Nullable } from "babylonjs/types";
  46407. import { Camera } from "babylonjs/Cameras/camera";
  46408. import { Scene } from "babylonjs/scene";
  46409. import { Color4 } from "babylonjs/Maths/math";
  46410. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46412. import { Mesh } from "babylonjs/Meshes/mesh";
  46413. import { Texture } from "babylonjs/Materials/Textures/texture";
  46414. import { Effect } from "babylonjs/Materials/effect";
  46415. import { Material } from "babylonjs/Materials/material";
  46416. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46417. import "babylonjs/Shaders/glowMapMerge.fragment";
  46418. import "babylonjs/Shaders/glowMapMerge.vertex";
  46419. module "babylonjs/abstractScene" {
  46420. interface AbstractScene {
  46421. /**
  46422. * Return a the first highlight layer of the scene with a given name.
  46423. * @param name The name of the highlight layer to look for.
  46424. * @return The highlight layer if found otherwise null.
  46425. */
  46426. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46427. }
  46428. }
  46429. /**
  46430. * Glow layer options. This helps customizing the behaviour
  46431. * of the glow layer.
  46432. */
  46433. export interface IGlowLayerOptions {
  46434. /**
  46435. * Multiplication factor apply to the canvas size to compute the render target size
  46436. * used to generated the glowing objects (the smaller the faster).
  46437. */
  46438. mainTextureRatio: number;
  46439. /**
  46440. * Enforces a fixed size texture to ensure resize independant blur.
  46441. */
  46442. mainTextureFixedSize?: number;
  46443. /**
  46444. * How big is the kernel of the blur texture.
  46445. */
  46446. blurKernelSize: number;
  46447. /**
  46448. * The camera attached to the layer.
  46449. */
  46450. camera: Nullable<Camera>;
  46451. /**
  46452. * Enable MSAA by chosing the number of samples.
  46453. */
  46454. mainTextureSamples?: number;
  46455. /**
  46456. * The rendering group to draw the layer in.
  46457. */
  46458. renderingGroupId: number;
  46459. }
  46460. /**
  46461. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46462. *
  46463. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46464. * glowy meshes to your scene.
  46465. *
  46466. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46467. */
  46468. export class GlowLayer extends EffectLayer {
  46469. /**
  46470. * Effect Name of the layer.
  46471. */
  46472. static readonly EffectName: string;
  46473. /**
  46474. * The default blur kernel size used for the glow.
  46475. */
  46476. static DefaultBlurKernelSize: number;
  46477. /**
  46478. * The default texture size ratio used for the glow.
  46479. */
  46480. static DefaultTextureRatio: number;
  46481. /**
  46482. * Sets the kernel size of the blur.
  46483. */
  46484. /**
  46485. * Gets the kernel size of the blur.
  46486. */
  46487. blurKernelSize: number;
  46488. /**
  46489. * Sets the glow intensity.
  46490. */
  46491. /**
  46492. * Gets the glow intensity.
  46493. */
  46494. intensity: number;
  46495. private _options;
  46496. private _intensity;
  46497. private _horizontalBlurPostprocess1;
  46498. private _verticalBlurPostprocess1;
  46499. private _horizontalBlurPostprocess2;
  46500. private _verticalBlurPostprocess2;
  46501. private _blurTexture1;
  46502. private _blurTexture2;
  46503. private _postProcesses1;
  46504. private _postProcesses2;
  46505. private _includedOnlyMeshes;
  46506. private _excludedMeshes;
  46507. /**
  46508. * Callback used to let the user override the color selection on a per mesh basis
  46509. */
  46510. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46511. /**
  46512. * Callback used to let the user override the texture selection on a per mesh basis
  46513. */
  46514. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46515. /**
  46516. * Instantiates a new glow Layer and references it to the scene.
  46517. * @param name The name of the layer
  46518. * @param scene The scene to use the layer in
  46519. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46520. */
  46521. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46522. /**
  46523. * Get the effect name of the layer.
  46524. * @return The effect name
  46525. */
  46526. getEffectName(): string;
  46527. /**
  46528. * Create the merge effect. This is the shader use to blit the information back
  46529. * to the main canvas at the end of the scene rendering.
  46530. */
  46531. protected _createMergeEffect(): Effect;
  46532. /**
  46533. * Creates the render target textures and post processes used in the glow layer.
  46534. */
  46535. protected _createTextureAndPostProcesses(): void;
  46536. /**
  46537. * Checks for the readiness of the element composing the layer.
  46538. * @param subMesh the mesh to check for
  46539. * @param useInstances specify wether or not to use instances to render the mesh
  46540. * @param emissiveTexture the associated emissive texture used to generate the glow
  46541. * @return true if ready otherwise, false
  46542. */
  46543. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46544. /**
  46545. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46546. */
  46547. needStencil(): boolean;
  46548. /**
  46549. * Returns true if the mesh can be rendered, otherwise false.
  46550. * @param mesh The mesh to render
  46551. * @param material The material used on the mesh
  46552. * @returns true if it can be rendered otherwise false
  46553. */
  46554. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46555. /**
  46556. * Implementation specific of rendering the generating effect on the main canvas.
  46557. * @param effect The effect used to render through
  46558. */
  46559. protected _internalRender(effect: Effect): void;
  46560. /**
  46561. * Sets the required values for both the emissive texture and and the main color.
  46562. */
  46563. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46564. /**
  46565. * Returns true if the mesh should render, otherwise false.
  46566. * @param mesh The mesh to render
  46567. * @returns true if it should render otherwise false
  46568. */
  46569. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46570. /**
  46571. * Adds specific effects defines.
  46572. * @param defines The defines to add specifics to.
  46573. */
  46574. protected _addCustomEffectDefines(defines: string[]): void;
  46575. /**
  46576. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46577. * @param mesh The mesh to exclude from the glow layer
  46578. */
  46579. addExcludedMesh(mesh: Mesh): void;
  46580. /**
  46581. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46582. * @param mesh The mesh to remove
  46583. */
  46584. removeExcludedMesh(mesh: Mesh): void;
  46585. /**
  46586. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46587. * @param mesh The mesh to include in the glow layer
  46588. */
  46589. addIncludedOnlyMesh(mesh: Mesh): void;
  46590. /**
  46591. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46592. * @param mesh The mesh to remove
  46593. */
  46594. removeIncludedOnlyMesh(mesh: Mesh): void;
  46595. /**
  46596. * Determine if a given mesh will be used in the glow layer
  46597. * @param mesh The mesh to test
  46598. * @returns true if the mesh will be highlighted by the current glow layer
  46599. */
  46600. hasMesh(mesh: AbstractMesh): boolean;
  46601. /**
  46602. * Free any resources and references associated to a mesh.
  46603. * Internal use
  46604. * @param mesh The mesh to free.
  46605. * @hidden
  46606. */
  46607. _disposeMesh(mesh: Mesh): void;
  46608. /**
  46609. * Gets the class name of the effect layer
  46610. * @returns the string with the class name of the effect layer
  46611. */
  46612. getClassName(): string;
  46613. /**
  46614. * Serializes this glow layer
  46615. * @returns a serialized glow layer object
  46616. */
  46617. serialize(): any;
  46618. /**
  46619. * Creates a Glow Layer from parsed glow layer data
  46620. * @param parsedGlowLayer defines glow layer data
  46621. * @param scene defines the current scene
  46622. * @param rootUrl defines the root URL containing the glow layer information
  46623. * @returns a parsed Glow Layer
  46624. */
  46625. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46626. }
  46627. }
  46628. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  46629. /** @hidden */
  46630. export var glowBlurPostProcessPixelShader: {
  46631. name: string;
  46632. shader: string;
  46633. };
  46634. }
  46635. declare module "babylonjs/Layers/highlightLayer" {
  46636. import { Observable } from "babylonjs/Misc/observable";
  46637. import { Nullable } from "babylonjs/types";
  46638. import { Camera } from "babylonjs/Cameras/camera";
  46639. import { Scene } from "babylonjs/scene";
  46640. import { Color3, Color4 } from "babylonjs/Maths/math";
  46641. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46643. import { Mesh } from "babylonjs/Meshes/mesh";
  46644. import { Effect } from "babylonjs/Materials/effect";
  46645. import { Material } from "babylonjs/Materials/material";
  46646. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46647. import "babylonjs/Shaders/glowMapMerge.fragment";
  46648. import "babylonjs/Shaders/glowMapMerge.vertex";
  46649. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  46650. module "babylonjs/abstractScene" {
  46651. interface AbstractScene {
  46652. /**
  46653. * Return a the first highlight layer of the scene with a given name.
  46654. * @param name The name of the highlight layer to look for.
  46655. * @return The highlight layer if found otherwise null.
  46656. */
  46657. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46658. }
  46659. }
  46660. /**
  46661. * Highlight layer options. This helps customizing the behaviour
  46662. * of the highlight layer.
  46663. */
  46664. export interface IHighlightLayerOptions {
  46665. /**
  46666. * Multiplication factor apply to the canvas size to compute the render target size
  46667. * used to generated the glowing objects (the smaller the faster).
  46668. */
  46669. mainTextureRatio: number;
  46670. /**
  46671. * Enforces a fixed size texture to ensure resize independant blur.
  46672. */
  46673. mainTextureFixedSize?: number;
  46674. /**
  46675. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46676. * of the picture to blur (the smaller the faster).
  46677. */
  46678. blurTextureSizeRatio: number;
  46679. /**
  46680. * How big in texel of the blur texture is the vertical blur.
  46681. */
  46682. blurVerticalSize: number;
  46683. /**
  46684. * How big in texel of the blur texture is the horizontal blur.
  46685. */
  46686. blurHorizontalSize: number;
  46687. /**
  46688. * Alpha blending mode used to apply the blur. Default is combine.
  46689. */
  46690. alphaBlendingMode: number;
  46691. /**
  46692. * The camera attached to the layer.
  46693. */
  46694. camera: Nullable<Camera>;
  46695. /**
  46696. * Should we display highlight as a solid stroke?
  46697. */
  46698. isStroke?: boolean;
  46699. /**
  46700. * The rendering group to draw the layer in.
  46701. */
  46702. renderingGroupId: number;
  46703. }
  46704. /**
  46705. * The highlight layer Helps adding a glow effect around a mesh.
  46706. *
  46707. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46708. * glowy meshes to your scene.
  46709. *
  46710. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46711. */
  46712. export class HighlightLayer extends EffectLayer {
  46713. name: string;
  46714. /**
  46715. * Effect Name of the highlight layer.
  46716. */
  46717. static readonly EffectName: string;
  46718. /**
  46719. * The neutral color used during the preparation of the glow effect.
  46720. * This is black by default as the blend operation is a blend operation.
  46721. */
  46722. static NeutralColor: Color4;
  46723. /**
  46724. * Stencil value used for glowing meshes.
  46725. */
  46726. static GlowingMeshStencilReference: number;
  46727. /**
  46728. * Stencil value used for the other meshes in the scene.
  46729. */
  46730. static NormalMeshStencilReference: number;
  46731. /**
  46732. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46733. */
  46734. innerGlow: boolean;
  46735. /**
  46736. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46737. */
  46738. outerGlow: boolean;
  46739. /**
  46740. * Specifies the horizontal size of the blur.
  46741. */
  46742. /**
  46743. * Gets the horizontal size of the blur.
  46744. */
  46745. blurHorizontalSize: number;
  46746. /**
  46747. * Specifies the vertical size of the blur.
  46748. */
  46749. /**
  46750. * Gets the vertical size of the blur.
  46751. */
  46752. blurVerticalSize: number;
  46753. /**
  46754. * An event triggered when the highlight layer is being blurred.
  46755. */
  46756. onBeforeBlurObservable: Observable<HighlightLayer>;
  46757. /**
  46758. * An event triggered when the highlight layer has been blurred.
  46759. */
  46760. onAfterBlurObservable: Observable<HighlightLayer>;
  46761. private _instanceGlowingMeshStencilReference;
  46762. private _options;
  46763. private _downSamplePostprocess;
  46764. private _horizontalBlurPostprocess;
  46765. private _verticalBlurPostprocess;
  46766. private _blurTexture;
  46767. private _meshes;
  46768. private _excludedMeshes;
  46769. /**
  46770. * Instantiates a new highlight Layer and references it to the scene..
  46771. * @param name The name of the layer
  46772. * @param scene The scene to use the layer in
  46773. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46774. */
  46775. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46776. /**
  46777. * Get the effect name of the layer.
  46778. * @return The effect name
  46779. */
  46780. getEffectName(): string;
  46781. /**
  46782. * Create the merge effect. This is the shader use to blit the information back
  46783. * to the main canvas at the end of the scene rendering.
  46784. */
  46785. protected _createMergeEffect(): Effect;
  46786. /**
  46787. * Creates the render target textures and post processes used in the highlight layer.
  46788. */
  46789. protected _createTextureAndPostProcesses(): void;
  46790. /**
  46791. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46792. */
  46793. needStencil(): boolean;
  46794. /**
  46795. * Checks for the readiness of the element composing the layer.
  46796. * @param subMesh the mesh to check for
  46797. * @param useInstances specify wether or not to use instances to render the mesh
  46798. * @param emissiveTexture the associated emissive texture used to generate the glow
  46799. * @return true if ready otherwise, false
  46800. */
  46801. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46802. /**
  46803. * Implementation specific of rendering the generating effect on the main canvas.
  46804. * @param effect The effect used to render through
  46805. */
  46806. protected _internalRender(effect: Effect): void;
  46807. /**
  46808. * Returns true if the layer contains information to display, otherwise false.
  46809. */
  46810. shouldRender(): boolean;
  46811. /**
  46812. * Returns true if the mesh should render, otherwise false.
  46813. * @param mesh The mesh to render
  46814. * @returns true if it should render otherwise false
  46815. */
  46816. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46817. /**
  46818. * Sets the required values for both the emissive texture and and the main color.
  46819. */
  46820. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46821. /**
  46822. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46823. * @param mesh The mesh to exclude from the highlight layer
  46824. */
  46825. addExcludedMesh(mesh: Mesh): void;
  46826. /**
  46827. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46828. * @param mesh The mesh to highlight
  46829. */
  46830. removeExcludedMesh(mesh: Mesh): void;
  46831. /**
  46832. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46833. * @param mesh mesh to test
  46834. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46835. */
  46836. hasMesh(mesh: AbstractMesh): boolean;
  46837. /**
  46838. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46839. * @param mesh The mesh to highlight
  46840. * @param color The color of the highlight
  46841. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46842. */
  46843. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46844. /**
  46845. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46846. * @param mesh The mesh to highlight
  46847. */
  46848. removeMesh(mesh: Mesh): void;
  46849. /**
  46850. * Force the stencil to the normal expected value for none glowing parts
  46851. */
  46852. private _defaultStencilReference;
  46853. /**
  46854. * Free any resources and references associated to a mesh.
  46855. * Internal use
  46856. * @param mesh The mesh to free.
  46857. * @hidden
  46858. */
  46859. _disposeMesh(mesh: Mesh): void;
  46860. /**
  46861. * Dispose the highlight layer and free resources.
  46862. */
  46863. dispose(): void;
  46864. /**
  46865. * Gets the class name of the effect layer
  46866. * @returns the string with the class name of the effect layer
  46867. */
  46868. getClassName(): string;
  46869. /**
  46870. * Serializes this Highlight layer
  46871. * @returns a serialized Highlight layer object
  46872. */
  46873. serialize(): any;
  46874. /**
  46875. * Creates a Highlight layer from parsed Highlight layer data
  46876. * @param parsedHightlightLayer defines the Highlight layer data
  46877. * @param scene defines the current scene
  46878. * @param rootUrl defines the root URL containing the Highlight layer information
  46879. * @returns a parsed Highlight layer
  46880. */
  46881. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46882. }
  46883. }
  46884. declare module "babylonjs/Layers/index" {
  46885. export * from "babylonjs/Layers/effectLayer";
  46886. export * from "babylonjs/Layers/effectLayerSceneComponent";
  46887. export * from "babylonjs/Layers/glowLayer";
  46888. export * from "babylonjs/Layers/highlightLayer";
  46889. export * from "babylonjs/Layers/layer";
  46890. export * from "babylonjs/Layers/layerSceneComponent";
  46891. }
  46892. declare module "babylonjs/Shaders/lensFlare.fragment" {
  46893. /** @hidden */
  46894. export var lensFlarePixelShader: {
  46895. name: string;
  46896. shader: string;
  46897. };
  46898. }
  46899. declare module "babylonjs/Shaders/lensFlare.vertex" {
  46900. /** @hidden */
  46901. export var lensFlareVertexShader: {
  46902. name: string;
  46903. shader: string;
  46904. };
  46905. }
  46906. declare module "babylonjs/LensFlares/lensFlareSystem" {
  46907. import { Scene } from "babylonjs/scene";
  46908. import { Vector3, Viewport } from "babylonjs/Maths/math";
  46909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46910. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  46911. import "babylonjs/Shaders/lensFlare.fragment";
  46912. import "babylonjs/Shaders/lensFlare.vertex";
  46913. /**
  46914. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46915. * It is usually composed of several `lensFlare`.
  46916. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46917. */
  46918. export class LensFlareSystem {
  46919. /**
  46920. * Define the name of the lens flare system
  46921. */
  46922. name: string;
  46923. /**
  46924. * List of lens flares used in this system.
  46925. */
  46926. lensFlares: LensFlare[];
  46927. /**
  46928. * Define a limit from the border the lens flare can be visible.
  46929. */
  46930. borderLimit: number;
  46931. /**
  46932. * Define a viewport border we do not want to see the lens flare in.
  46933. */
  46934. viewportBorder: number;
  46935. /**
  46936. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46937. */
  46938. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46939. /**
  46940. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46941. */
  46942. layerMask: number;
  46943. /**
  46944. * Define the id of the lens flare system in the scene.
  46945. * (equal to name by default)
  46946. */
  46947. id: string;
  46948. private _scene;
  46949. private _emitter;
  46950. private _vertexBuffers;
  46951. private _indexBuffer;
  46952. private _effect;
  46953. private _positionX;
  46954. private _positionY;
  46955. private _isEnabled;
  46956. /** @hidden */
  46957. static _SceneComponentInitialization: (scene: Scene) => void;
  46958. /**
  46959. * Instantiates a lens flare system.
  46960. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46961. * It is usually composed of several `lensFlare`.
  46962. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46963. * @param name Define the name of the lens flare system in the scene
  46964. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46965. * @param scene Define the scene the lens flare system belongs to
  46966. */
  46967. constructor(
  46968. /**
  46969. * Define the name of the lens flare system
  46970. */
  46971. name: string, emitter: any, scene: Scene);
  46972. /**
  46973. * Define if the lens flare system is enabled.
  46974. */
  46975. isEnabled: boolean;
  46976. /**
  46977. * Get the scene the effects belongs to.
  46978. * @returns the scene holding the lens flare system
  46979. */
  46980. getScene(): Scene;
  46981. /**
  46982. * Get the emitter of the lens flare system.
  46983. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46984. * @returns the emitter of the lens flare system
  46985. */
  46986. getEmitter(): any;
  46987. /**
  46988. * Set the emitter of the lens flare system.
  46989. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46990. * @param newEmitter Define the new emitter of the system
  46991. */
  46992. setEmitter(newEmitter: any): void;
  46993. /**
  46994. * Get the lens flare system emitter position.
  46995. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46996. * @returns the position
  46997. */
  46998. getEmitterPosition(): Vector3;
  46999. /**
  47000. * @hidden
  47001. */
  47002. computeEffectivePosition(globalViewport: Viewport): boolean;
  47003. /** @hidden */
  47004. _isVisible(): boolean;
  47005. /**
  47006. * @hidden
  47007. */
  47008. render(): boolean;
  47009. /**
  47010. * Dispose and release the lens flare with its associated resources.
  47011. */
  47012. dispose(): void;
  47013. /**
  47014. * Parse a lens flare system from a JSON repressentation
  47015. * @param parsedLensFlareSystem Define the JSON to parse
  47016. * @param scene Define the scene the parsed system should be instantiated in
  47017. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47018. * @returns the parsed system
  47019. */
  47020. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47021. /**
  47022. * Serialize the current Lens Flare System into a JSON representation.
  47023. * @returns the serialized JSON
  47024. */
  47025. serialize(): any;
  47026. }
  47027. }
  47028. declare module "babylonjs/LensFlares/lensFlare" {
  47029. import { Nullable } from "babylonjs/types";
  47030. import { Color3 } from "babylonjs/Maths/math";
  47031. import { Texture } from "babylonjs/Materials/Textures/texture";
  47032. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47033. /**
  47034. * This represents one of the lens effect in a `lensFlareSystem`.
  47035. * It controls one of the indiviual texture used in the effect.
  47036. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47037. */
  47038. export class LensFlare {
  47039. /**
  47040. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47041. */
  47042. size: number;
  47043. /**
  47044. * 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.
  47045. */
  47046. position: number;
  47047. /**
  47048. * Define the lens color.
  47049. */
  47050. color: Color3;
  47051. /**
  47052. * Define the lens texture.
  47053. */
  47054. texture: Nullable<Texture>;
  47055. /**
  47056. * Define the alpha mode to render this particular lens.
  47057. */
  47058. alphaMode: number;
  47059. private _system;
  47060. /**
  47061. * Creates a new Lens Flare.
  47062. * This represents one of the lens effect in a `lensFlareSystem`.
  47063. * It controls one of the indiviual texture used in the effect.
  47064. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47065. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47066. * @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.
  47067. * @param color Define the lens color
  47068. * @param imgUrl Define the lens texture url
  47069. * @param system Define the `lensFlareSystem` this flare is part of
  47070. * @returns The newly created Lens Flare
  47071. */
  47072. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47073. /**
  47074. * Instantiates a new Lens Flare.
  47075. * This represents one of the lens effect in a `lensFlareSystem`.
  47076. * It controls one of the indiviual texture used in the effect.
  47077. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47078. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47079. * @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.
  47080. * @param color Define the lens color
  47081. * @param imgUrl Define the lens texture url
  47082. * @param system Define the `lensFlareSystem` this flare is part of
  47083. */
  47084. constructor(
  47085. /**
  47086. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47087. */
  47088. size: number,
  47089. /**
  47090. * 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.
  47091. */
  47092. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47093. /**
  47094. * Dispose and release the lens flare with its associated resources.
  47095. */
  47096. dispose(): void;
  47097. }
  47098. }
  47099. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  47100. import { Nullable } from "babylonjs/types";
  47101. import { Scene } from "babylonjs/scene";
  47102. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47103. import { AbstractScene } from "babylonjs/abstractScene";
  47104. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47105. module "babylonjs/abstractScene" {
  47106. interface AbstractScene {
  47107. /**
  47108. * The list of lens flare system added to the scene
  47109. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47110. */
  47111. lensFlareSystems: Array<LensFlareSystem>;
  47112. /**
  47113. * Removes the given lens flare system from this scene.
  47114. * @param toRemove The lens flare system to remove
  47115. * @returns The index of the removed lens flare system
  47116. */
  47117. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47118. /**
  47119. * Adds the given lens flare system to this scene
  47120. * @param newLensFlareSystem The lens flare system to add
  47121. */
  47122. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47123. /**
  47124. * Gets a lens flare system using its name
  47125. * @param name defines the name to look for
  47126. * @returns the lens flare system or null if not found
  47127. */
  47128. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47129. /**
  47130. * Gets a lens flare system using its id
  47131. * @param id defines the id to look for
  47132. * @returns the lens flare system or null if not found
  47133. */
  47134. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47135. }
  47136. }
  47137. /**
  47138. * Defines the lens flare scene component responsible to manage any lens flares
  47139. * in a given scene.
  47140. */
  47141. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47142. /**
  47143. * The component name helpfull to identify the component in the list of scene components.
  47144. */
  47145. readonly name: string;
  47146. /**
  47147. * The scene the component belongs to.
  47148. */
  47149. scene: Scene;
  47150. /**
  47151. * Creates a new instance of the component for the given scene
  47152. * @param scene Defines the scene to register the component in
  47153. */
  47154. constructor(scene: Scene);
  47155. /**
  47156. * Registers the component in a given scene
  47157. */
  47158. register(): void;
  47159. /**
  47160. * Rebuilds the elements related to this component in case of
  47161. * context lost for instance.
  47162. */
  47163. rebuild(): void;
  47164. /**
  47165. * Adds all the element from the container to the scene
  47166. * @param container the container holding the elements
  47167. */
  47168. addFromContainer(container: AbstractScene): void;
  47169. /**
  47170. * Removes all the elements in the container from the scene
  47171. * @param container contains the elements to remove
  47172. */
  47173. removeFromContainer(container: AbstractScene): void;
  47174. /**
  47175. * Serializes the component data to the specified json object
  47176. * @param serializationObject The object to serialize to
  47177. */
  47178. serialize(serializationObject: any): void;
  47179. /**
  47180. * Disposes the component and the associated ressources.
  47181. */
  47182. dispose(): void;
  47183. private _draw;
  47184. }
  47185. }
  47186. declare module "babylonjs/LensFlares/index" {
  47187. export * from "babylonjs/LensFlares/lensFlare";
  47188. export * from "babylonjs/LensFlares/lensFlareSystem";
  47189. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  47190. }
  47191. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  47192. import { Scene } from "babylonjs/scene";
  47193. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47194. import { AbstractScene } from "babylonjs/abstractScene";
  47195. /**
  47196. * Defines the shadow generator component responsible to manage any shadow generators
  47197. * in a given scene.
  47198. */
  47199. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47200. /**
  47201. * The component name helpfull to identify the component in the list of scene components.
  47202. */
  47203. readonly name: string;
  47204. /**
  47205. * The scene the component belongs to.
  47206. */
  47207. scene: Scene;
  47208. /**
  47209. * Creates a new instance of the component for the given scene
  47210. * @param scene Defines the scene to register the component in
  47211. */
  47212. constructor(scene: Scene);
  47213. /**
  47214. * Registers the component in a given scene
  47215. */
  47216. register(): void;
  47217. /**
  47218. * Rebuilds the elements related to this component in case of
  47219. * context lost for instance.
  47220. */
  47221. rebuild(): void;
  47222. /**
  47223. * Serializes the component data to the specified json object
  47224. * @param serializationObject The object to serialize to
  47225. */
  47226. serialize(serializationObject: any): void;
  47227. /**
  47228. * Adds all the element from the container to the scene
  47229. * @param container the container holding the elements
  47230. */
  47231. addFromContainer(container: AbstractScene): void;
  47232. /**
  47233. * Removes all the elements in the container from the scene
  47234. * @param container contains the elements to remove
  47235. */
  47236. removeFromContainer(container: AbstractScene): void;
  47237. /**
  47238. * Rebuilds the elements related to this component in case of
  47239. * context lost for instance.
  47240. */
  47241. dispose(): void;
  47242. private _gatherRenderTargets;
  47243. }
  47244. }
  47245. declare module "babylonjs/Lights/Shadows/index" {
  47246. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  47247. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  47248. }
  47249. declare module "babylonjs/Lights/directionalLight" {
  47250. import { Camera } from "babylonjs/Cameras/camera";
  47251. import { Scene } from "babylonjs/scene";
  47252. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47254. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47255. import { Effect } from "babylonjs/Materials/effect";
  47256. /**
  47257. * A directional light is defined by a direction (what a surprise!).
  47258. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47259. * 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.
  47260. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47261. */
  47262. export class DirectionalLight extends ShadowLight {
  47263. private _shadowFrustumSize;
  47264. /**
  47265. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47266. */
  47267. /**
  47268. * Specifies a fix frustum size for the shadow generation.
  47269. */
  47270. shadowFrustumSize: number;
  47271. private _shadowOrthoScale;
  47272. /**
  47273. * Gets the shadow projection scale against the optimal computed one.
  47274. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47275. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47276. */
  47277. /**
  47278. * Sets the shadow projection scale against the optimal computed one.
  47279. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47280. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47281. */
  47282. shadowOrthoScale: number;
  47283. /**
  47284. * Automatically compute the projection matrix to best fit (including all the casters)
  47285. * on each frame.
  47286. */
  47287. autoUpdateExtends: boolean;
  47288. private _orthoLeft;
  47289. private _orthoRight;
  47290. private _orthoTop;
  47291. private _orthoBottom;
  47292. /**
  47293. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47294. * The directional light is emitted from everywhere in the given direction.
  47295. * It can cast shadows.
  47296. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47297. * @param name The friendly name of the light
  47298. * @param direction The direction of the light
  47299. * @param scene The scene the light belongs to
  47300. */
  47301. constructor(name: string, direction: Vector3, scene: Scene);
  47302. /**
  47303. * Returns the string "DirectionalLight".
  47304. * @return The class name
  47305. */
  47306. getClassName(): string;
  47307. /**
  47308. * Returns the integer 1.
  47309. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47310. */
  47311. getTypeID(): number;
  47312. /**
  47313. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47314. * Returns the DirectionalLight Shadow projection matrix.
  47315. */
  47316. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47317. /**
  47318. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47319. * Returns the DirectionalLight Shadow projection matrix.
  47320. */
  47321. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47322. /**
  47323. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47324. * Returns the DirectionalLight Shadow projection matrix.
  47325. */
  47326. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47327. protected _buildUniformLayout(): void;
  47328. /**
  47329. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47330. * @param effect The effect to update
  47331. * @param lightIndex The index of the light in the effect to update
  47332. * @returns The directional light
  47333. */
  47334. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47335. /**
  47336. * Gets the minZ used for shadow according to both the scene and the light.
  47337. *
  47338. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47339. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47340. * @param activeCamera The camera we are returning the min for
  47341. * @returns the depth min z
  47342. */
  47343. getDepthMinZ(activeCamera: Camera): number;
  47344. /**
  47345. * Gets the maxZ used for shadow according to both the scene and the light.
  47346. *
  47347. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47348. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47349. * @param activeCamera The camera we are returning the max for
  47350. * @returns the depth max z
  47351. */
  47352. getDepthMaxZ(activeCamera: Camera): number;
  47353. /**
  47354. * Prepares the list of defines specific to the light type.
  47355. * @param defines the list of defines
  47356. * @param lightIndex defines the index of the light for the effect
  47357. */
  47358. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47359. }
  47360. }
  47361. declare module "babylonjs/Lights/pointLight" {
  47362. import { Scene } from "babylonjs/scene";
  47363. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47365. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47366. import { Effect } from "babylonjs/Materials/effect";
  47367. /**
  47368. * A point light is a light defined by an unique point in world space.
  47369. * The light is emitted in every direction from this point.
  47370. * A good example of a point light is a standard light bulb.
  47371. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47372. */
  47373. export class PointLight extends ShadowLight {
  47374. private _shadowAngle;
  47375. /**
  47376. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47377. * This specifies what angle the shadow will use to be created.
  47378. *
  47379. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47380. */
  47381. /**
  47382. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47383. * This specifies what angle the shadow will use to be created.
  47384. *
  47385. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47386. */
  47387. shadowAngle: number;
  47388. /**
  47389. * Gets the direction if it has been set.
  47390. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47391. */
  47392. /**
  47393. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47394. */
  47395. direction: Vector3;
  47396. /**
  47397. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47398. * A PointLight emits the light in every direction.
  47399. * It can cast shadows.
  47400. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47401. * ```javascript
  47402. * var pointLight = new PointLight("pl", camera.position, scene);
  47403. * ```
  47404. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47405. * @param name The light friendly name
  47406. * @param position The position of the point light in the scene
  47407. * @param scene The scene the lights belongs to
  47408. */
  47409. constructor(name: string, position: Vector3, scene: Scene);
  47410. /**
  47411. * Returns the string "PointLight"
  47412. * @returns the class name
  47413. */
  47414. getClassName(): string;
  47415. /**
  47416. * Returns the integer 0.
  47417. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47418. */
  47419. getTypeID(): number;
  47420. /**
  47421. * Specifies wether or not the shadowmap should be a cube texture.
  47422. * @returns true if the shadowmap needs to be a cube texture.
  47423. */
  47424. needCube(): boolean;
  47425. /**
  47426. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47427. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47428. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47429. */
  47430. getShadowDirection(faceIndex?: number): Vector3;
  47431. /**
  47432. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47433. * - fov = PI / 2
  47434. * - aspect ratio : 1.0
  47435. * - z-near and far equal to the active camera minZ and maxZ.
  47436. * Returns the PointLight.
  47437. */
  47438. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47439. protected _buildUniformLayout(): void;
  47440. /**
  47441. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47442. * @param effect The effect to update
  47443. * @param lightIndex The index of the light in the effect to update
  47444. * @returns The point light
  47445. */
  47446. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47447. /**
  47448. * Prepares the list of defines specific to the light type.
  47449. * @param defines the list of defines
  47450. * @param lightIndex defines the index of the light for the effect
  47451. */
  47452. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47453. }
  47454. }
  47455. declare module "babylonjs/Lights/spotLight" {
  47456. import { Nullable } from "babylonjs/types";
  47457. import { Scene } from "babylonjs/scene";
  47458. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47460. import { Effect } from "babylonjs/Materials/effect";
  47461. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47462. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47463. /**
  47464. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47465. * These values define a cone of light starting from the position, emitting toward the direction.
  47466. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47467. * and the exponent defines the speed of the decay of the light with distance (reach).
  47468. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47469. */
  47470. export class SpotLight extends ShadowLight {
  47471. private _angle;
  47472. private _innerAngle;
  47473. private _cosHalfAngle;
  47474. private _lightAngleScale;
  47475. private _lightAngleOffset;
  47476. /**
  47477. * Gets the cone angle of the spot light in Radians.
  47478. */
  47479. /**
  47480. * Sets the cone angle of the spot light in Radians.
  47481. */
  47482. angle: number;
  47483. /**
  47484. * Only used in gltf falloff mode, this defines the angle where
  47485. * the directional falloff will start before cutting at angle which could be seen
  47486. * as outer angle.
  47487. */
  47488. /**
  47489. * Only used in gltf falloff mode, this defines the angle where
  47490. * the directional falloff will start before cutting at angle which could be seen
  47491. * as outer angle.
  47492. */
  47493. innerAngle: number;
  47494. private _shadowAngleScale;
  47495. /**
  47496. * Allows scaling the angle of the light for shadow generation only.
  47497. */
  47498. /**
  47499. * Allows scaling the angle of the light for shadow generation only.
  47500. */
  47501. shadowAngleScale: number;
  47502. /**
  47503. * The light decay speed with the distance from the emission spot.
  47504. */
  47505. exponent: number;
  47506. private _projectionTextureMatrix;
  47507. /**
  47508. * Allows reading the projecton texture
  47509. */
  47510. readonly projectionTextureMatrix: Matrix;
  47511. protected _projectionTextureLightNear: number;
  47512. /**
  47513. * Gets the near clip of the Spotlight for texture projection.
  47514. */
  47515. /**
  47516. * Sets the near clip of the Spotlight for texture projection.
  47517. */
  47518. projectionTextureLightNear: number;
  47519. protected _projectionTextureLightFar: number;
  47520. /**
  47521. * Gets the far clip of the Spotlight for texture projection.
  47522. */
  47523. /**
  47524. * Sets the far clip of the Spotlight for texture projection.
  47525. */
  47526. projectionTextureLightFar: number;
  47527. protected _projectionTextureUpDirection: Vector3;
  47528. /**
  47529. * Gets the Up vector of the Spotlight for texture projection.
  47530. */
  47531. /**
  47532. * Sets the Up vector of the Spotlight for texture projection.
  47533. */
  47534. projectionTextureUpDirection: Vector3;
  47535. private _projectionTexture;
  47536. /**
  47537. * Gets the projection texture of the light.
  47538. */
  47539. /**
  47540. * Sets the projection texture of the light.
  47541. */
  47542. projectionTexture: Nullable<BaseTexture>;
  47543. private _projectionTextureViewLightDirty;
  47544. private _projectionTextureProjectionLightDirty;
  47545. private _projectionTextureDirty;
  47546. private _projectionTextureViewTargetVector;
  47547. private _projectionTextureViewLightMatrix;
  47548. private _projectionTextureProjectionLightMatrix;
  47549. private _projectionTextureScalingMatrix;
  47550. /**
  47551. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47552. * It can cast shadows.
  47553. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47554. * @param name The light friendly name
  47555. * @param position The position of the spot light in the scene
  47556. * @param direction The direction of the light in the scene
  47557. * @param angle The cone angle of the light in Radians
  47558. * @param exponent The light decay speed with the distance from the emission spot
  47559. * @param scene The scene the lights belongs to
  47560. */
  47561. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47562. /**
  47563. * Returns the string "SpotLight".
  47564. * @returns the class name
  47565. */
  47566. getClassName(): string;
  47567. /**
  47568. * Returns the integer 2.
  47569. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47570. */
  47571. getTypeID(): number;
  47572. /**
  47573. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47574. */
  47575. protected _setDirection(value: Vector3): void;
  47576. /**
  47577. * Overrides the position setter to recompute the projection texture view light Matrix.
  47578. */
  47579. protected _setPosition(value: Vector3): void;
  47580. /**
  47581. * 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.
  47582. * Returns the SpotLight.
  47583. */
  47584. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47585. protected _computeProjectionTextureViewLightMatrix(): void;
  47586. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47587. /**
  47588. * Main function for light texture projection matrix computing.
  47589. */
  47590. protected _computeProjectionTextureMatrix(): void;
  47591. protected _buildUniformLayout(): void;
  47592. private _computeAngleValues;
  47593. /**
  47594. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47595. * @param effect The effect to update
  47596. * @param lightIndex The index of the light in the effect to update
  47597. * @returns The spot light
  47598. */
  47599. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47600. /**
  47601. * Disposes the light and the associated resources.
  47602. */
  47603. dispose(): void;
  47604. /**
  47605. * Prepares the list of defines specific to the light type.
  47606. * @param defines the list of defines
  47607. * @param lightIndex defines the index of the light for the effect
  47608. */
  47609. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47610. }
  47611. }
  47612. declare module "babylonjs/Lights/index" {
  47613. export * from "babylonjs/Lights/light";
  47614. export * from "babylonjs/Lights/shadowLight";
  47615. export * from "babylonjs/Lights/Shadows/index";
  47616. export * from "babylonjs/Lights/directionalLight";
  47617. export * from "babylonjs/Lights/hemisphericLight";
  47618. export * from "babylonjs/Lights/pointLight";
  47619. export * from "babylonjs/Lights/spotLight";
  47620. }
  47621. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  47622. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47623. /**
  47624. * Header information of HDR texture files.
  47625. */
  47626. export interface HDRInfo {
  47627. /**
  47628. * The height of the texture in pixels.
  47629. */
  47630. height: number;
  47631. /**
  47632. * The width of the texture in pixels.
  47633. */
  47634. width: number;
  47635. /**
  47636. * The index of the beginning of the data in the binary file.
  47637. */
  47638. dataPosition: number;
  47639. }
  47640. /**
  47641. * This groups tools to convert HDR texture to native colors array.
  47642. */
  47643. export class HDRTools {
  47644. private static Ldexp;
  47645. private static Rgbe2float;
  47646. private static readStringLine;
  47647. /**
  47648. * Reads header information from an RGBE texture stored in a native array.
  47649. * More information on this format are available here:
  47650. * https://en.wikipedia.org/wiki/RGBE_image_format
  47651. *
  47652. * @param uint8array The binary file stored in native array.
  47653. * @return The header information.
  47654. */
  47655. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47656. /**
  47657. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47658. * This RGBE texture needs to store the information as a panorama.
  47659. *
  47660. * More information on this format are available here:
  47661. * https://en.wikipedia.org/wiki/RGBE_image_format
  47662. *
  47663. * @param buffer The binary file stored in an array buffer.
  47664. * @param size The expected size of the extracted cubemap.
  47665. * @return The Cube Map information.
  47666. */
  47667. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47668. /**
  47669. * Returns the pixels data extracted from an RGBE texture.
  47670. * This pixels will be stored left to right up to down in the R G B order in one array.
  47671. *
  47672. * More information on this format are available here:
  47673. * https://en.wikipedia.org/wiki/RGBE_image_format
  47674. *
  47675. * @param uint8array The binary file stored in an array buffer.
  47676. * @param hdrInfo The header information of the file.
  47677. * @return The pixels data in RGB right to left up to down order.
  47678. */
  47679. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47680. private static RGBE_ReadPixels_RLE;
  47681. }
  47682. }
  47683. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  47684. import { Nullable } from "babylonjs/types";
  47685. import { Scene } from "babylonjs/scene";
  47686. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47687. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47688. /**
  47689. * This represents a texture coming from an HDR input.
  47690. *
  47691. * The only supported format is currently panorama picture stored in RGBE format.
  47692. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47693. */
  47694. export class HDRCubeTexture extends BaseTexture {
  47695. private static _facesMapping;
  47696. private _generateHarmonics;
  47697. private _noMipmap;
  47698. private _textureMatrix;
  47699. private _size;
  47700. private _onLoad;
  47701. private _onError;
  47702. /**
  47703. * The texture URL.
  47704. */
  47705. url: string;
  47706. /**
  47707. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47708. */
  47709. coordinatesMode: number;
  47710. protected _isBlocking: boolean;
  47711. /**
  47712. * Sets wether or not the texture is blocking during loading.
  47713. */
  47714. /**
  47715. * Gets wether or not the texture is blocking during loading.
  47716. */
  47717. isBlocking: boolean;
  47718. protected _rotationY: number;
  47719. /**
  47720. * Sets texture matrix rotation angle around Y axis in radians.
  47721. */
  47722. /**
  47723. * Gets texture matrix rotation angle around Y axis radians.
  47724. */
  47725. rotationY: number;
  47726. /**
  47727. * Gets or sets the center of the bounding box associated with the cube texture
  47728. * It must define where the camera used to render the texture was set
  47729. */
  47730. boundingBoxPosition: Vector3;
  47731. private _boundingBoxSize;
  47732. /**
  47733. * Gets or sets the size of the bounding box associated with the cube texture
  47734. * When defined, the cubemap will switch to local mode
  47735. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47736. * @example https://www.babylonjs-playground.com/#RNASML
  47737. */
  47738. boundingBoxSize: Vector3;
  47739. /**
  47740. * Instantiates an HDRTexture from the following parameters.
  47741. *
  47742. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47743. * @param scene The scene the texture will be used in
  47744. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47745. * @param noMipmap Forces to not generate the mipmap if true
  47746. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47747. * @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)
  47748. * @param reserved Reserved flag for internal use.
  47749. */
  47750. 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>);
  47751. /**
  47752. * Get the current class name of the texture useful for serialization or dynamic coding.
  47753. * @returns "HDRCubeTexture"
  47754. */
  47755. getClassName(): string;
  47756. /**
  47757. * Occurs when the file is raw .hdr file.
  47758. */
  47759. private loadTexture;
  47760. clone(): HDRCubeTexture;
  47761. delayLoad(): void;
  47762. /**
  47763. * Get the texture reflection matrix used to rotate/transform the reflection.
  47764. * @returns the reflection matrix
  47765. */
  47766. getReflectionTextureMatrix(): Matrix;
  47767. /**
  47768. * Set the texture reflection matrix used to rotate/transform the reflection.
  47769. * @param value Define the reflection matrix to set
  47770. */
  47771. setReflectionTextureMatrix(value: Matrix): void;
  47772. /**
  47773. * Parses a JSON representation of an HDR Texture in order to create the texture
  47774. * @param parsedTexture Define the JSON representation
  47775. * @param scene Define the scene the texture should be created in
  47776. * @param rootUrl Define the root url in case we need to load relative dependencies
  47777. * @returns the newly created texture after parsing
  47778. */
  47779. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47780. serialize(): any;
  47781. }
  47782. }
  47783. declare module "babylonjs/Physics/physicsEngine" {
  47784. import { Nullable } from "babylonjs/types";
  47785. import { Vector3 } from "babylonjs/Maths/math";
  47786. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47787. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  47788. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  47789. /**
  47790. * Class used to control physics engine
  47791. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47792. */
  47793. export class PhysicsEngine implements IPhysicsEngine {
  47794. private _physicsPlugin;
  47795. /**
  47796. * Global value used to control the smallest number supported by the simulation
  47797. */
  47798. static Epsilon: number;
  47799. private _impostors;
  47800. private _joints;
  47801. /**
  47802. * Gets the gravity vector used by the simulation
  47803. */
  47804. gravity: Vector3;
  47805. /**
  47806. * Factory used to create the default physics plugin.
  47807. * @returns The default physics plugin
  47808. */
  47809. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47810. /**
  47811. * Creates a new Physics Engine
  47812. * @param gravity defines the gravity vector used by the simulation
  47813. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47814. */
  47815. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47816. /**
  47817. * Sets the gravity vector used by the simulation
  47818. * @param gravity defines the gravity vector to use
  47819. */
  47820. setGravity(gravity: Vector3): void;
  47821. /**
  47822. * Set the time step of the physics engine.
  47823. * Default is 1/60.
  47824. * To slow it down, enter 1/600 for example.
  47825. * To speed it up, 1/30
  47826. * @param newTimeStep defines the new timestep to apply to this world.
  47827. */
  47828. setTimeStep(newTimeStep?: number): void;
  47829. /**
  47830. * Get the time step of the physics engine.
  47831. * @returns the current time step
  47832. */
  47833. getTimeStep(): number;
  47834. /**
  47835. * Release all resources
  47836. */
  47837. dispose(): void;
  47838. /**
  47839. * Gets the name of the current physics plugin
  47840. * @returns the name of the plugin
  47841. */
  47842. getPhysicsPluginName(): string;
  47843. /**
  47844. * Adding a new impostor for the impostor tracking.
  47845. * This will be done by the impostor itself.
  47846. * @param impostor the impostor to add
  47847. */
  47848. addImpostor(impostor: PhysicsImpostor): void;
  47849. /**
  47850. * Remove an impostor from the engine.
  47851. * This impostor and its mesh will not longer be updated by the physics engine.
  47852. * @param impostor the impostor to remove
  47853. */
  47854. removeImpostor(impostor: PhysicsImpostor): void;
  47855. /**
  47856. * Add a joint to the physics engine
  47857. * @param mainImpostor defines the main impostor to which the joint is added.
  47858. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47859. * @param joint defines the joint that will connect both impostors.
  47860. */
  47861. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47862. /**
  47863. * Removes a joint from the simulation
  47864. * @param mainImpostor defines the impostor used with the joint
  47865. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47866. * @param joint defines the joint to remove
  47867. */
  47868. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47869. /**
  47870. * Called by the scene. No need to call it.
  47871. * @param delta defines the timespam between frames
  47872. */
  47873. _step(delta: number): void;
  47874. /**
  47875. * Gets the current plugin used to run the simulation
  47876. * @returns current plugin
  47877. */
  47878. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47879. /**
  47880. * Gets the list of physic impostors
  47881. * @returns an array of PhysicsImpostor
  47882. */
  47883. getImpostors(): Array<PhysicsImpostor>;
  47884. /**
  47885. * Gets the impostor for a physics enabled object
  47886. * @param object defines the object impersonated by the impostor
  47887. * @returns the PhysicsImpostor or null if not found
  47888. */
  47889. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47890. /**
  47891. * Gets the impostor for a physics body object
  47892. * @param body defines physics body used by the impostor
  47893. * @returns the PhysicsImpostor or null if not found
  47894. */
  47895. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47896. }
  47897. }
  47898. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  47899. import { Nullable } from "babylonjs/types";
  47900. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47902. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47903. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47904. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47905. /** @hidden */
  47906. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47907. private _useDeltaForWorldStep;
  47908. world: any;
  47909. name: string;
  47910. private _physicsMaterials;
  47911. private _fixedTimeStep;
  47912. BJSCANNON: any;
  47913. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47914. setGravity(gravity: Vector3): void;
  47915. setTimeStep(timeStep: number): void;
  47916. getTimeStep(): number;
  47917. executeStep(delta: number): void;
  47918. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47919. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47920. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47921. private _processChildMeshes;
  47922. removePhysicsBody(impostor: PhysicsImpostor): void;
  47923. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47924. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47925. private _addMaterial;
  47926. private _checkWithEpsilon;
  47927. private _createShape;
  47928. private _createHeightmap;
  47929. private _minus90X;
  47930. private _plus90X;
  47931. private _tmpPosition;
  47932. private _tmpDeltaPosition;
  47933. private _tmpUnityRotation;
  47934. private _updatePhysicsBodyTransformation;
  47935. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47936. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47937. isSupported(): boolean;
  47938. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47939. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47940. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47941. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47942. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47943. getBodyMass(impostor: PhysicsImpostor): number;
  47944. getBodyFriction(impostor: PhysicsImpostor): number;
  47945. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47946. getBodyRestitution(impostor: PhysicsImpostor): number;
  47947. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47948. sleepBody(impostor: PhysicsImpostor): void;
  47949. wakeUpBody(impostor: PhysicsImpostor): void;
  47950. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47951. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47952. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47953. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47954. getRadius(impostor: PhysicsImpostor): number;
  47955. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47956. dispose(): void;
  47957. private _extendNamespace;
  47958. }
  47959. }
  47960. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  47961. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47962. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47963. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47965. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47966. import { Nullable } from "babylonjs/types";
  47967. /** @hidden */
  47968. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47969. world: any;
  47970. name: string;
  47971. BJSOIMO: any;
  47972. constructor(iterations?: number, oimoInjection?: any);
  47973. setGravity(gravity: Vector3): void;
  47974. setTimeStep(timeStep: number): void;
  47975. getTimeStep(): number;
  47976. private _tmpImpostorsArray;
  47977. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47978. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47979. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47980. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47981. private _tmpPositionVector;
  47982. removePhysicsBody(impostor: PhysicsImpostor): void;
  47983. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47984. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47985. isSupported(): boolean;
  47986. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47987. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47988. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47989. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47990. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47991. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47992. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47993. getBodyMass(impostor: PhysicsImpostor): number;
  47994. getBodyFriction(impostor: PhysicsImpostor): number;
  47995. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47996. getBodyRestitution(impostor: PhysicsImpostor): number;
  47997. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47998. sleepBody(impostor: PhysicsImpostor): void;
  47999. wakeUpBody(impostor: PhysicsImpostor): void;
  48000. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48001. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48002. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48003. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48004. getRadius(impostor: PhysicsImpostor): number;
  48005. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48006. dispose(): void;
  48007. }
  48008. }
  48009. declare module "babylonjs/Probes/reflectionProbe" {
  48010. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48011. import { Vector3 } from "babylonjs/Maths/math";
  48012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48013. import { Nullable } from "babylonjs/types";
  48014. import { Scene } from "babylonjs/scene";
  48015. module "babylonjs/abstractScene" {
  48016. interface AbstractScene {
  48017. /**
  48018. * The list of reflection probes added to the scene
  48019. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48020. */
  48021. reflectionProbes: Array<ReflectionProbe>;
  48022. /**
  48023. * Removes the given reflection probe from this scene.
  48024. * @param toRemove The reflection probe to remove
  48025. * @returns The index of the removed reflection probe
  48026. */
  48027. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48028. /**
  48029. * Adds the given reflection probe to this scene.
  48030. * @param newReflectionProbe The reflection probe to add
  48031. */
  48032. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48033. }
  48034. }
  48035. /**
  48036. * Class used to generate realtime reflection / refraction cube textures
  48037. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48038. */
  48039. export class ReflectionProbe {
  48040. /** defines the name of the probe */
  48041. name: string;
  48042. private _scene;
  48043. private _renderTargetTexture;
  48044. private _projectionMatrix;
  48045. private _viewMatrix;
  48046. private _target;
  48047. private _add;
  48048. private _attachedMesh;
  48049. private _invertYAxis;
  48050. /** Gets or sets probe position (center of the cube map) */
  48051. position: Vector3;
  48052. /**
  48053. * Creates a new reflection probe
  48054. * @param name defines the name of the probe
  48055. * @param size defines the texture resolution (for each face)
  48056. * @param scene defines the hosting scene
  48057. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48058. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48059. */
  48060. constructor(
  48061. /** defines the name of the probe */
  48062. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48063. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48064. samples: number;
  48065. /** Gets or sets the refresh rate to use (on every frame by default) */
  48066. refreshRate: number;
  48067. /**
  48068. * Gets the hosting scene
  48069. * @returns a Scene
  48070. */
  48071. getScene(): Scene;
  48072. /** Gets the internal CubeTexture used to render to */
  48073. readonly cubeTexture: RenderTargetTexture;
  48074. /** Gets the list of meshes to render */
  48075. readonly renderList: Nullable<AbstractMesh[]>;
  48076. /**
  48077. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48078. * @param mesh defines the mesh to attach to
  48079. */
  48080. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48081. /**
  48082. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48083. * @param renderingGroupId The rendering group id corresponding to its index
  48084. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48085. */
  48086. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48087. /**
  48088. * Clean all associated resources
  48089. */
  48090. dispose(): void;
  48091. /**
  48092. * Converts the reflection probe information to a readable string for debug purpose.
  48093. * @param fullDetails Supports for multiple levels of logging within scene loading
  48094. * @returns the human readable reflection probe info
  48095. */
  48096. toString(fullDetails?: boolean): string;
  48097. /**
  48098. * Get the class name of the relfection probe.
  48099. * @returns "ReflectionProbe"
  48100. */
  48101. getClassName(): string;
  48102. /**
  48103. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48104. * @returns The JSON representation of the texture
  48105. */
  48106. serialize(): any;
  48107. /**
  48108. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48109. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48110. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48111. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48112. * @returns The parsed reflection probe if successful
  48113. */
  48114. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48115. }
  48116. }
  48117. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  48118. /** @hidden */
  48119. export var _BabylonLoaderRegistered: boolean;
  48120. }
  48121. declare module "babylonjs/Loading/Plugins/index" {
  48122. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  48123. }
  48124. declare module "babylonjs/Loading/index" {
  48125. export * from "babylonjs/Loading/loadingScreen";
  48126. export * from "babylonjs/Loading/Plugins/index";
  48127. export * from "babylonjs/Loading/sceneLoader";
  48128. export * from "babylonjs/Loading/sceneLoaderFlags";
  48129. }
  48130. declare module "babylonjs/Materials/Background/index" {
  48131. export * from "babylonjs/Materials/Background/backgroundMaterial";
  48132. }
  48133. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  48134. import { Scene } from "babylonjs/scene";
  48135. import { Color3 } from "babylonjs/Maths/math";
  48136. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48137. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48138. /**
  48139. * The Physically based simple base material of BJS.
  48140. *
  48141. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48142. * It is used as the base class for both the specGloss and metalRough conventions.
  48143. */
  48144. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48145. /**
  48146. * Number of Simultaneous lights allowed on the material.
  48147. */
  48148. maxSimultaneousLights: number;
  48149. /**
  48150. * If sets to true, disables all the lights affecting the material.
  48151. */
  48152. disableLighting: boolean;
  48153. /**
  48154. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48155. */
  48156. environmentTexture: BaseTexture;
  48157. /**
  48158. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48159. */
  48160. invertNormalMapX: boolean;
  48161. /**
  48162. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48163. */
  48164. invertNormalMapY: boolean;
  48165. /**
  48166. * Normal map used in the model.
  48167. */
  48168. normalTexture: BaseTexture;
  48169. /**
  48170. * Emissivie color used to self-illuminate the model.
  48171. */
  48172. emissiveColor: Color3;
  48173. /**
  48174. * Emissivie texture used to self-illuminate the model.
  48175. */
  48176. emissiveTexture: BaseTexture;
  48177. /**
  48178. * Occlusion Channel Strenght.
  48179. */
  48180. occlusionStrength: number;
  48181. /**
  48182. * Occlusion Texture of the material (adding extra occlusion effects).
  48183. */
  48184. occlusionTexture: BaseTexture;
  48185. /**
  48186. * Defines the alpha limits in alpha test mode.
  48187. */
  48188. alphaCutOff: number;
  48189. /**
  48190. * Gets the current double sided mode.
  48191. */
  48192. /**
  48193. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48194. */
  48195. doubleSided: boolean;
  48196. /**
  48197. * Stores the pre-calculated light information of a mesh in a texture.
  48198. */
  48199. lightmapTexture: BaseTexture;
  48200. /**
  48201. * If true, the light map contains occlusion information instead of lighting info.
  48202. */
  48203. useLightmapAsShadowmap: boolean;
  48204. /**
  48205. * Instantiates a new PBRMaterial instance.
  48206. *
  48207. * @param name The material name
  48208. * @param scene The scene the material will be use in.
  48209. */
  48210. constructor(name: string, scene: Scene);
  48211. getClassName(): string;
  48212. }
  48213. }
  48214. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  48215. import { Scene } from "babylonjs/scene";
  48216. import { Color3 } from "babylonjs/Maths/math";
  48217. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48218. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48219. /**
  48220. * The PBR material of BJS following the metal roughness convention.
  48221. *
  48222. * This fits to the PBR convention in the GLTF definition:
  48223. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48224. */
  48225. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48226. /**
  48227. * The base color has two different interpretations depending on the value of metalness.
  48228. * When the material is a metal, the base color is the specific measured reflectance value
  48229. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48230. * of the material.
  48231. */
  48232. baseColor: Color3;
  48233. /**
  48234. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48235. * well as opacity information in the alpha channel.
  48236. */
  48237. baseTexture: BaseTexture;
  48238. /**
  48239. * Specifies the metallic scalar value of the material.
  48240. * Can also be used to scale the metalness values of the metallic texture.
  48241. */
  48242. metallic: number;
  48243. /**
  48244. * Specifies the roughness scalar value of the material.
  48245. * Can also be used to scale the roughness values of the metallic texture.
  48246. */
  48247. roughness: number;
  48248. /**
  48249. * Texture containing both the metallic value in the B channel and the
  48250. * roughness value in the G channel to keep better precision.
  48251. */
  48252. metallicRoughnessTexture: BaseTexture;
  48253. /**
  48254. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48255. *
  48256. * @param name The material name
  48257. * @param scene The scene the material will be use in.
  48258. */
  48259. constructor(name: string, scene: Scene);
  48260. /**
  48261. * Return the currrent class name of the material.
  48262. */
  48263. getClassName(): string;
  48264. /**
  48265. * Makes a duplicate of the current material.
  48266. * @param name - name to use for the new material.
  48267. */
  48268. clone(name: string): PBRMetallicRoughnessMaterial;
  48269. /**
  48270. * Serialize the material to a parsable JSON object.
  48271. */
  48272. serialize(): any;
  48273. /**
  48274. * Parses a JSON object correponding to the serialize function.
  48275. */
  48276. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48277. }
  48278. }
  48279. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  48280. import { Scene } from "babylonjs/scene";
  48281. import { Color3 } from "babylonjs/Maths/math";
  48282. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48283. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48284. /**
  48285. * The PBR material of BJS following the specular glossiness convention.
  48286. *
  48287. * This fits to the PBR convention in the GLTF definition:
  48288. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48289. */
  48290. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48291. /**
  48292. * Specifies the diffuse color of the material.
  48293. */
  48294. diffuseColor: Color3;
  48295. /**
  48296. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48297. * channel.
  48298. */
  48299. diffuseTexture: BaseTexture;
  48300. /**
  48301. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48302. */
  48303. specularColor: Color3;
  48304. /**
  48305. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48306. */
  48307. glossiness: number;
  48308. /**
  48309. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48310. */
  48311. specularGlossinessTexture: BaseTexture;
  48312. /**
  48313. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48314. *
  48315. * @param name The material name
  48316. * @param scene The scene the material will be use in.
  48317. */
  48318. constructor(name: string, scene: Scene);
  48319. /**
  48320. * Return the currrent class name of the material.
  48321. */
  48322. getClassName(): string;
  48323. /**
  48324. * Makes a duplicate of the current material.
  48325. * @param name - name to use for the new material.
  48326. */
  48327. clone(name: string): PBRSpecularGlossinessMaterial;
  48328. /**
  48329. * Serialize the material to a parsable JSON object.
  48330. */
  48331. serialize(): any;
  48332. /**
  48333. * Parses a JSON object correponding to the serialize function.
  48334. */
  48335. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48336. }
  48337. }
  48338. declare module "babylonjs/Materials/PBR/index" {
  48339. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48340. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48341. export * from "babylonjs/Materials/PBR/pbrMaterial";
  48342. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  48343. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  48344. }
  48345. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  48346. import { Nullable } from "babylonjs/types";
  48347. import { Scene } from "babylonjs/scene";
  48348. import { Matrix } from "babylonjs/Maths/math";
  48349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48350. /**
  48351. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48352. * It can help converting any input color in a desired output one. This can then be used to create effects
  48353. * from sepia, black and white to sixties or futuristic rendering...
  48354. *
  48355. * The only supported format is currently 3dl.
  48356. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48357. */
  48358. export class ColorGradingTexture extends BaseTexture {
  48359. /**
  48360. * The current texture matrix. (will always be identity in color grading texture)
  48361. */
  48362. private _textureMatrix;
  48363. /**
  48364. * The texture URL.
  48365. */
  48366. url: string;
  48367. /**
  48368. * Empty line regex stored for GC.
  48369. */
  48370. private static _noneEmptyLineRegex;
  48371. private _engine;
  48372. /**
  48373. * Instantiates a ColorGradingTexture from the following parameters.
  48374. *
  48375. * @param url The location of the color gradind data (currently only supporting 3dl)
  48376. * @param scene The scene the texture will be used in
  48377. */
  48378. constructor(url: string, scene: Scene);
  48379. /**
  48380. * Returns the texture matrix used in most of the material.
  48381. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48382. */
  48383. getTextureMatrix(): Matrix;
  48384. /**
  48385. * Occurs when the file being loaded is a .3dl LUT file.
  48386. */
  48387. private load3dlTexture;
  48388. /**
  48389. * Starts the loading process of the texture.
  48390. */
  48391. private loadTexture;
  48392. /**
  48393. * Clones the color gradind texture.
  48394. */
  48395. clone(): ColorGradingTexture;
  48396. /**
  48397. * Called during delayed load for textures.
  48398. */
  48399. delayLoad(): void;
  48400. /**
  48401. * Parses a color grading texture serialized by Babylon.
  48402. * @param parsedTexture The texture information being parsedTexture
  48403. * @param scene The scene to load the texture in
  48404. * @param rootUrl The root url of the data assets to load
  48405. * @return A color gradind texture
  48406. */
  48407. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48408. /**
  48409. * Serializes the LUT texture to json format.
  48410. */
  48411. serialize(): any;
  48412. }
  48413. }
  48414. declare module "babylonjs/Misc/dds" {
  48415. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48416. import { Engine } from "babylonjs/Engines/engine";
  48417. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48418. import { Nullable } from "babylonjs/types";
  48419. import { Scene } from "babylonjs/scene";
  48420. /**
  48421. * Direct draw surface info
  48422. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48423. */
  48424. export interface DDSInfo {
  48425. /**
  48426. * Width of the texture
  48427. */
  48428. width: number;
  48429. /**
  48430. * Width of the texture
  48431. */
  48432. height: number;
  48433. /**
  48434. * Number of Mipmaps for the texture
  48435. * @see https://en.wikipedia.org/wiki/Mipmap
  48436. */
  48437. mipmapCount: number;
  48438. /**
  48439. * If the textures format is a known fourCC format
  48440. * @see https://www.fourcc.org/
  48441. */
  48442. isFourCC: boolean;
  48443. /**
  48444. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48445. */
  48446. isRGB: boolean;
  48447. /**
  48448. * If the texture is a lumincance format
  48449. */
  48450. isLuminance: boolean;
  48451. /**
  48452. * If this is a cube texture
  48453. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48454. */
  48455. isCube: boolean;
  48456. /**
  48457. * If the texture is a compressed format eg. FOURCC_DXT1
  48458. */
  48459. isCompressed: boolean;
  48460. /**
  48461. * The dxgiFormat of the texture
  48462. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48463. */
  48464. dxgiFormat: number;
  48465. /**
  48466. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48467. */
  48468. textureType: number;
  48469. /**
  48470. * Sphericle polynomial created for the dds texture
  48471. */
  48472. sphericalPolynomial?: SphericalPolynomial;
  48473. }
  48474. /**
  48475. * Class used to provide DDS decompression tools
  48476. */
  48477. export class DDSTools {
  48478. /**
  48479. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48480. */
  48481. static StoreLODInAlphaChannel: boolean;
  48482. /**
  48483. * Gets DDS information from an array buffer
  48484. * @param arrayBuffer defines the array buffer to read data from
  48485. * @returns the DDS information
  48486. */
  48487. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48488. private static _FloatView;
  48489. private static _Int32View;
  48490. private static _ToHalfFloat;
  48491. private static _FromHalfFloat;
  48492. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48493. private static _GetHalfFloatRGBAArrayBuffer;
  48494. private static _GetFloatRGBAArrayBuffer;
  48495. private static _GetFloatAsUIntRGBAArrayBuffer;
  48496. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48497. private static _GetRGBAArrayBuffer;
  48498. private static _ExtractLongWordOrder;
  48499. private static _GetRGBArrayBuffer;
  48500. private static _GetLuminanceArrayBuffer;
  48501. /**
  48502. * Uploads DDS Levels to a Babylon Texture
  48503. * @hidden
  48504. */
  48505. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48506. }
  48507. module "babylonjs/Engines/engine" {
  48508. interface Engine {
  48509. /**
  48510. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48511. * @param rootUrl defines the url where the file to load is located
  48512. * @param scene defines the current scene
  48513. * @param lodScale defines scale to apply to the mip map selection
  48514. * @param lodOffset defines offset to apply to the mip map selection
  48515. * @param onLoad defines an optional callback raised when the texture is loaded
  48516. * @param onError defines an optional callback raised if there is an issue to load the texture
  48517. * @param format defines the format of the data
  48518. * @param forcedExtension defines the extension to use to pick the right loader
  48519. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48520. * @returns the cube texture as an InternalTexture
  48521. */
  48522. 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;
  48523. }
  48524. }
  48525. }
  48526. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48527. import { Nullable } from "babylonjs/types";
  48528. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48529. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48530. /**
  48531. * Implementation of the DDS Texture Loader.
  48532. * @hidden
  48533. */
  48534. export class _DDSTextureLoader implements IInternalTextureLoader {
  48535. /**
  48536. * Defines wether the loader supports cascade loading the different faces.
  48537. */
  48538. readonly supportCascades: boolean;
  48539. /**
  48540. * This returns if the loader support the current file information.
  48541. * @param extension defines the file extension of the file being loaded
  48542. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48543. * @param fallback defines the fallback internal texture if any
  48544. * @param isBase64 defines whether the texture is encoded as a base64
  48545. * @param isBuffer defines whether the texture data are stored as a buffer
  48546. * @returns true if the loader can load the specified file
  48547. */
  48548. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48549. /**
  48550. * Transform the url before loading if required.
  48551. * @param rootUrl the url of the texture
  48552. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48553. * @returns the transformed texture
  48554. */
  48555. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48556. /**
  48557. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48558. * @param rootUrl the url of the texture
  48559. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48560. * @returns the fallback texture
  48561. */
  48562. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48563. /**
  48564. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48565. * @param data contains the texture data
  48566. * @param texture defines the BabylonJS internal texture
  48567. * @param createPolynomials will be true if polynomials have been requested
  48568. * @param onLoad defines the callback to trigger once the texture is ready
  48569. * @param onError defines the callback to trigger in case of error
  48570. */
  48571. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48572. /**
  48573. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48574. * @param data contains the texture data
  48575. * @param texture defines the BabylonJS internal texture
  48576. * @param callback defines the method to call once ready to upload
  48577. */
  48578. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48579. }
  48580. }
  48581. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48582. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48583. /** @hidden */
  48584. export var rgbdEncodePixelShader: {
  48585. name: string;
  48586. shader: string;
  48587. };
  48588. }
  48589. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48590. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48591. /** @hidden */
  48592. export var rgbdDecodePixelShader: {
  48593. name: string;
  48594. shader: string;
  48595. };
  48596. }
  48597. declare module "babylonjs/Misc/environmentTextureTools" {
  48598. import { Nullable } from "babylonjs/types";
  48599. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48600. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48601. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48602. import "babylonjs/Shaders/rgbdEncode.fragment";
  48603. import "babylonjs/Shaders/rgbdDecode.fragment";
  48604. /**
  48605. * Raw texture data and descriptor sufficient for WebGL texture upload
  48606. */
  48607. export interface EnvironmentTextureInfo {
  48608. /**
  48609. * Version of the environment map
  48610. */
  48611. version: number;
  48612. /**
  48613. * Width of image
  48614. */
  48615. width: number;
  48616. /**
  48617. * Irradiance information stored in the file.
  48618. */
  48619. irradiance: any;
  48620. /**
  48621. * Specular information stored in the file.
  48622. */
  48623. specular: any;
  48624. }
  48625. /**
  48626. * Sets of helpers addressing the serialization and deserialization of environment texture
  48627. * stored in a BabylonJS env file.
  48628. * Those files are usually stored as .env files.
  48629. */
  48630. export class EnvironmentTextureTools {
  48631. /**
  48632. * Magic number identifying the env file.
  48633. */
  48634. private static _MagicBytes;
  48635. /**
  48636. * Gets the environment info from an env file.
  48637. * @param data The array buffer containing the .env bytes.
  48638. * @returns the environment file info (the json header) if successfully parsed.
  48639. */
  48640. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48641. /**
  48642. * Creates an environment texture from a loaded cube texture.
  48643. * @param texture defines the cube texture to convert in env file
  48644. * @return a promise containing the environment data if succesfull.
  48645. */
  48646. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48647. /**
  48648. * Creates a JSON representation of the spherical data.
  48649. * @param texture defines the texture containing the polynomials
  48650. * @return the JSON representation of the spherical info
  48651. */
  48652. private static _CreateEnvTextureIrradiance;
  48653. /**
  48654. * Uploads the texture info contained in the env file to the GPU.
  48655. * @param texture defines the internal texture to upload to
  48656. * @param arrayBuffer defines the buffer cotaining the data to load
  48657. * @param info defines the texture info retrieved through the GetEnvInfo method
  48658. * @returns a promise
  48659. */
  48660. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48661. /**
  48662. * Uploads the levels of image data to the GPU.
  48663. * @param texture defines the internal texture to upload to
  48664. * @param imageData defines the array buffer views of image data [mipmap][face]
  48665. * @returns a promise
  48666. */
  48667. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48668. /**
  48669. * Uploads spherical polynomials information to the texture.
  48670. * @param texture defines the texture we are trying to upload the information to
  48671. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48672. */
  48673. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48674. /** @hidden */
  48675. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48676. }
  48677. }
  48678. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48679. import { Nullable } from "babylonjs/types";
  48680. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48681. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48682. /**
  48683. * Implementation of the ENV Texture Loader.
  48684. * @hidden
  48685. */
  48686. export class _ENVTextureLoader implements IInternalTextureLoader {
  48687. /**
  48688. * Defines wether the loader supports cascade loading the different faces.
  48689. */
  48690. readonly supportCascades: boolean;
  48691. /**
  48692. * This returns if the loader support the current file information.
  48693. * @param extension defines the file extension of the file being loaded
  48694. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48695. * @param fallback defines the fallback internal texture if any
  48696. * @param isBase64 defines whether the texture is encoded as a base64
  48697. * @param isBuffer defines whether the texture data are stored as a buffer
  48698. * @returns true if the loader can load the specified file
  48699. */
  48700. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48701. /**
  48702. * Transform the url before loading if required.
  48703. * @param rootUrl the url of the texture
  48704. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48705. * @returns the transformed texture
  48706. */
  48707. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48708. /**
  48709. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48710. * @param rootUrl the url of the texture
  48711. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48712. * @returns the fallback texture
  48713. */
  48714. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48715. /**
  48716. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48717. * @param data contains the texture data
  48718. * @param texture defines the BabylonJS internal texture
  48719. * @param createPolynomials will be true if polynomials have been requested
  48720. * @param onLoad defines the callback to trigger once the texture is ready
  48721. * @param onError defines the callback to trigger in case of error
  48722. */
  48723. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48724. /**
  48725. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48726. * @param data contains the texture data
  48727. * @param texture defines the BabylonJS internal texture
  48728. * @param callback defines the method to call once ready to upload
  48729. */
  48730. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48731. }
  48732. }
  48733. declare module "babylonjs/Misc/khronosTextureContainer" {
  48734. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48735. /**
  48736. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48737. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48738. */
  48739. export class KhronosTextureContainer {
  48740. /** contents of the KTX container file */
  48741. arrayBuffer: any;
  48742. private static HEADER_LEN;
  48743. private static COMPRESSED_2D;
  48744. private static COMPRESSED_3D;
  48745. private static TEX_2D;
  48746. private static TEX_3D;
  48747. /**
  48748. * Gets the openGL type
  48749. */
  48750. glType: number;
  48751. /**
  48752. * Gets the openGL type size
  48753. */
  48754. glTypeSize: number;
  48755. /**
  48756. * Gets the openGL format
  48757. */
  48758. glFormat: number;
  48759. /**
  48760. * Gets the openGL internal format
  48761. */
  48762. glInternalFormat: number;
  48763. /**
  48764. * Gets the base internal format
  48765. */
  48766. glBaseInternalFormat: number;
  48767. /**
  48768. * Gets image width in pixel
  48769. */
  48770. pixelWidth: number;
  48771. /**
  48772. * Gets image height in pixel
  48773. */
  48774. pixelHeight: number;
  48775. /**
  48776. * Gets image depth in pixels
  48777. */
  48778. pixelDepth: number;
  48779. /**
  48780. * Gets the number of array elements
  48781. */
  48782. numberOfArrayElements: number;
  48783. /**
  48784. * Gets the number of faces
  48785. */
  48786. numberOfFaces: number;
  48787. /**
  48788. * Gets the number of mipmap levels
  48789. */
  48790. numberOfMipmapLevels: number;
  48791. /**
  48792. * Gets the bytes of key value data
  48793. */
  48794. bytesOfKeyValueData: number;
  48795. /**
  48796. * Gets the load type
  48797. */
  48798. loadType: number;
  48799. /**
  48800. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48801. */
  48802. isInvalid: boolean;
  48803. /**
  48804. * Creates a new KhronosTextureContainer
  48805. * @param arrayBuffer contents of the KTX container file
  48806. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48807. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48808. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48809. */
  48810. constructor(
  48811. /** contents of the KTX container file */
  48812. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48813. /**
  48814. * Uploads KTX content to a Babylon Texture.
  48815. * It is assumed that the texture has already been created & is currently bound
  48816. * @hidden
  48817. */
  48818. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48819. private _upload2DCompressedLevels;
  48820. }
  48821. }
  48822. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48823. import { Nullable } from "babylonjs/types";
  48824. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48825. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48826. /**
  48827. * Implementation of the KTX Texture Loader.
  48828. * @hidden
  48829. */
  48830. export class _KTXTextureLoader implements IInternalTextureLoader {
  48831. /**
  48832. * Defines wether the loader supports cascade loading the different faces.
  48833. */
  48834. readonly supportCascades: boolean;
  48835. /**
  48836. * This returns if the loader support the current file information.
  48837. * @param extension defines the file extension of the file being loaded
  48838. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48839. * @param fallback defines the fallback internal texture if any
  48840. * @param isBase64 defines whether the texture is encoded as a base64
  48841. * @param isBuffer defines whether the texture data are stored as a buffer
  48842. * @returns true if the loader can load the specified file
  48843. */
  48844. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48845. /**
  48846. * Transform the url before loading if required.
  48847. * @param rootUrl the url of the texture
  48848. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48849. * @returns the transformed texture
  48850. */
  48851. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48852. /**
  48853. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48854. * @param rootUrl the url of the texture
  48855. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48856. * @returns the fallback texture
  48857. */
  48858. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48859. /**
  48860. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48861. * @param data contains the texture data
  48862. * @param texture defines the BabylonJS internal texture
  48863. * @param createPolynomials will be true if polynomials have been requested
  48864. * @param onLoad defines the callback to trigger once the texture is ready
  48865. * @param onError defines the callback to trigger in case of error
  48866. */
  48867. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48868. /**
  48869. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48870. * @param data contains the texture data
  48871. * @param texture defines the BabylonJS internal texture
  48872. * @param callback defines the method to call once ready to upload
  48873. */
  48874. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48875. }
  48876. }
  48877. declare module "babylonjs/Misc/tga" {
  48878. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48879. /**
  48880. * Based on jsTGALoader - Javascript loader for TGA file
  48881. * By Vincent Thibault
  48882. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48883. */
  48884. export class TGATools {
  48885. private static _TYPE_INDEXED;
  48886. private static _TYPE_RGB;
  48887. private static _TYPE_GREY;
  48888. private static _TYPE_RLE_INDEXED;
  48889. private static _TYPE_RLE_RGB;
  48890. private static _TYPE_RLE_GREY;
  48891. private static _ORIGIN_MASK;
  48892. private static _ORIGIN_SHIFT;
  48893. private static _ORIGIN_BL;
  48894. private static _ORIGIN_BR;
  48895. private static _ORIGIN_UL;
  48896. private static _ORIGIN_UR;
  48897. /**
  48898. * Gets the header of a TGA file
  48899. * @param data defines the TGA data
  48900. * @returns the header
  48901. */
  48902. static GetTGAHeader(data: Uint8Array): any;
  48903. /**
  48904. * Uploads TGA content to a Babylon Texture
  48905. * @hidden
  48906. */
  48907. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48908. /** @hidden */
  48909. 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;
  48910. /** @hidden */
  48911. 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;
  48912. /** @hidden */
  48913. 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;
  48914. /** @hidden */
  48915. 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;
  48916. /** @hidden */
  48917. 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;
  48918. /** @hidden */
  48919. 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;
  48920. }
  48921. }
  48922. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  48923. import { Nullable } from "babylonjs/types";
  48924. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48925. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48926. /**
  48927. * Implementation of the TGA Texture Loader.
  48928. * @hidden
  48929. */
  48930. export class _TGATextureLoader implements IInternalTextureLoader {
  48931. /**
  48932. * Defines wether the loader supports cascade loading the different faces.
  48933. */
  48934. readonly supportCascades: boolean;
  48935. /**
  48936. * This returns if the loader support the current file information.
  48937. * @param extension defines the file extension of the file being loaded
  48938. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48939. * @param fallback defines the fallback internal texture if any
  48940. * @param isBase64 defines whether the texture is encoded as a base64
  48941. * @param isBuffer defines whether the texture data are stored as a buffer
  48942. * @returns true if the loader can load the specified file
  48943. */
  48944. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48945. /**
  48946. * Transform the url before loading if required.
  48947. * @param rootUrl the url of the texture
  48948. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48949. * @returns the transformed texture
  48950. */
  48951. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48952. /**
  48953. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48954. * @param rootUrl the url of the texture
  48955. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48956. * @returns the fallback texture
  48957. */
  48958. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48959. /**
  48960. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48961. * @param data contains the texture data
  48962. * @param texture defines the BabylonJS internal texture
  48963. * @param createPolynomials will be true if polynomials have been requested
  48964. * @param onLoad defines the callback to trigger once the texture is ready
  48965. * @param onError defines the callback to trigger in case of error
  48966. */
  48967. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48968. /**
  48969. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48970. * @param data contains the texture data
  48971. * @param texture defines the BabylonJS internal texture
  48972. * @param callback defines the method to call once ready to upload
  48973. */
  48974. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48975. }
  48976. }
  48977. declare module "babylonjs/Materials/Textures/Loaders/index" {
  48978. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48979. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48980. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48981. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  48982. }
  48983. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  48984. import { Scene } from "babylonjs/scene";
  48985. import { Texture } from "babylonjs/Materials/Textures/texture";
  48986. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48987. /**
  48988. * 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.
  48989. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48990. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48991. */
  48992. export class CustomProceduralTexture extends ProceduralTexture {
  48993. private _animate;
  48994. private _time;
  48995. private _config;
  48996. private _texturePath;
  48997. /**
  48998. * Instantiates a new Custom Procedural Texture.
  48999. * 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.
  49000. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49001. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49002. * @param name Define the name of the texture
  49003. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49004. * @param size Define the size of the texture to create
  49005. * @param scene Define the scene the texture belongs to
  49006. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49007. * @param generateMipMaps Define if the texture should creates mip maps or not
  49008. */
  49009. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49010. private _loadJson;
  49011. /**
  49012. * Is the texture ready to be used ? (rendered at least once)
  49013. * @returns true if ready, otherwise, false.
  49014. */
  49015. isReady(): boolean;
  49016. /**
  49017. * Render the texture to its associated render target.
  49018. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49019. */
  49020. render(useCameraPostProcess?: boolean): void;
  49021. /**
  49022. * Update the list of dependant textures samplers in the shader.
  49023. */
  49024. updateTextures(): void;
  49025. /**
  49026. * Update the uniform values of the procedural texture in the shader.
  49027. */
  49028. updateShaderUniforms(): void;
  49029. /**
  49030. * Define if the texture animates or not.
  49031. */
  49032. animate: boolean;
  49033. }
  49034. }
  49035. declare module "babylonjs/Shaders/noise.fragment" {
  49036. /** @hidden */
  49037. export var noisePixelShader: {
  49038. name: string;
  49039. shader: string;
  49040. };
  49041. }
  49042. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49043. import { Nullable } from "babylonjs/types";
  49044. import { Scene } from "babylonjs/scene";
  49045. import { Texture } from "babylonjs/Materials/Textures/texture";
  49046. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49047. import "babylonjs/Shaders/noise.fragment";
  49048. /**
  49049. * Class used to generate noise procedural textures
  49050. */
  49051. export class NoiseProceduralTexture extends ProceduralTexture {
  49052. private _time;
  49053. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49054. brightness: number;
  49055. /** Defines the number of octaves to process */
  49056. octaves: number;
  49057. /** Defines the level of persistence (0.8 by default) */
  49058. persistence: number;
  49059. /** Gets or sets animation speed factor (default is 1) */
  49060. animationSpeedFactor: number;
  49061. /**
  49062. * Creates a new NoiseProceduralTexture
  49063. * @param name defines the name fo the texture
  49064. * @param size defines the size of the texture (default is 256)
  49065. * @param scene defines the hosting scene
  49066. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49067. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49068. */
  49069. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49070. private _updateShaderUniforms;
  49071. protected _getDefines(): string;
  49072. /** Generate the current state of the procedural texture */
  49073. render(useCameraPostProcess?: boolean): void;
  49074. /**
  49075. * Serializes this noise procedural texture
  49076. * @returns a serialized noise procedural texture object
  49077. */
  49078. serialize(): any;
  49079. /**
  49080. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49081. * @param parsedTexture defines parsed texture data
  49082. * @param scene defines the current scene
  49083. * @param rootUrl defines the root URL containing noise procedural texture information
  49084. * @returns a parsed NoiseProceduralTexture
  49085. */
  49086. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49087. }
  49088. }
  49089. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49090. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49091. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49092. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49093. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49094. }
  49095. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49096. import { Nullable } from "babylonjs/types";
  49097. import { Scene } from "babylonjs/scene";
  49098. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49099. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49100. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49101. /**
  49102. * Raw cube texture where the raw buffers are passed in
  49103. */
  49104. export class RawCubeTexture extends CubeTexture {
  49105. /**
  49106. * Creates a cube texture where the raw buffers are passed in.
  49107. * @param scene defines the scene the texture is attached to
  49108. * @param data defines the array of data to use to create each face
  49109. * @param size defines the size of the textures
  49110. * @param format defines the format of the data
  49111. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49112. * @param generateMipMaps defines if the engine should generate the mip levels
  49113. * @param invertY defines if data must be stored with Y axis inverted
  49114. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49115. * @param compression defines the compression used (null by default)
  49116. */
  49117. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49118. /**
  49119. * Updates the raw cube texture.
  49120. * @param data defines the data to store
  49121. * @param format defines the data format
  49122. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49123. * @param invertY defines if data must be stored with Y axis inverted
  49124. * @param compression defines the compression used (null by default)
  49125. * @param level defines which level of the texture to update
  49126. */
  49127. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49128. /**
  49129. * Updates a raw cube texture with RGBD encoded data.
  49130. * @param data defines the array of data [mipmap][face] to use to create each face
  49131. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49132. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49133. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49134. * @returns a promsie that resolves when the operation is complete
  49135. */
  49136. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49137. /**
  49138. * Clones the raw cube texture.
  49139. * @return a new cube texture
  49140. */
  49141. clone(): CubeTexture;
  49142. /** @hidden */
  49143. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49144. }
  49145. }
  49146. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49147. import { Scene } from "babylonjs/scene";
  49148. import { Texture } from "babylonjs/Materials/Textures/texture";
  49149. /**
  49150. * Class used to store 3D textures containing user data
  49151. */
  49152. export class RawTexture3D extends Texture {
  49153. /** Gets or sets the texture format to use */
  49154. format: number;
  49155. private _engine;
  49156. /**
  49157. * Create a new RawTexture3D
  49158. * @param data defines the data of the texture
  49159. * @param width defines the width of the texture
  49160. * @param height defines the height of the texture
  49161. * @param depth defines the depth of the texture
  49162. * @param format defines the texture format to use
  49163. * @param scene defines the hosting scene
  49164. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49165. * @param invertY defines if texture must be stored with Y axis inverted
  49166. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49167. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49168. */
  49169. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49170. /** Gets or sets the texture format to use */
  49171. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49172. /**
  49173. * Update the texture with new data
  49174. * @param data defines the data to store in the texture
  49175. */
  49176. update(data: ArrayBufferView): void;
  49177. }
  49178. }
  49179. declare module "babylonjs/Materials/Textures/refractionTexture" {
  49180. import { Scene } from "babylonjs/scene";
  49181. import { Plane } from "babylonjs/Maths/math";
  49182. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49183. /**
  49184. * Creates a refraction texture used by refraction channel of the standard material.
  49185. * It is like a mirror but to see through a material.
  49186. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49187. */
  49188. export class RefractionTexture extends RenderTargetTexture {
  49189. /**
  49190. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49191. * 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.
  49192. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49193. */
  49194. refractionPlane: Plane;
  49195. /**
  49196. * Define how deep under the surface we should see.
  49197. */
  49198. depth: number;
  49199. /**
  49200. * Creates a refraction texture used by refraction channel of the standard material.
  49201. * It is like a mirror but to see through a material.
  49202. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49203. * @param name Define the texture name
  49204. * @param size Define the size of the underlying texture
  49205. * @param scene Define the scene the refraction belongs to
  49206. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49207. */
  49208. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49209. /**
  49210. * Clone the refraction texture.
  49211. * @returns the cloned texture
  49212. */
  49213. clone(): RefractionTexture;
  49214. /**
  49215. * Serialize the texture to a JSON representation you could use in Parse later on
  49216. * @returns the serialized JSON representation
  49217. */
  49218. serialize(): any;
  49219. }
  49220. }
  49221. declare module "babylonjs/Materials/Textures/index" {
  49222. export * from "babylonjs/Materials/Textures/baseTexture";
  49223. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  49224. export * from "babylonjs/Materials/Textures/cubeTexture";
  49225. export * from "babylonjs/Materials/Textures/dynamicTexture";
  49226. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  49227. export * from "babylonjs/Materials/Textures/internalTexture";
  49228. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  49229. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  49230. export * from "babylonjs/Materials/Textures/Loaders/index";
  49231. export * from "babylonjs/Materials/Textures/mirrorTexture";
  49232. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  49233. export * from "babylonjs/Materials/Textures/Procedurals/index";
  49234. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  49235. export * from "babylonjs/Materials/Textures/rawTexture";
  49236. export * from "babylonjs/Materials/Textures/rawTexture3D";
  49237. export * from "babylonjs/Materials/Textures/refractionTexture";
  49238. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  49239. export * from "babylonjs/Materials/Textures/texture";
  49240. export * from "babylonjs/Materials/Textures/videoTexture";
  49241. }
  49242. declare module "babylonjs/Materials/index" {
  49243. export * from "babylonjs/Materials/Background/index";
  49244. export * from "babylonjs/Materials/colorCurves";
  49245. export * from "babylonjs/Materials/effect";
  49246. export * from "babylonjs/Materials/fresnelParameters";
  49247. export * from "babylonjs/Materials/imageProcessingConfiguration";
  49248. export * from "babylonjs/Materials/material";
  49249. export * from "babylonjs/Materials/materialDefines";
  49250. export * from "babylonjs/Materials/materialHelper";
  49251. export * from "babylonjs/Materials/multiMaterial";
  49252. export * from "babylonjs/Materials/PBR/index";
  49253. export * from "babylonjs/Materials/pushMaterial";
  49254. export * from "babylonjs/Materials/shaderMaterial";
  49255. export * from "babylonjs/Materials/standardMaterial";
  49256. export * from "babylonjs/Materials/Textures/index";
  49257. export * from "babylonjs/Materials/uniformBuffer";
  49258. export * from "babylonjs/Materials/materialFlags";
  49259. }
  49260. declare module "babylonjs/Maths/index" {
  49261. export * from "babylonjs/Maths/math.scalar";
  49262. export * from "babylonjs/Maths/math";
  49263. export * from "babylonjs/Maths/sphericalPolynomial";
  49264. }
  49265. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  49266. import { IDisposable } from "babylonjs/scene";
  49267. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  49268. /**
  49269. * Configuration for Draco compression
  49270. */
  49271. export interface IDracoCompressionConfiguration {
  49272. /**
  49273. * Configuration for the decoder.
  49274. */
  49275. decoder?: {
  49276. /**
  49277. * The url to the WebAssembly module.
  49278. */
  49279. wasmUrl?: string;
  49280. /**
  49281. * The url to the WebAssembly binary.
  49282. */
  49283. wasmBinaryUrl?: string;
  49284. /**
  49285. * The url to the fallback JavaScript module.
  49286. */
  49287. fallbackUrl?: string;
  49288. };
  49289. }
  49290. /**
  49291. * Draco compression (https://google.github.io/draco/)
  49292. *
  49293. * This class wraps the Draco module.
  49294. *
  49295. * **Encoder**
  49296. *
  49297. * The encoder is not currently implemented.
  49298. *
  49299. * **Decoder**
  49300. *
  49301. * 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.
  49302. *
  49303. * To update the configuration, use the following code:
  49304. * ```javascript
  49305. * DracoCompression.Configuration = {
  49306. * decoder: {
  49307. * wasmUrl: "<url to the WebAssembly library>",
  49308. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49309. * fallbackUrl: "<url to the fallback JavaScript library>",
  49310. * }
  49311. * };
  49312. * ```
  49313. *
  49314. * 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.
  49315. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49316. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49317. *
  49318. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49319. * ```javascript
  49320. * var dracoCompression = new DracoCompression();
  49321. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49322. * [VertexBuffer.PositionKind]: 0
  49323. * });
  49324. * ```
  49325. *
  49326. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49327. */
  49328. export class DracoCompression implements IDisposable {
  49329. private static _DecoderModulePromise;
  49330. /**
  49331. * The configuration. Defaults to the following urls:
  49332. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49333. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49334. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49335. */
  49336. static Configuration: IDracoCompressionConfiguration;
  49337. /**
  49338. * Returns true if the decoder is available.
  49339. */
  49340. static readonly DecoderAvailable: boolean;
  49341. /**
  49342. * Constructor
  49343. */
  49344. constructor();
  49345. /**
  49346. * Stop all async operations and release resources.
  49347. */
  49348. dispose(): void;
  49349. /**
  49350. * Decode Draco compressed mesh data to vertex data.
  49351. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49352. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49353. * @returns A promise that resolves with the decoded vertex data
  49354. */
  49355. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49356. [kind: string]: number;
  49357. }): Promise<VertexData>;
  49358. private static _GetDecoderModule;
  49359. private static _LoadScriptAsync;
  49360. private static _LoadFileAsync;
  49361. }
  49362. }
  49363. declare module "babylonjs/Meshes/Compression/index" {
  49364. export * from "babylonjs/Meshes/Compression/dracoCompression";
  49365. }
  49366. declare module "babylonjs/Meshes/csg" {
  49367. import { Nullable } from "babylonjs/types";
  49368. import { Scene } from "babylonjs/scene";
  49369. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  49370. import { Mesh } from "babylonjs/Meshes/mesh";
  49371. import { Material } from "babylonjs/Materials/material";
  49372. /**
  49373. * Class for building Constructive Solid Geometry
  49374. */
  49375. export class CSG {
  49376. private polygons;
  49377. /**
  49378. * The world matrix
  49379. */
  49380. matrix: Matrix;
  49381. /**
  49382. * Stores the position
  49383. */
  49384. position: Vector3;
  49385. /**
  49386. * Stores the rotation
  49387. */
  49388. rotation: Vector3;
  49389. /**
  49390. * Stores the rotation quaternion
  49391. */
  49392. rotationQuaternion: Nullable<Quaternion>;
  49393. /**
  49394. * Stores the scaling vector
  49395. */
  49396. scaling: Vector3;
  49397. /**
  49398. * Convert the Mesh to CSG
  49399. * @param mesh The Mesh to convert to CSG
  49400. * @returns A new CSG from the Mesh
  49401. */
  49402. static FromMesh(mesh: Mesh): CSG;
  49403. /**
  49404. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49405. * @param polygons Polygons used to construct a CSG solid
  49406. */
  49407. private static FromPolygons;
  49408. /**
  49409. * Clones, or makes a deep copy, of the CSG
  49410. * @returns A new CSG
  49411. */
  49412. clone(): CSG;
  49413. /**
  49414. * Unions this CSG with another CSG
  49415. * @param csg The CSG to union against this CSG
  49416. * @returns The unioned CSG
  49417. */
  49418. union(csg: CSG): CSG;
  49419. /**
  49420. * Unions this CSG with another CSG in place
  49421. * @param csg The CSG to union against this CSG
  49422. */
  49423. unionInPlace(csg: CSG): void;
  49424. /**
  49425. * Subtracts this CSG with another CSG
  49426. * @param csg The CSG to subtract against this CSG
  49427. * @returns A new CSG
  49428. */
  49429. subtract(csg: CSG): CSG;
  49430. /**
  49431. * Subtracts this CSG with another CSG in place
  49432. * @param csg The CSG to subtact against this CSG
  49433. */
  49434. subtractInPlace(csg: CSG): void;
  49435. /**
  49436. * Intersect this CSG with another CSG
  49437. * @param csg The CSG to intersect against this CSG
  49438. * @returns A new CSG
  49439. */
  49440. intersect(csg: CSG): CSG;
  49441. /**
  49442. * Intersects this CSG with another CSG in place
  49443. * @param csg The CSG to intersect against this CSG
  49444. */
  49445. intersectInPlace(csg: CSG): void;
  49446. /**
  49447. * Return a new CSG solid with solid and empty space switched. This solid is
  49448. * not modified.
  49449. * @returns A new CSG solid with solid and empty space switched
  49450. */
  49451. inverse(): CSG;
  49452. /**
  49453. * Inverses the CSG in place
  49454. */
  49455. inverseInPlace(): void;
  49456. /**
  49457. * This is used to keep meshes transformations so they can be restored
  49458. * when we build back a Babylon Mesh
  49459. * NB : All CSG operations are performed in world coordinates
  49460. * @param csg The CSG to copy the transform attributes from
  49461. * @returns This CSG
  49462. */
  49463. copyTransformAttributes(csg: CSG): CSG;
  49464. /**
  49465. * Build Raw mesh from CSG
  49466. * Coordinates here are in world space
  49467. * @param name The name of the mesh geometry
  49468. * @param scene The Scene
  49469. * @param keepSubMeshes Specifies if the submeshes should be kept
  49470. * @returns A new Mesh
  49471. */
  49472. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49473. /**
  49474. * Build Mesh from CSG taking material and transforms into account
  49475. * @param name The name of the Mesh
  49476. * @param material The material of the Mesh
  49477. * @param scene The Scene
  49478. * @param keepSubMeshes Specifies if submeshes should be kept
  49479. * @returns The new Mesh
  49480. */
  49481. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49482. }
  49483. }
  49484. declare module "babylonjs/Meshes/trailMesh" {
  49485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49486. import { Mesh } from "babylonjs/Meshes/mesh";
  49487. import { Scene } from "babylonjs/scene";
  49488. /**
  49489. * Class used to create a trail following a mesh
  49490. */
  49491. export class TrailMesh extends Mesh {
  49492. private _generator;
  49493. private _autoStart;
  49494. private _running;
  49495. private _diameter;
  49496. private _length;
  49497. private _sectionPolygonPointsCount;
  49498. private _sectionVectors;
  49499. private _sectionNormalVectors;
  49500. private _beforeRenderObserver;
  49501. /**
  49502. * @constructor
  49503. * @param name The value used by scene.getMeshByName() to do a lookup.
  49504. * @param generator The mesh to generate a trail.
  49505. * @param scene The scene to add this mesh to.
  49506. * @param diameter Diameter of trailing mesh. Default is 1.
  49507. * @param length Length of trailing mesh. Default is 60.
  49508. * @param autoStart Automatically start trailing mesh. Default true.
  49509. */
  49510. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49511. /**
  49512. * "TrailMesh"
  49513. * @returns "TrailMesh"
  49514. */
  49515. getClassName(): string;
  49516. private _createMesh;
  49517. /**
  49518. * Start trailing mesh.
  49519. */
  49520. start(): void;
  49521. /**
  49522. * Stop trailing mesh.
  49523. */
  49524. stop(): void;
  49525. /**
  49526. * Update trailing mesh geometry.
  49527. */
  49528. update(): void;
  49529. /**
  49530. * Returns a new TrailMesh object.
  49531. * @param name is a string, the name given to the new mesh
  49532. * @param newGenerator use new generator object for cloned trail mesh
  49533. * @returns a new mesh
  49534. */
  49535. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49536. /**
  49537. * Serializes this trail mesh
  49538. * @param serializationObject object to write serialization to
  49539. */
  49540. serialize(serializationObject: any): void;
  49541. /**
  49542. * Parses a serialized trail mesh
  49543. * @param parsedMesh the serialized mesh
  49544. * @param scene the scene to create the trail mesh in
  49545. * @returns the created trail mesh
  49546. */
  49547. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49548. }
  49549. }
  49550. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49551. import { Nullable } from "babylonjs/types";
  49552. import { Scene } from "babylonjs/scene";
  49553. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49554. import { Mesh } from "babylonjs/Meshes/mesh";
  49555. /**
  49556. * Class containing static functions to help procedurally build meshes
  49557. */
  49558. export class RibbonBuilder {
  49559. /**
  49560. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49561. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49562. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49563. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49564. * * 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
  49565. * * 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
  49566. * * 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
  49567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49568. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49569. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49570. * * 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
  49571. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49572. * * 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
  49573. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49575. * @param name defines the name of the mesh
  49576. * @param options defines the options used to create the mesh
  49577. * @param scene defines the hosting scene
  49578. * @returns the ribbon mesh
  49579. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49580. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49581. */
  49582. static CreateRibbon(name: string, options: {
  49583. pathArray: Vector3[][];
  49584. closeArray?: boolean;
  49585. closePath?: boolean;
  49586. offset?: number;
  49587. updatable?: boolean;
  49588. sideOrientation?: number;
  49589. frontUVs?: Vector4;
  49590. backUVs?: Vector4;
  49591. instance?: Mesh;
  49592. invertUV?: boolean;
  49593. uvs?: Vector2[];
  49594. colors?: Color4[];
  49595. }, scene?: Nullable<Scene>): Mesh;
  49596. }
  49597. }
  49598. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  49599. import { Vector4 } from "babylonjs/Maths/math";
  49600. import { Mesh } from "babylonjs/Meshes/mesh";
  49601. /**
  49602. * Class containing static functions to help procedurally build meshes
  49603. */
  49604. export class TorusKnotBuilder {
  49605. /**
  49606. * Creates a torus knot mesh
  49607. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49608. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49609. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49610. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49612. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49614. * @param name defines the name of the mesh
  49615. * @param options defines the options used to create the mesh
  49616. * @param scene defines the hosting scene
  49617. * @returns the torus knot mesh
  49618. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49619. */
  49620. static CreateTorusKnot(name: string, options: {
  49621. radius?: number;
  49622. tube?: number;
  49623. radialSegments?: number;
  49624. tubularSegments?: number;
  49625. p?: number;
  49626. q?: number;
  49627. updatable?: boolean;
  49628. sideOrientation?: number;
  49629. frontUVs?: Vector4;
  49630. backUVs?: Vector4;
  49631. }, scene: any): Mesh;
  49632. }
  49633. }
  49634. declare module "babylonjs/Meshes/polygonMesh" {
  49635. import { Scene } from "babylonjs/scene";
  49636. import { Vector2, Path2 } from "babylonjs/Maths/math";
  49637. import { Mesh } from "babylonjs/Meshes/mesh";
  49638. /**
  49639. * Polygon
  49640. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49641. */
  49642. export class Polygon {
  49643. /**
  49644. * Creates a rectangle
  49645. * @param xmin bottom X coord
  49646. * @param ymin bottom Y coord
  49647. * @param xmax top X coord
  49648. * @param ymax top Y coord
  49649. * @returns points that make the resulting rectation
  49650. */
  49651. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49652. /**
  49653. * Creates a circle
  49654. * @param radius radius of circle
  49655. * @param cx scale in x
  49656. * @param cy scale in y
  49657. * @param numberOfSides number of sides that make up the circle
  49658. * @returns points that make the resulting circle
  49659. */
  49660. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49661. /**
  49662. * Creates a polygon from input string
  49663. * @param input Input polygon data
  49664. * @returns the parsed points
  49665. */
  49666. static Parse(input: string): Vector2[];
  49667. /**
  49668. * Starts building a polygon from x and y coordinates
  49669. * @param x x coordinate
  49670. * @param y y coordinate
  49671. * @returns the started path2
  49672. */
  49673. static StartingAt(x: number, y: number): Path2;
  49674. }
  49675. /**
  49676. * Builds a polygon
  49677. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49678. */
  49679. export class PolygonMeshBuilder {
  49680. private _points;
  49681. private _outlinepoints;
  49682. private _holes;
  49683. private _name;
  49684. private _scene;
  49685. private _epoints;
  49686. private _eholes;
  49687. private _addToepoint;
  49688. /**
  49689. * Babylon reference to the earcut plugin.
  49690. */
  49691. bjsEarcut: any;
  49692. /**
  49693. * Creates a PolygonMeshBuilder
  49694. * @param name name of the builder
  49695. * @param contours Path of the polygon
  49696. * @param scene scene to add to
  49697. * @param earcutInjection can be used to inject your own earcut reference
  49698. */
  49699. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  49700. /**
  49701. * Adds a whole within the polygon
  49702. * @param hole Array of points defining the hole
  49703. * @returns this
  49704. */
  49705. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49706. /**
  49707. * Creates the polygon
  49708. * @param updatable If the mesh should be updatable
  49709. * @param depth The depth of the mesh created
  49710. * @returns the created mesh
  49711. */
  49712. build(updatable?: boolean, depth?: number): Mesh;
  49713. /**
  49714. * Adds a side to the polygon
  49715. * @param positions points that make the polygon
  49716. * @param normals normals of the polygon
  49717. * @param uvs uvs of the polygon
  49718. * @param indices indices of the polygon
  49719. * @param bounds bounds of the polygon
  49720. * @param points points of the polygon
  49721. * @param depth depth of the polygon
  49722. * @param flip flip of the polygon
  49723. */
  49724. private addSide;
  49725. }
  49726. }
  49727. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  49728. import { Scene } from "babylonjs/scene";
  49729. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  49730. import { Mesh } from "babylonjs/Meshes/mesh";
  49731. /**
  49732. * Class containing static functions to help procedurally build meshes
  49733. */
  49734. export class PolygonBuilder {
  49735. /**
  49736. * Creates a polygon mesh
  49737. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49738. * * 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
  49739. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49742. * * Remember you can only change the shape positions, not their number when updating a polygon
  49743. * @param name defines the name of the mesh
  49744. * @param options defines the options used to create the mesh
  49745. * @param scene defines the hosting scene
  49746. * @param earcutInjection can be used to inject your own earcut reference
  49747. * @returns the polygon mesh
  49748. */
  49749. static CreatePolygon(name: string, options: {
  49750. shape: Vector3[];
  49751. holes?: Vector3[][];
  49752. depth?: number;
  49753. faceUV?: Vector4[];
  49754. faceColors?: Color4[];
  49755. updatable?: boolean;
  49756. sideOrientation?: number;
  49757. frontUVs?: Vector4;
  49758. backUVs?: Vector4;
  49759. }, scene: Scene, earcutInjection?: any): Mesh;
  49760. /**
  49761. * Creates an extruded polygon mesh, with depth in the Y direction.
  49762. * * 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)
  49763. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49764. * @param name defines the name of the mesh
  49765. * @param options defines the options used to create the mesh
  49766. * @param scene defines the hosting scene
  49767. * @param earcutInjection can be used to inject your own earcut reference
  49768. * @returns the polygon mesh
  49769. */
  49770. static ExtrudePolygon(name: string, options: {
  49771. shape: Vector3[];
  49772. holes?: Vector3[][];
  49773. depth?: number;
  49774. faceUV?: Vector4[];
  49775. faceColors?: Color4[];
  49776. updatable?: boolean;
  49777. sideOrientation?: number;
  49778. frontUVs?: Vector4;
  49779. backUVs?: Vector4;
  49780. }, scene: Scene, earcutInjection?: any): Mesh;
  49781. }
  49782. }
  49783. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  49784. import { Nullable } from "babylonjs/types";
  49785. import { Scene } from "babylonjs/scene";
  49786. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49787. import { Mesh } from "babylonjs/Meshes/mesh";
  49788. /**
  49789. * Class containing static functions to help procedurally build meshes
  49790. */
  49791. export class ShapeBuilder {
  49792. /**
  49793. * 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.
  49794. * * 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.
  49795. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49796. * * 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.
  49797. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49798. * * 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
  49799. * * 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
  49800. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49802. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49803. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49805. * @param name defines the name of the mesh
  49806. * @param options defines the options used to create the mesh
  49807. * @param scene defines the hosting scene
  49808. * @returns the extruded shape mesh
  49809. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49810. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49811. */
  49812. static ExtrudeShape(name: string, options: {
  49813. shape: Vector3[];
  49814. path: Vector3[];
  49815. scale?: number;
  49816. rotation?: number;
  49817. cap?: number;
  49818. updatable?: boolean;
  49819. sideOrientation?: number;
  49820. frontUVs?: Vector4;
  49821. backUVs?: Vector4;
  49822. instance?: Mesh;
  49823. invertUV?: boolean;
  49824. }, scene?: Nullable<Scene>): Mesh;
  49825. /**
  49826. * Creates an custom extruded shape mesh.
  49827. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49828. * * 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.
  49829. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49830. * * 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
  49831. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49832. * * 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
  49833. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49834. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49835. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49836. * * 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
  49837. * * 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
  49838. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49840. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49841. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49843. * @param name defines the name of the mesh
  49844. * @param options defines the options used to create the mesh
  49845. * @param scene defines the hosting scene
  49846. * @returns the custom extruded shape mesh
  49847. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49848. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49849. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49850. */
  49851. static ExtrudeShapeCustom(name: string, options: {
  49852. shape: Vector3[];
  49853. path: Vector3[];
  49854. scaleFunction?: any;
  49855. rotationFunction?: any;
  49856. ribbonCloseArray?: boolean;
  49857. ribbonClosePath?: boolean;
  49858. cap?: number;
  49859. updatable?: boolean;
  49860. sideOrientation?: number;
  49861. frontUVs?: Vector4;
  49862. backUVs?: Vector4;
  49863. instance?: Mesh;
  49864. invertUV?: boolean;
  49865. }, scene: Scene): Mesh;
  49866. private static _ExtrudeShapeGeneric;
  49867. }
  49868. }
  49869. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  49870. import { Scene } from "babylonjs/scene";
  49871. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49872. import { Mesh } from "babylonjs/Meshes/mesh";
  49873. /**
  49874. * Class containing static functions to help procedurally build meshes
  49875. */
  49876. export class LatheBuilder {
  49877. /**
  49878. * Creates lathe mesh.
  49879. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49880. * * 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
  49881. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49882. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49883. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49884. * * 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
  49885. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49886. * * 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
  49887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49889. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49891. * @param name defines the name of the mesh
  49892. * @param options defines the options used to create the mesh
  49893. * @param scene defines the hosting scene
  49894. * @returns the lathe mesh
  49895. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49896. */
  49897. static CreateLathe(name: string, options: {
  49898. shape: Vector3[];
  49899. radius?: number;
  49900. tessellation?: number;
  49901. clip?: number;
  49902. arc?: number;
  49903. closed?: boolean;
  49904. updatable?: boolean;
  49905. sideOrientation?: number;
  49906. frontUVs?: Vector4;
  49907. backUVs?: Vector4;
  49908. cap?: number;
  49909. invertUV?: boolean;
  49910. }, scene: Scene): Mesh;
  49911. }
  49912. }
  49913. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  49914. import { Scene } from "babylonjs/scene";
  49915. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49916. import { Mesh } from "babylonjs/Meshes/mesh";
  49917. /**
  49918. * Class containing static functions to help procedurally build meshes
  49919. */
  49920. export class TubeBuilder {
  49921. /**
  49922. * Creates a tube mesh.
  49923. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49924. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49925. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49926. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49927. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49928. * * 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)
  49929. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49930. * * 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
  49931. * * 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
  49932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49933. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49934. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49936. * @param name defines the name of the mesh
  49937. * @param options defines the options used to create the mesh
  49938. * @param scene defines the hosting scene
  49939. * @returns the tube mesh
  49940. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49941. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49942. */
  49943. static CreateTube(name: string, options: {
  49944. path: Vector3[];
  49945. radius?: number;
  49946. tessellation?: number;
  49947. radiusFunction?: {
  49948. (i: number, distance: number): number;
  49949. };
  49950. cap?: number;
  49951. arc?: number;
  49952. updatable?: boolean;
  49953. sideOrientation?: number;
  49954. frontUVs?: Vector4;
  49955. backUVs?: Vector4;
  49956. instance?: Mesh;
  49957. invertUV?: boolean;
  49958. }, scene: Scene): Mesh;
  49959. }
  49960. }
  49961. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  49962. import { Scene } from "babylonjs/scene";
  49963. import { Vector4 } from "babylonjs/Maths/math";
  49964. import { Mesh } from "babylonjs/Meshes/mesh";
  49965. /**
  49966. * Class containing static functions to help procedurally build meshes
  49967. */
  49968. export class IcoSphereBuilder {
  49969. /**
  49970. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49971. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49972. * * 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`)
  49973. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49974. * * 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
  49975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49976. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49978. * @param name defines the name of the mesh
  49979. * @param options defines the options used to create the mesh
  49980. * @param scene defines the hosting scene
  49981. * @returns the icosahedron mesh
  49982. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49983. */
  49984. static CreateIcoSphere(name: string, options: {
  49985. radius?: number;
  49986. radiusX?: number;
  49987. radiusY?: number;
  49988. radiusZ?: number;
  49989. flat?: boolean;
  49990. subdivisions?: number;
  49991. sideOrientation?: number;
  49992. frontUVs?: Vector4;
  49993. backUVs?: Vector4;
  49994. updatable?: boolean;
  49995. }, scene: Scene): Mesh;
  49996. }
  49997. }
  49998. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  49999. import { Vector3 } from "babylonjs/Maths/math";
  50000. import { Mesh } from "babylonjs/Meshes/mesh";
  50001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50002. /**
  50003. * Class containing static functions to help procedurally build meshes
  50004. */
  50005. export class DecalBuilder {
  50006. /**
  50007. * Creates a decal mesh.
  50008. * 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
  50009. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50010. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50011. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50012. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50013. * @param name defines the name of the mesh
  50014. * @param sourceMesh defines the mesh where the decal must be applied
  50015. * @param options defines the options used to create the mesh
  50016. * @param scene defines the hosting scene
  50017. * @returns the decal mesh
  50018. * @see https://doc.babylonjs.com/how_to/decals
  50019. */
  50020. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50021. position?: Vector3;
  50022. normal?: Vector3;
  50023. size?: Vector3;
  50024. angle?: number;
  50025. }): Mesh;
  50026. }
  50027. }
  50028. declare module "babylonjs/Meshes/meshBuilder" {
  50029. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50030. import { Nullable } from "babylonjs/types";
  50031. import { Scene } from "babylonjs/scene";
  50032. import { Mesh } from "babylonjs/Meshes/mesh";
  50033. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50034. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50036. /**
  50037. * Class containing static functions to help procedurally build meshes
  50038. */
  50039. export class MeshBuilder {
  50040. /**
  50041. * Creates a box mesh
  50042. * * The parameter `size` sets the size (float) of each box side (default 1)
  50043. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50044. * * 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)
  50045. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50049. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50050. * @param name defines the name of the mesh
  50051. * @param options defines the options used to create the mesh
  50052. * @param scene defines the hosting scene
  50053. * @returns the box mesh
  50054. */
  50055. static CreateBox(name: string, options: {
  50056. size?: number;
  50057. width?: number;
  50058. height?: number;
  50059. depth?: number;
  50060. faceUV?: Vector4[];
  50061. faceColors?: Color4[];
  50062. sideOrientation?: number;
  50063. frontUVs?: Vector4;
  50064. backUVs?: Vector4;
  50065. updatable?: boolean;
  50066. }, scene?: Nullable<Scene>): Mesh;
  50067. /**
  50068. * Creates a sphere mesh
  50069. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50070. * * 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`)
  50071. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50072. * * 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
  50073. * * 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)
  50074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50077. * @param name defines the name of the mesh
  50078. * @param options defines the options used to create the mesh
  50079. * @param scene defines the hosting scene
  50080. * @returns the sphere mesh
  50081. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50082. */
  50083. static CreateSphere(name: string, options: {
  50084. segments?: number;
  50085. diameter?: number;
  50086. diameterX?: number;
  50087. diameterY?: number;
  50088. diameterZ?: number;
  50089. arc?: number;
  50090. slice?: number;
  50091. sideOrientation?: number;
  50092. frontUVs?: Vector4;
  50093. backUVs?: Vector4;
  50094. updatable?: boolean;
  50095. }, scene: any): Mesh;
  50096. /**
  50097. * Creates a plane polygonal mesh. By default, this is a disc
  50098. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50099. * * 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
  50100. * * 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
  50101. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50102. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50104. * @param name defines the name of the mesh
  50105. * @param options defines the options used to create the mesh
  50106. * @param scene defines the hosting scene
  50107. * @returns the plane polygonal mesh
  50108. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50109. */
  50110. static CreateDisc(name: string, options: {
  50111. radius?: number;
  50112. tessellation?: number;
  50113. arc?: number;
  50114. updatable?: boolean;
  50115. sideOrientation?: number;
  50116. frontUVs?: Vector4;
  50117. backUVs?: Vector4;
  50118. }, scene?: Nullable<Scene>): Mesh;
  50119. /**
  50120. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50121. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50122. * * 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`)
  50123. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50124. * * 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
  50125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50128. * @param name defines the name of the mesh
  50129. * @param options defines the options used to create the mesh
  50130. * @param scene defines the hosting scene
  50131. * @returns the icosahedron mesh
  50132. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50133. */
  50134. static CreateIcoSphere(name: string, options: {
  50135. radius?: number;
  50136. radiusX?: number;
  50137. radiusY?: number;
  50138. radiusZ?: number;
  50139. flat?: boolean;
  50140. subdivisions?: number;
  50141. sideOrientation?: number;
  50142. frontUVs?: Vector4;
  50143. backUVs?: Vector4;
  50144. updatable?: boolean;
  50145. }, scene: Scene): Mesh;
  50146. /**
  50147. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50148. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50149. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50150. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50151. * * 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
  50152. * * 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
  50153. * * 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
  50154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50156. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50157. * * 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
  50158. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50159. * * 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
  50160. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50162. * @param name defines the name of the mesh
  50163. * @param options defines the options used to create the mesh
  50164. * @param scene defines the hosting scene
  50165. * @returns the ribbon mesh
  50166. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50167. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50168. */
  50169. static CreateRibbon(name: string, options: {
  50170. pathArray: Vector3[][];
  50171. closeArray?: boolean;
  50172. closePath?: boolean;
  50173. offset?: number;
  50174. updatable?: boolean;
  50175. sideOrientation?: number;
  50176. frontUVs?: Vector4;
  50177. backUVs?: Vector4;
  50178. instance?: Mesh;
  50179. invertUV?: boolean;
  50180. uvs?: Vector2[];
  50181. colors?: Color4[];
  50182. }, scene?: Nullable<Scene>): Mesh;
  50183. /**
  50184. * Creates a cylinder or a cone mesh
  50185. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50186. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50187. * * 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.
  50188. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50189. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50190. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50191. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50192. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50193. * * 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).
  50194. * * 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
  50195. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50196. * * 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
  50197. * * 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.
  50198. * * If `enclose` is false, a ring surface is one element.
  50199. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50200. * * 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
  50201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50202. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50204. * @param name defines the name of the mesh
  50205. * @param options defines the options used to create the mesh
  50206. * @param scene defines the hosting scene
  50207. * @returns the cylinder mesh
  50208. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50209. */
  50210. static CreateCylinder(name: string, options: {
  50211. height?: number;
  50212. diameterTop?: number;
  50213. diameterBottom?: number;
  50214. diameter?: number;
  50215. tessellation?: number;
  50216. subdivisions?: number;
  50217. arc?: number;
  50218. faceColors?: Color4[];
  50219. faceUV?: Vector4[];
  50220. updatable?: boolean;
  50221. hasRings?: boolean;
  50222. enclose?: boolean;
  50223. sideOrientation?: number;
  50224. frontUVs?: Vector4;
  50225. backUVs?: Vector4;
  50226. }, scene: any): Mesh;
  50227. /**
  50228. * Creates a torus mesh
  50229. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50230. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50231. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50235. * @param name defines the name of the mesh
  50236. * @param options defines the options used to create the mesh
  50237. * @param scene defines the hosting scene
  50238. * @returns the torus mesh
  50239. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50240. */
  50241. static CreateTorus(name: string, options: {
  50242. diameter?: number;
  50243. thickness?: number;
  50244. tessellation?: number;
  50245. updatable?: boolean;
  50246. sideOrientation?: number;
  50247. frontUVs?: Vector4;
  50248. backUVs?: Vector4;
  50249. }, scene: any): Mesh;
  50250. /**
  50251. * Creates a torus knot mesh
  50252. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50253. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50254. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50255. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50259. * @param name defines the name of the mesh
  50260. * @param options defines the options used to create the mesh
  50261. * @param scene defines the hosting scene
  50262. * @returns the torus knot mesh
  50263. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50264. */
  50265. static CreateTorusKnot(name: string, options: {
  50266. radius?: number;
  50267. tube?: number;
  50268. radialSegments?: number;
  50269. tubularSegments?: number;
  50270. p?: number;
  50271. q?: number;
  50272. updatable?: boolean;
  50273. sideOrientation?: number;
  50274. frontUVs?: Vector4;
  50275. backUVs?: Vector4;
  50276. }, scene: any): Mesh;
  50277. /**
  50278. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50279. * * 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
  50280. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50281. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50282. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50283. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50284. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50285. * * 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
  50286. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50288. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50289. * @param name defines the name of the new line system
  50290. * @param options defines the options used to create the line system
  50291. * @param scene defines the hosting scene
  50292. * @returns a new line system mesh
  50293. */
  50294. static CreateLineSystem(name: string, options: {
  50295. lines: Vector3[][];
  50296. updatable?: boolean;
  50297. instance?: Nullable<LinesMesh>;
  50298. colors?: Nullable<Color4[][]>;
  50299. useVertexAlpha?: boolean;
  50300. }, scene: Nullable<Scene>): LinesMesh;
  50301. /**
  50302. * Creates a line mesh
  50303. * 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
  50304. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50305. * * The parameter `points` is an array successive Vector3
  50306. * * 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
  50307. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50308. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50309. * * When updating an instance, remember that only point positions can change, not the number of points
  50310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50311. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50312. * @param name defines the name of the new line system
  50313. * @param options defines the options used to create the line system
  50314. * @param scene defines the hosting scene
  50315. * @returns a new line mesh
  50316. */
  50317. static CreateLines(name: string, options: {
  50318. points: Vector3[];
  50319. updatable?: boolean;
  50320. instance?: Nullable<LinesMesh>;
  50321. colors?: Color4[];
  50322. useVertexAlpha?: boolean;
  50323. }, scene?: Nullable<Scene>): LinesMesh;
  50324. /**
  50325. * Creates a dashed line mesh
  50326. * * 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
  50327. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50328. * * The parameter `points` is an array successive Vector3
  50329. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50330. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50331. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50332. * * 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
  50333. * * When updating an instance, remember that only point positions can change, not the number of points
  50334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50335. * @param name defines the name of the mesh
  50336. * @param options defines the options used to create the mesh
  50337. * @param scene defines the hosting scene
  50338. * @returns the dashed line mesh
  50339. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50340. */
  50341. static CreateDashedLines(name: string, options: {
  50342. points: Vector3[];
  50343. dashSize?: number;
  50344. gapSize?: number;
  50345. dashNb?: number;
  50346. updatable?: boolean;
  50347. instance?: LinesMesh;
  50348. }, scene?: Nullable<Scene>): LinesMesh;
  50349. /**
  50350. * 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.
  50351. * * 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.
  50352. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50353. * * 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.
  50354. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50355. * * 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
  50356. * * 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
  50357. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50359. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50360. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50362. * @param name defines the name of the mesh
  50363. * @param options defines the options used to create the mesh
  50364. * @param scene defines the hosting scene
  50365. * @returns the extruded shape mesh
  50366. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50367. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50368. */
  50369. static ExtrudeShape(name: string, options: {
  50370. shape: Vector3[];
  50371. path: Vector3[];
  50372. scale?: number;
  50373. rotation?: number;
  50374. cap?: number;
  50375. updatable?: boolean;
  50376. sideOrientation?: number;
  50377. frontUVs?: Vector4;
  50378. backUVs?: Vector4;
  50379. instance?: Mesh;
  50380. invertUV?: boolean;
  50381. }, scene?: Nullable<Scene>): Mesh;
  50382. /**
  50383. * Creates an custom extruded shape mesh.
  50384. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50385. * * 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.
  50386. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50387. * * 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
  50388. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50389. * * 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
  50390. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50391. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50392. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50393. * * 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
  50394. * * 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
  50395. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50396. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50397. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50398. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50400. * @param name defines the name of the mesh
  50401. * @param options defines the options used to create the mesh
  50402. * @param scene defines the hosting scene
  50403. * @returns the custom extruded shape mesh
  50404. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50405. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50406. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50407. */
  50408. static ExtrudeShapeCustom(name: string, options: {
  50409. shape: Vector3[];
  50410. path: Vector3[];
  50411. scaleFunction?: any;
  50412. rotationFunction?: any;
  50413. ribbonCloseArray?: boolean;
  50414. ribbonClosePath?: boolean;
  50415. cap?: number;
  50416. updatable?: boolean;
  50417. sideOrientation?: number;
  50418. frontUVs?: Vector4;
  50419. backUVs?: Vector4;
  50420. instance?: Mesh;
  50421. invertUV?: boolean;
  50422. }, scene: Scene): Mesh;
  50423. /**
  50424. * Creates lathe mesh.
  50425. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50426. * * 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
  50427. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50428. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50429. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50430. * * 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
  50431. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50432. * * 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
  50433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50434. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50435. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50437. * @param name defines the name of the mesh
  50438. * @param options defines the options used to create the mesh
  50439. * @param scene defines the hosting scene
  50440. * @returns the lathe mesh
  50441. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50442. */
  50443. static CreateLathe(name: string, options: {
  50444. shape: Vector3[];
  50445. radius?: number;
  50446. tessellation?: number;
  50447. clip?: number;
  50448. arc?: number;
  50449. closed?: boolean;
  50450. updatable?: boolean;
  50451. sideOrientation?: number;
  50452. frontUVs?: Vector4;
  50453. backUVs?: Vector4;
  50454. cap?: number;
  50455. invertUV?: boolean;
  50456. }, scene: Scene): Mesh;
  50457. /**
  50458. * Creates a plane mesh
  50459. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50460. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50461. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50463. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50465. * @param name defines the name of the mesh
  50466. * @param options defines the options used to create the mesh
  50467. * @param scene defines the hosting scene
  50468. * @returns the plane mesh
  50469. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50470. */
  50471. static CreatePlane(name: string, options: {
  50472. size?: number;
  50473. width?: number;
  50474. height?: number;
  50475. sideOrientation?: number;
  50476. frontUVs?: Vector4;
  50477. backUVs?: Vector4;
  50478. updatable?: boolean;
  50479. sourcePlane?: Plane;
  50480. }, scene: Scene): Mesh;
  50481. /**
  50482. * Creates a ground mesh
  50483. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50484. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50486. * @param name defines the name of the mesh
  50487. * @param options defines the options used to create the mesh
  50488. * @param scene defines the hosting scene
  50489. * @returns the ground mesh
  50490. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50491. */
  50492. static CreateGround(name: string, options: {
  50493. width?: number;
  50494. height?: number;
  50495. subdivisions?: number;
  50496. subdivisionsX?: number;
  50497. subdivisionsY?: number;
  50498. updatable?: boolean;
  50499. }, scene: any): Mesh;
  50500. /**
  50501. * Creates a tiled ground mesh
  50502. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50503. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50504. * * 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
  50505. * * 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
  50506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50507. * @param name defines the name of the mesh
  50508. * @param options defines the options used to create the mesh
  50509. * @param scene defines the hosting scene
  50510. * @returns the tiled ground mesh
  50511. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50512. */
  50513. static CreateTiledGround(name: string, options: {
  50514. xmin: number;
  50515. zmin: number;
  50516. xmax: number;
  50517. zmax: number;
  50518. subdivisions?: {
  50519. w: number;
  50520. h: number;
  50521. };
  50522. precision?: {
  50523. w: number;
  50524. h: number;
  50525. };
  50526. updatable?: boolean;
  50527. }, scene: Scene): Mesh;
  50528. /**
  50529. * Creates a ground mesh from a height map
  50530. * * The parameter `url` sets the URL of the height map image resource.
  50531. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50532. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50533. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50534. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50535. * * 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.
  50536. * * 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).
  50537. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50539. * @param name defines the name of the mesh
  50540. * @param url defines the url to the height map
  50541. * @param options defines the options used to create the mesh
  50542. * @param scene defines the hosting scene
  50543. * @returns the ground mesh
  50544. * @see https://doc.babylonjs.com/babylon101/height_map
  50545. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50546. */
  50547. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50548. width?: number;
  50549. height?: number;
  50550. subdivisions?: number;
  50551. minHeight?: number;
  50552. maxHeight?: number;
  50553. colorFilter?: Color3;
  50554. alphaFilter?: number;
  50555. updatable?: boolean;
  50556. onReady?: (mesh: GroundMesh) => void;
  50557. }, scene: Scene): GroundMesh;
  50558. /**
  50559. * Creates a polygon mesh
  50560. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50561. * * 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
  50562. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50564. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50565. * * Remember you can only change the shape positions, not their number when updating a polygon
  50566. * @param name defines the name of the mesh
  50567. * @param options defines the options used to create the mesh
  50568. * @param scene defines the hosting scene
  50569. * @param earcutInjection can be used to inject your own earcut reference
  50570. * @returns the polygon mesh
  50571. */
  50572. static CreatePolygon(name: string, options: {
  50573. shape: Vector3[];
  50574. holes?: Vector3[][];
  50575. depth?: number;
  50576. faceUV?: Vector4[];
  50577. faceColors?: Color4[];
  50578. updatable?: boolean;
  50579. sideOrientation?: number;
  50580. frontUVs?: Vector4;
  50581. backUVs?: Vector4;
  50582. }, scene: Scene, earcutInjection?: any): Mesh;
  50583. /**
  50584. * Creates an extruded polygon mesh, with depth in the Y direction.
  50585. * * 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)
  50586. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50587. * @param name defines the name of the mesh
  50588. * @param options defines the options used to create the mesh
  50589. * @param scene defines the hosting scene
  50590. * @param earcutInjection can be used to inject your own earcut reference
  50591. * @returns the polygon mesh
  50592. */
  50593. static ExtrudePolygon(name: string, options: {
  50594. shape: Vector3[];
  50595. holes?: Vector3[][];
  50596. depth?: number;
  50597. faceUV?: Vector4[];
  50598. faceColors?: Color4[];
  50599. updatable?: boolean;
  50600. sideOrientation?: number;
  50601. frontUVs?: Vector4;
  50602. backUVs?: Vector4;
  50603. }, scene: Scene, earcutInjection?: any): Mesh;
  50604. /**
  50605. * Creates a tube mesh.
  50606. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50607. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50608. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50609. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50610. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50611. * * 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)
  50612. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50613. * * 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
  50614. * * 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
  50615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50617. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50619. * @param name defines the name of the mesh
  50620. * @param options defines the options used to create the mesh
  50621. * @param scene defines the hosting scene
  50622. * @returns the tube mesh
  50623. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50624. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50625. */
  50626. static CreateTube(name: string, options: {
  50627. path: Vector3[];
  50628. radius?: number;
  50629. tessellation?: number;
  50630. radiusFunction?: {
  50631. (i: number, distance: number): number;
  50632. };
  50633. cap?: number;
  50634. arc?: number;
  50635. updatable?: boolean;
  50636. sideOrientation?: number;
  50637. frontUVs?: Vector4;
  50638. backUVs?: Vector4;
  50639. instance?: Mesh;
  50640. invertUV?: boolean;
  50641. }, scene: Scene): Mesh;
  50642. /**
  50643. * Creates a polyhedron mesh
  50644. * * 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
  50645. * * The parameter `size` (positive float, default 1) sets the polygon size
  50646. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50647. * * 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`
  50648. * * 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
  50649. * * 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)`)
  50650. * * 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
  50651. * * 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
  50652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50653. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50655. * @param name defines the name of the mesh
  50656. * @param options defines the options used to create the mesh
  50657. * @param scene defines the hosting scene
  50658. * @returns the polyhedron mesh
  50659. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50660. */
  50661. static CreatePolyhedron(name: string, options: {
  50662. type?: number;
  50663. size?: number;
  50664. sizeX?: number;
  50665. sizeY?: number;
  50666. sizeZ?: number;
  50667. custom?: any;
  50668. faceUV?: Vector4[];
  50669. faceColors?: Color4[];
  50670. flat?: boolean;
  50671. updatable?: boolean;
  50672. sideOrientation?: number;
  50673. frontUVs?: Vector4;
  50674. backUVs?: Vector4;
  50675. }, scene: Scene): Mesh;
  50676. /**
  50677. * Creates a decal mesh.
  50678. * 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
  50679. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50680. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50681. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50682. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50683. * @param name defines the name of the mesh
  50684. * @param sourceMesh defines the mesh where the decal must be applied
  50685. * @param options defines the options used to create the mesh
  50686. * @param scene defines the hosting scene
  50687. * @returns the decal mesh
  50688. * @see https://doc.babylonjs.com/how_to/decals
  50689. */
  50690. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50691. position?: Vector3;
  50692. normal?: Vector3;
  50693. size?: Vector3;
  50694. angle?: number;
  50695. }): Mesh;
  50696. }
  50697. }
  50698. declare module "babylonjs/Meshes/meshSimplification" {
  50699. import { Mesh } from "babylonjs/Meshes/mesh";
  50700. /**
  50701. * A simplifier interface for future simplification implementations
  50702. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50703. */
  50704. export interface ISimplifier {
  50705. /**
  50706. * Simplification of a given mesh according to the given settings.
  50707. * Since this requires computation, it is assumed that the function runs async.
  50708. * @param settings The settings of the simplification, including quality and distance
  50709. * @param successCallback A callback that will be called after the mesh was simplified.
  50710. * @param errorCallback in case of an error, this callback will be called. optional.
  50711. */
  50712. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50713. }
  50714. /**
  50715. * Expected simplification settings.
  50716. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50717. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50718. */
  50719. export interface ISimplificationSettings {
  50720. /**
  50721. * Gets or sets the expected quality
  50722. */
  50723. quality: number;
  50724. /**
  50725. * Gets or sets the distance when this optimized version should be used
  50726. */
  50727. distance: number;
  50728. /**
  50729. * Gets an already optimized mesh
  50730. */
  50731. optimizeMesh?: boolean;
  50732. }
  50733. /**
  50734. * Class used to specify simplification options
  50735. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50736. */
  50737. export class SimplificationSettings implements ISimplificationSettings {
  50738. /** expected quality */
  50739. quality: number;
  50740. /** distance when this optimized version should be used */
  50741. distance: number;
  50742. /** already optimized mesh */
  50743. optimizeMesh?: boolean | undefined;
  50744. /**
  50745. * Creates a SimplificationSettings
  50746. * @param quality expected quality
  50747. * @param distance distance when this optimized version should be used
  50748. * @param optimizeMesh already optimized mesh
  50749. */
  50750. constructor(
  50751. /** expected quality */
  50752. quality: number,
  50753. /** distance when this optimized version should be used */
  50754. distance: number,
  50755. /** already optimized mesh */
  50756. optimizeMesh?: boolean | undefined);
  50757. }
  50758. /**
  50759. * Interface used to define a simplification task
  50760. */
  50761. export interface ISimplificationTask {
  50762. /**
  50763. * Array of settings
  50764. */
  50765. settings: Array<ISimplificationSettings>;
  50766. /**
  50767. * Simplification type
  50768. */
  50769. simplificationType: SimplificationType;
  50770. /**
  50771. * Mesh to simplify
  50772. */
  50773. mesh: Mesh;
  50774. /**
  50775. * Callback called on success
  50776. */
  50777. successCallback?: () => void;
  50778. /**
  50779. * Defines if parallel processing can be used
  50780. */
  50781. parallelProcessing: boolean;
  50782. }
  50783. /**
  50784. * Queue used to order the simplification tasks
  50785. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50786. */
  50787. export class SimplificationQueue {
  50788. private _simplificationArray;
  50789. /**
  50790. * Gets a boolean indicating that the process is still running
  50791. */
  50792. running: boolean;
  50793. /**
  50794. * Creates a new queue
  50795. */
  50796. constructor();
  50797. /**
  50798. * Adds a new simplification task
  50799. * @param task defines a task to add
  50800. */
  50801. addTask(task: ISimplificationTask): void;
  50802. /**
  50803. * Execute next task
  50804. */
  50805. executeNext(): void;
  50806. /**
  50807. * Execute a simplification task
  50808. * @param task defines the task to run
  50809. */
  50810. runSimplification(task: ISimplificationTask): void;
  50811. private getSimplifier;
  50812. }
  50813. /**
  50814. * The implemented types of simplification
  50815. * At the moment only Quadratic Error Decimation is implemented
  50816. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50817. */
  50818. export enum SimplificationType {
  50819. /** Quadratic error decimation */
  50820. QUADRATIC = 0
  50821. }
  50822. }
  50823. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  50824. import { Scene } from "babylonjs/scene";
  50825. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  50826. import { ISceneComponent } from "babylonjs/sceneComponent";
  50827. module "babylonjs/scene" {
  50828. interface Scene {
  50829. /** @hidden (Backing field) */
  50830. _simplificationQueue: SimplificationQueue;
  50831. /**
  50832. * Gets or sets the simplification queue attached to the scene
  50833. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50834. */
  50835. simplificationQueue: SimplificationQueue;
  50836. }
  50837. }
  50838. module "babylonjs/Meshes/mesh" {
  50839. interface Mesh {
  50840. /**
  50841. * Simplify the mesh according to the given array of settings.
  50842. * Function will return immediately and will simplify async
  50843. * @param settings a collection of simplification settings
  50844. * @param parallelProcessing should all levels calculate parallel or one after the other
  50845. * @param simplificationType the type of simplification to run
  50846. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50847. * @returns the current mesh
  50848. */
  50849. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50850. }
  50851. }
  50852. /**
  50853. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50854. * created in a scene
  50855. */
  50856. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50857. /**
  50858. * The component name helpfull to identify the component in the list of scene components.
  50859. */
  50860. readonly name: string;
  50861. /**
  50862. * The scene the component belongs to.
  50863. */
  50864. scene: Scene;
  50865. /**
  50866. * Creates a new instance of the component for the given scene
  50867. * @param scene Defines the scene to register the component in
  50868. */
  50869. constructor(scene: Scene);
  50870. /**
  50871. * Registers the component in a given scene
  50872. */
  50873. register(): void;
  50874. /**
  50875. * Rebuilds the elements related to this component in case of
  50876. * context lost for instance.
  50877. */
  50878. rebuild(): void;
  50879. /**
  50880. * Disposes the component and the associated ressources
  50881. */
  50882. dispose(): void;
  50883. private _beforeCameraUpdate;
  50884. }
  50885. }
  50886. declare module "babylonjs/Meshes/Builders/index" {
  50887. export * from "babylonjs/Meshes/Builders/boxBuilder";
  50888. export * from "babylonjs/Meshes/Builders/discBuilder";
  50889. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  50890. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  50891. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  50892. export * from "babylonjs/Meshes/Builders/torusBuilder";
  50893. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  50894. export * from "babylonjs/Meshes/Builders/linesBuilder";
  50895. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  50896. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  50897. export * from "babylonjs/Meshes/Builders/latheBuilder";
  50898. export * from "babylonjs/Meshes/Builders/planeBuilder";
  50899. export * from "babylonjs/Meshes/Builders/groundBuilder";
  50900. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  50901. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  50902. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  50903. export * from "babylonjs/Meshes/Builders/decalBuilder";
  50904. }
  50905. declare module "babylonjs/Meshes/index" {
  50906. export * from "babylonjs/Meshes/abstractMesh";
  50907. export * from "babylonjs/Meshes/buffer";
  50908. export * from "babylonjs/Meshes/Compression/index";
  50909. export * from "babylonjs/Meshes/csg";
  50910. export * from "babylonjs/Meshes/geometry";
  50911. export * from "babylonjs/Meshes/groundMesh";
  50912. export * from "babylonjs/Meshes/trailMesh";
  50913. export * from "babylonjs/Meshes/instancedMesh";
  50914. export * from "babylonjs/Meshes/linesMesh";
  50915. export * from "babylonjs/Meshes/mesh";
  50916. export * from "babylonjs/Meshes/mesh.vertexData";
  50917. export * from "babylonjs/Meshes/meshBuilder";
  50918. export * from "babylonjs/Meshes/meshSimplification";
  50919. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  50920. export * from "babylonjs/Meshes/polygonMesh";
  50921. export * from "babylonjs/Meshes/subMesh";
  50922. export * from "babylonjs/Meshes/transformNode";
  50923. export * from "babylonjs/Meshes/Builders/index";
  50924. }
  50925. declare module "babylonjs/Morph/index" {
  50926. export * from "babylonjs/Morph/morphTarget";
  50927. export * from "babylonjs/Morph/morphTargetManager";
  50928. }
  50929. declare module "babylonjs/Offline/database" {
  50930. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  50931. /**
  50932. * Class used to enable access to IndexedDB
  50933. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50934. */
  50935. export class Database implements IOfflineProvider {
  50936. private _callbackManifestChecked;
  50937. private _currentSceneUrl;
  50938. private _db;
  50939. private _enableSceneOffline;
  50940. private _enableTexturesOffline;
  50941. private _manifestVersionFound;
  50942. private _mustUpdateRessources;
  50943. private _hasReachedQuota;
  50944. private _isSupported;
  50945. private _idbFactory;
  50946. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50947. private static IsUASupportingBlobStorage;
  50948. /**
  50949. * Gets a boolean indicating if Database storate is enabled (off by default)
  50950. */
  50951. static IDBStorageEnabled: boolean;
  50952. /**
  50953. * Gets a boolean indicating if scene must be saved in the database
  50954. */
  50955. readonly enableSceneOffline: boolean;
  50956. /**
  50957. * Gets a boolean indicating if textures must be saved in the database
  50958. */
  50959. readonly enableTexturesOffline: boolean;
  50960. /**
  50961. * Creates a new Database
  50962. * @param urlToScene defines the url to load the scene
  50963. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50964. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50965. */
  50966. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50967. private static _ParseURL;
  50968. private static _ReturnFullUrlLocation;
  50969. private _checkManifestFile;
  50970. /**
  50971. * Open the database and make it available
  50972. * @param successCallback defines the callback to call on success
  50973. * @param errorCallback defines the callback to call on error
  50974. */
  50975. open(successCallback: () => void, errorCallback: () => void): void;
  50976. /**
  50977. * Loads an image from the database
  50978. * @param url defines the url to load from
  50979. * @param image defines the target DOM image
  50980. */
  50981. loadImage(url: string, image: HTMLImageElement): void;
  50982. private _loadImageFromDBAsync;
  50983. private _saveImageIntoDBAsync;
  50984. private _checkVersionFromDB;
  50985. private _loadVersionFromDBAsync;
  50986. private _saveVersionIntoDBAsync;
  50987. /**
  50988. * Loads a file from database
  50989. * @param url defines the URL to load from
  50990. * @param sceneLoaded defines a callback to call on success
  50991. * @param progressCallBack defines a callback to call when progress changed
  50992. * @param errorCallback defines a callback to call on error
  50993. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50994. */
  50995. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50996. private _loadFileAsync;
  50997. private _saveFileAsync;
  50998. /**
  50999. * Validates if xhr data is correct
  51000. * @param xhr defines the request to validate
  51001. * @param dataType defines the expected data type
  51002. * @returns true if data is correct
  51003. */
  51004. private static _ValidateXHRData;
  51005. }
  51006. }
  51007. declare module "babylonjs/Offline/index" {
  51008. export * from "babylonjs/Offline/database";
  51009. export * from "babylonjs/Offline/IOfflineProvider";
  51010. }
  51011. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51012. /** @hidden */
  51013. export var gpuUpdateParticlesPixelShader: {
  51014. name: string;
  51015. shader: string;
  51016. };
  51017. }
  51018. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51019. /** @hidden */
  51020. export var gpuUpdateParticlesVertexShader: {
  51021. name: string;
  51022. shader: string;
  51023. };
  51024. }
  51025. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51026. /** @hidden */
  51027. export var clipPlaneFragmentDeclaration2: {
  51028. name: string;
  51029. shader: string;
  51030. };
  51031. }
  51032. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51033. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51034. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51035. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51036. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51037. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51038. /** @hidden */
  51039. export var gpuRenderParticlesPixelShader: {
  51040. name: string;
  51041. shader: string;
  51042. };
  51043. }
  51044. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51045. /** @hidden */
  51046. export var clipPlaneVertexDeclaration2: {
  51047. name: string;
  51048. shader: string;
  51049. };
  51050. }
  51051. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51052. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51053. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51054. /** @hidden */
  51055. export var gpuRenderParticlesVertexShader: {
  51056. name: string;
  51057. shader: string;
  51058. };
  51059. }
  51060. declare module "babylonjs/Particles/gpuParticleSystem" {
  51061. import { Nullable } from "babylonjs/types";
  51062. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51063. import { Observable } from "babylonjs/Misc/observable";
  51064. import { Color4, Color3 } from "babylonjs/Maths/math";
  51065. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51066. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51067. import { Scene, IDisposable } from "babylonjs/scene";
  51068. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51069. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51070. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51071. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51072. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51073. /**
  51074. * This represents a GPU particle system in Babylon
  51075. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51076. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51077. */
  51078. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51079. /**
  51080. * The layer mask we are rendering the particles through.
  51081. */
  51082. layerMask: number;
  51083. private _capacity;
  51084. private _activeCount;
  51085. private _currentActiveCount;
  51086. private _accumulatedCount;
  51087. private _renderEffect;
  51088. private _updateEffect;
  51089. private _buffer0;
  51090. private _buffer1;
  51091. private _spriteBuffer;
  51092. private _updateVAO;
  51093. private _renderVAO;
  51094. private _targetIndex;
  51095. private _sourceBuffer;
  51096. private _targetBuffer;
  51097. private _engine;
  51098. private _currentRenderId;
  51099. private _started;
  51100. private _stopped;
  51101. private _timeDelta;
  51102. private _randomTexture;
  51103. private _randomTexture2;
  51104. private _attributesStrideSize;
  51105. private _updateEffectOptions;
  51106. private _randomTextureSize;
  51107. private _actualFrame;
  51108. private readonly _rawTextureWidth;
  51109. /**
  51110. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51111. */
  51112. static readonly IsSupported: boolean;
  51113. /**
  51114. * An event triggered when the system is disposed.
  51115. */
  51116. onDisposeObservable: Observable<GPUParticleSystem>;
  51117. /**
  51118. * Gets the maximum number of particles active at the same time.
  51119. * @returns The max number of active particles.
  51120. */
  51121. getCapacity(): number;
  51122. /**
  51123. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51124. * to override the particles.
  51125. */
  51126. forceDepthWrite: boolean;
  51127. /**
  51128. * Gets or set the number of active particles
  51129. */
  51130. activeParticleCount: number;
  51131. private _preWarmDone;
  51132. /**
  51133. * Is this system ready to be used/rendered
  51134. * @return true if the system is ready
  51135. */
  51136. isReady(): boolean;
  51137. /**
  51138. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51139. * @returns True if it has been started, otherwise false.
  51140. */
  51141. isStarted(): boolean;
  51142. /**
  51143. * Starts the particle system and begins to emit
  51144. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51145. */
  51146. start(delay?: number): void;
  51147. /**
  51148. * Stops the particle system.
  51149. */
  51150. stop(): void;
  51151. /**
  51152. * Remove all active particles
  51153. */
  51154. reset(): void;
  51155. /**
  51156. * Returns the string "GPUParticleSystem"
  51157. * @returns a string containing the class name
  51158. */
  51159. getClassName(): string;
  51160. private _colorGradientsTexture;
  51161. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51162. /**
  51163. * Adds a new color gradient
  51164. * @param gradient defines the gradient to use (between 0 and 1)
  51165. * @param color1 defines the color to affect to the specified gradient
  51166. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51167. * @returns the current particle system
  51168. */
  51169. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51170. /**
  51171. * Remove a specific color gradient
  51172. * @param gradient defines the gradient to remove
  51173. * @returns the current particle system
  51174. */
  51175. removeColorGradient(gradient: number): GPUParticleSystem;
  51176. private _angularSpeedGradientsTexture;
  51177. private _sizeGradientsTexture;
  51178. private _velocityGradientsTexture;
  51179. private _limitVelocityGradientsTexture;
  51180. private _dragGradientsTexture;
  51181. private _addFactorGradient;
  51182. /**
  51183. * Adds a new size gradient
  51184. * @param gradient defines the gradient to use (between 0 and 1)
  51185. * @param factor defines the size factor to affect to the specified gradient
  51186. * @returns the current particle system
  51187. */
  51188. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51189. /**
  51190. * Remove a specific size gradient
  51191. * @param gradient defines the gradient to remove
  51192. * @returns the current particle system
  51193. */
  51194. removeSizeGradient(gradient: number): GPUParticleSystem;
  51195. /**
  51196. * Adds a new angular speed gradient
  51197. * @param gradient defines the gradient to use (between 0 and 1)
  51198. * @param factor defines the angular speed to affect to the specified gradient
  51199. * @returns the current particle system
  51200. */
  51201. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51202. /**
  51203. * Remove a specific angular speed gradient
  51204. * @param gradient defines the gradient to remove
  51205. * @returns the current particle system
  51206. */
  51207. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51208. /**
  51209. * Adds a new velocity gradient
  51210. * @param gradient defines the gradient to use (between 0 and 1)
  51211. * @param factor defines the velocity to affect to the specified gradient
  51212. * @returns the current particle system
  51213. */
  51214. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51215. /**
  51216. * Remove a specific velocity gradient
  51217. * @param gradient defines the gradient to remove
  51218. * @returns the current particle system
  51219. */
  51220. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51221. /**
  51222. * Adds a new limit velocity gradient
  51223. * @param gradient defines the gradient to use (between 0 and 1)
  51224. * @param factor defines the limit velocity value to affect to the specified gradient
  51225. * @returns the current particle system
  51226. */
  51227. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51228. /**
  51229. * Remove a specific limit velocity gradient
  51230. * @param gradient defines the gradient to remove
  51231. * @returns the current particle system
  51232. */
  51233. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51234. /**
  51235. * Adds a new drag gradient
  51236. * @param gradient defines the gradient to use (between 0 and 1)
  51237. * @param factor defines the drag value to affect to the specified gradient
  51238. * @returns the current particle system
  51239. */
  51240. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51241. /**
  51242. * Remove a specific drag gradient
  51243. * @param gradient defines the gradient to remove
  51244. * @returns the current particle system
  51245. */
  51246. removeDragGradient(gradient: number): GPUParticleSystem;
  51247. /**
  51248. * Not supported by GPUParticleSystem
  51249. * @param gradient defines the gradient to use (between 0 and 1)
  51250. * @param factor defines the emit rate value to affect to the specified gradient
  51251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51252. * @returns the current particle system
  51253. */
  51254. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51255. /**
  51256. * Not supported by GPUParticleSystem
  51257. * @param gradient defines the gradient to remove
  51258. * @returns the current particle system
  51259. */
  51260. removeEmitRateGradient(gradient: number): IParticleSystem;
  51261. /**
  51262. * Not supported by GPUParticleSystem
  51263. * @param gradient defines the gradient to use (between 0 and 1)
  51264. * @param factor defines the start size value to affect to the specified gradient
  51265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51266. * @returns the current particle system
  51267. */
  51268. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51269. /**
  51270. * Not supported by GPUParticleSystem
  51271. * @param gradient defines the gradient to remove
  51272. * @returns the current particle system
  51273. */
  51274. removeStartSizeGradient(gradient: number): IParticleSystem;
  51275. /**
  51276. * Not supported by GPUParticleSystem
  51277. * @param gradient defines the gradient to use (between 0 and 1)
  51278. * @param min defines the color remap minimal range
  51279. * @param max defines the color remap maximal range
  51280. * @returns the current particle system
  51281. */
  51282. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51283. /**
  51284. * Not supported by GPUParticleSystem
  51285. * @param gradient defines the gradient to remove
  51286. * @returns the current particle system
  51287. */
  51288. removeColorRemapGradient(): IParticleSystem;
  51289. /**
  51290. * Not supported by GPUParticleSystem
  51291. * @param gradient defines the gradient to use (between 0 and 1)
  51292. * @param min defines the alpha remap minimal range
  51293. * @param max defines the alpha remap maximal range
  51294. * @returns the current particle system
  51295. */
  51296. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51297. /**
  51298. * Not supported by GPUParticleSystem
  51299. * @param gradient defines the gradient to remove
  51300. * @returns the current particle system
  51301. */
  51302. removeAlphaRemapGradient(): IParticleSystem;
  51303. /**
  51304. * Not supported by GPUParticleSystem
  51305. * @param gradient defines the gradient to use (between 0 and 1)
  51306. * @param color defines the color to affect to the specified gradient
  51307. * @returns the current particle system
  51308. */
  51309. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51310. /**
  51311. * Not supported by GPUParticleSystem
  51312. * @param gradient defines the gradient to remove
  51313. * @returns the current particle system
  51314. */
  51315. removeRampGradient(): IParticleSystem;
  51316. /**
  51317. * Not supported by GPUParticleSystem
  51318. * @returns the list of ramp gradients
  51319. */
  51320. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51321. /**
  51322. * Not supported by GPUParticleSystem
  51323. * Gets or sets a boolean indicating that ramp gradients must be used
  51324. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51325. */
  51326. useRampGradients: boolean;
  51327. /**
  51328. * Not supported by GPUParticleSystem
  51329. * @param gradient defines the gradient to use (between 0 and 1)
  51330. * @param factor defines the life time factor to affect to the specified gradient
  51331. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51332. * @returns the current particle system
  51333. */
  51334. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51335. /**
  51336. * Not supported by GPUParticleSystem
  51337. * @param gradient defines the gradient to remove
  51338. * @returns the current particle system
  51339. */
  51340. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51341. /**
  51342. * Instantiates a GPU particle system.
  51343. * 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.
  51344. * @param name The name of the particle system
  51345. * @param options The options used to create the system
  51346. * @param scene The scene the particle system belongs to
  51347. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51348. */
  51349. constructor(name: string, options: Partial<{
  51350. capacity: number;
  51351. randomTextureSize: number;
  51352. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51353. protected _reset(): void;
  51354. private _createUpdateVAO;
  51355. private _createRenderVAO;
  51356. private _initialize;
  51357. /** @hidden */
  51358. _recreateUpdateEffect(): void;
  51359. /** @hidden */
  51360. _recreateRenderEffect(): void;
  51361. /**
  51362. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51363. * @param preWarm defines if we are in the pre-warmimg phase
  51364. */
  51365. animate(preWarm?: boolean): void;
  51366. private _createFactorGradientTexture;
  51367. private _createSizeGradientTexture;
  51368. private _createAngularSpeedGradientTexture;
  51369. private _createVelocityGradientTexture;
  51370. private _createLimitVelocityGradientTexture;
  51371. private _createDragGradientTexture;
  51372. private _createColorGradientTexture;
  51373. /**
  51374. * Renders the particle system in its current state
  51375. * @param preWarm defines if the system should only update the particles but not render them
  51376. * @returns the current number of particles
  51377. */
  51378. render(preWarm?: boolean): number;
  51379. /**
  51380. * Rebuilds the particle system
  51381. */
  51382. rebuild(): void;
  51383. private _releaseBuffers;
  51384. private _releaseVAOs;
  51385. /**
  51386. * Disposes the particle system and free the associated resources
  51387. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51388. */
  51389. dispose(disposeTexture?: boolean): void;
  51390. /**
  51391. * Clones the particle system.
  51392. * @param name The name of the cloned object
  51393. * @param newEmitter The new emitter to use
  51394. * @returns the cloned particle system
  51395. */
  51396. clone(name: string, newEmitter: any): GPUParticleSystem;
  51397. /**
  51398. * Serializes the particle system to a JSON object.
  51399. * @returns the JSON object
  51400. */
  51401. serialize(): any;
  51402. /**
  51403. * Parses a JSON object to create a GPU particle system.
  51404. * @param parsedParticleSystem The JSON object to parse
  51405. * @param scene The scene to create the particle system in
  51406. * @param rootUrl The root url to use to load external dependencies like texture
  51407. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51408. * @returns the parsed GPU particle system
  51409. */
  51410. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51411. }
  51412. }
  51413. declare module "babylonjs/Particles/particleSystemSet" {
  51414. import { Nullable } from "babylonjs/types";
  51415. import { Color3 } from "babylonjs/Maths/math";
  51416. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51418. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51419. import { Scene, IDisposable } from "babylonjs/scene";
  51420. /**
  51421. * Represents a set of particle systems working together to create a specific effect
  51422. */
  51423. export class ParticleSystemSet implements IDisposable {
  51424. private _emitterCreationOptions;
  51425. private _emitterNode;
  51426. /**
  51427. * Gets the particle system list
  51428. */
  51429. systems: IParticleSystem[];
  51430. /**
  51431. * Gets the emitter node used with this set
  51432. */
  51433. readonly emitterNode: Nullable<TransformNode>;
  51434. /**
  51435. * Creates a new emitter mesh as a sphere
  51436. * @param options defines the options used to create the sphere
  51437. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51438. * @param scene defines the hosting scene
  51439. */
  51440. setEmitterAsSphere(options: {
  51441. diameter: number;
  51442. segments: number;
  51443. color: Color3;
  51444. }, renderingGroupId: number, scene: Scene): void;
  51445. /**
  51446. * Starts all particle systems of the set
  51447. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51448. */
  51449. start(emitter?: AbstractMesh): void;
  51450. /**
  51451. * Release all associated resources
  51452. */
  51453. dispose(): void;
  51454. /**
  51455. * Serialize the set into a JSON compatible object
  51456. * @returns a JSON compatible representation of the set
  51457. */
  51458. serialize(): any;
  51459. /**
  51460. * Parse a new ParticleSystemSet from a serialized source
  51461. * @param data defines a JSON compatible representation of the set
  51462. * @param scene defines the hosting scene
  51463. * @param gpu defines if we want GPU particles or CPU particles
  51464. * @returns a new ParticleSystemSet
  51465. */
  51466. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51467. }
  51468. }
  51469. declare module "babylonjs/Particles/particleHelper" {
  51470. import { Nullable } from "babylonjs/types";
  51471. import { Scene } from "babylonjs/scene";
  51472. import { Vector3 } from "babylonjs/Maths/math";
  51473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51474. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51475. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  51476. /**
  51477. * This class is made for on one-liner static method to help creating particle system set.
  51478. */
  51479. export class ParticleHelper {
  51480. /**
  51481. * Gets or sets base Assets URL
  51482. */
  51483. static BaseAssetsUrl: string;
  51484. /**
  51485. * Create a default particle system that you can tweak
  51486. * @param emitter defines the emitter to use
  51487. * @param capacity defines the system capacity (default is 500 particles)
  51488. * @param scene defines the hosting scene
  51489. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51490. * @returns the new Particle system
  51491. */
  51492. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51493. /**
  51494. * This is the main static method (one-liner) of this helper to create different particle systems
  51495. * @param type This string represents the type to the particle system to create
  51496. * @param scene The scene where the particle system should live
  51497. * @param gpu If the system will use gpu
  51498. * @returns the ParticleSystemSet created
  51499. */
  51500. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51501. /**
  51502. * Static function used to export a particle system to a ParticleSystemSet variable.
  51503. * Please note that the emitter shape is not exported
  51504. * @param systems defines the particle systems to export
  51505. * @returns the created particle system set
  51506. */
  51507. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51508. }
  51509. }
  51510. declare module "babylonjs/Particles/particleSystemComponent" {
  51511. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51512. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  51513. import "babylonjs/Shaders/particles.vertex";
  51514. module "babylonjs/Engines/engine" {
  51515. interface Engine {
  51516. /**
  51517. * Create an effect to use with particle systems.
  51518. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51519. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51520. * @param uniformsNames defines a list of attribute names
  51521. * @param samplers defines an array of string used to represent textures
  51522. * @param defines defines the string containing the defines to use to compile the shaders
  51523. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51524. * @param onCompiled defines a function to call when the effect creation is successful
  51525. * @param onError defines a function to call when the effect creation has failed
  51526. * @returns the new Effect
  51527. */
  51528. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51529. }
  51530. }
  51531. module "babylonjs/Meshes/mesh" {
  51532. interface Mesh {
  51533. /**
  51534. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51535. * @returns an array of IParticleSystem
  51536. */
  51537. getEmittedParticleSystems(): IParticleSystem[];
  51538. /**
  51539. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51540. * @returns an array of IParticleSystem
  51541. */
  51542. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51543. }
  51544. }
  51545. /**
  51546. * @hidden
  51547. */
  51548. export var _IDoNeedToBeInTheBuild: number;
  51549. }
  51550. declare module "babylonjs/Particles/index" {
  51551. export * from "babylonjs/Particles/baseParticleSystem";
  51552. export * from "babylonjs/Particles/EmitterTypes/index";
  51553. export * from "babylonjs/Particles/gpuParticleSystem";
  51554. export * from "babylonjs/Particles/IParticleSystem";
  51555. export * from "babylonjs/Particles/particle";
  51556. export * from "babylonjs/Particles/particleHelper";
  51557. export * from "babylonjs/Particles/particleSystem";
  51558. export * from "babylonjs/Particles/particleSystemComponent";
  51559. export * from "babylonjs/Particles/particleSystemSet";
  51560. export * from "babylonjs/Particles/solidParticle";
  51561. export * from "babylonjs/Particles/solidParticleSystem";
  51562. export * from "babylonjs/Particles/subEmitter";
  51563. }
  51564. declare module "babylonjs/Physics/physicsEngineComponent" {
  51565. import { Nullable } from "babylonjs/types";
  51566. import { Observable, Observer } from "babylonjs/Misc/observable";
  51567. import { Vector3 } from "babylonjs/Maths/math";
  51568. import { Mesh } from "babylonjs/Meshes/mesh";
  51569. import { ISceneComponent } from "babylonjs/sceneComponent";
  51570. import { Scene } from "babylonjs/scene";
  51571. import { Node } from "babylonjs/node";
  51572. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51573. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51574. module "babylonjs/scene" {
  51575. interface Scene {
  51576. /** @hidden (Backing field) */
  51577. _physicsEngine: Nullable<IPhysicsEngine>;
  51578. /**
  51579. * Gets the current physics engine
  51580. * @returns a IPhysicsEngine or null if none attached
  51581. */
  51582. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51583. /**
  51584. * Enables physics to the current scene
  51585. * @param gravity defines the scene's gravity for the physics engine
  51586. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51587. * @return a boolean indicating if the physics engine was initialized
  51588. */
  51589. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51590. /**
  51591. * Disables and disposes the physics engine associated with the scene
  51592. */
  51593. disablePhysicsEngine(): void;
  51594. /**
  51595. * Gets a boolean indicating if there is an active physics engine
  51596. * @returns a boolean indicating if there is an active physics engine
  51597. */
  51598. isPhysicsEnabled(): boolean;
  51599. /**
  51600. * Deletes a physics compound impostor
  51601. * @param compound defines the compound to delete
  51602. */
  51603. deleteCompoundImpostor(compound: any): void;
  51604. /**
  51605. * An event triggered when physic simulation is about to be run
  51606. */
  51607. onBeforePhysicsObservable: Observable<Scene>;
  51608. /**
  51609. * An event triggered when physic simulation has been done
  51610. */
  51611. onAfterPhysicsObservable: Observable<Scene>;
  51612. }
  51613. }
  51614. module "babylonjs/Meshes/abstractMesh" {
  51615. interface AbstractMesh {
  51616. /** @hidden */
  51617. _physicsImpostor: Nullable<PhysicsImpostor>;
  51618. /**
  51619. * Gets or sets impostor used for physic simulation
  51620. * @see http://doc.babylonjs.com/features/physics_engine
  51621. */
  51622. physicsImpostor: Nullable<PhysicsImpostor>;
  51623. /**
  51624. * Gets the current physics impostor
  51625. * @see http://doc.babylonjs.com/features/physics_engine
  51626. * @returns a physics impostor or null
  51627. */
  51628. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51629. /** Apply a physic impulse to the mesh
  51630. * @param force defines the force to apply
  51631. * @param contactPoint defines where to apply the force
  51632. * @returns the current mesh
  51633. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51634. */
  51635. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51636. /**
  51637. * Creates a physic joint between two meshes
  51638. * @param otherMesh defines the other mesh to use
  51639. * @param pivot1 defines the pivot to use on this mesh
  51640. * @param pivot2 defines the pivot to use on the other mesh
  51641. * @param options defines additional options (can be plugin dependent)
  51642. * @returns the current mesh
  51643. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51644. */
  51645. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51646. /** @hidden */
  51647. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51648. }
  51649. }
  51650. /**
  51651. * Defines the physics engine scene component responsible to manage a physics engine
  51652. */
  51653. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51654. /**
  51655. * The component name helpful to identify the component in the list of scene components.
  51656. */
  51657. readonly name: string;
  51658. /**
  51659. * The scene the component belongs to.
  51660. */
  51661. scene: Scene;
  51662. /**
  51663. * Creates a new instance of the component for the given scene
  51664. * @param scene Defines the scene to register the component in
  51665. */
  51666. constructor(scene: Scene);
  51667. /**
  51668. * Registers the component in a given scene
  51669. */
  51670. register(): void;
  51671. /**
  51672. * Rebuilds the elements related to this component in case of
  51673. * context lost for instance.
  51674. */
  51675. rebuild(): void;
  51676. /**
  51677. * Disposes the component and the associated ressources
  51678. */
  51679. dispose(): void;
  51680. }
  51681. }
  51682. declare module "babylonjs/Physics/physicsHelper" {
  51683. import { Nullable } from "babylonjs/types";
  51684. import { Vector3 } from "babylonjs/Maths/math";
  51685. import { Mesh } from "babylonjs/Meshes/mesh";
  51686. import { Ray } from "babylonjs/Culling/ray";
  51687. import { Scene } from "babylonjs/scene";
  51688. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51689. /**
  51690. * A helper for physics simulations
  51691. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51692. */
  51693. export class PhysicsHelper {
  51694. private _scene;
  51695. private _physicsEngine;
  51696. /**
  51697. * Initializes the Physics helper
  51698. * @param scene Babylon.js scene
  51699. */
  51700. constructor(scene: Scene);
  51701. /**
  51702. * Applies a radial explosion impulse
  51703. * @param origin the origin of the explosion
  51704. * @param radius the explosion radius
  51705. * @param strength the explosion strength
  51706. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51707. * @returns A physics radial explosion event, or null
  51708. */
  51709. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51710. /**
  51711. * Applies a radial explosion force
  51712. * @param origin the origin of the explosion
  51713. * @param radius the explosion radius
  51714. * @param strength the explosion strength
  51715. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51716. * @returns A physics radial explosion event, or null
  51717. */
  51718. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51719. /**
  51720. * Creates a gravitational field
  51721. * @param origin the origin of the explosion
  51722. * @param radius the explosion radius
  51723. * @param strength the explosion strength
  51724. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51725. * @returns A physics gravitational field event, or null
  51726. */
  51727. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51728. /**
  51729. * Creates a physics updraft event
  51730. * @param origin the origin of the updraft
  51731. * @param radius the radius of the updraft
  51732. * @param strength the strength of the updraft
  51733. * @param height the height of the updraft
  51734. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51735. * @returns A physics updraft event, or null
  51736. */
  51737. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51738. /**
  51739. * Creates a physics vortex event
  51740. * @param origin the of the vortex
  51741. * @param radius the radius of the vortex
  51742. * @param strength the strength of the vortex
  51743. * @param height the height of the vortex
  51744. * @returns a Physics vortex event, or null
  51745. * A physics vortex event or null
  51746. */
  51747. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  51748. }
  51749. /**
  51750. * Represents a physics radial explosion event
  51751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51752. */
  51753. export class PhysicsRadialExplosionEvent {
  51754. private _scene;
  51755. private _sphere;
  51756. private _sphereOptions;
  51757. private _rays;
  51758. private _dataFetched;
  51759. /**
  51760. * Initializes a radial explosioin event
  51761. * @param scene BabylonJS scene
  51762. */
  51763. constructor(scene: Scene);
  51764. /**
  51765. * Returns the data related to the radial explosion event (sphere & rays).
  51766. * @returns The radial explosion event data
  51767. */
  51768. getData(): PhysicsRadialExplosionEventData;
  51769. /**
  51770. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51771. * @param impostor A physics imposter
  51772. * @param origin the origin of the explosion
  51773. * @param radius the explosion radius
  51774. * @param strength the explosion strength
  51775. * @param falloff possible options: Constant & Linear
  51776. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  51777. */
  51778. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  51779. /**
  51780. * Disposes the sphere.
  51781. * @param force Specifies if the sphere should be disposed by force
  51782. */
  51783. dispose(force?: boolean): void;
  51784. /*** Helpers ***/
  51785. private _prepareSphere;
  51786. private _intersectsWithSphere;
  51787. }
  51788. /**
  51789. * Represents a gravitational field event
  51790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51791. */
  51792. export class PhysicsGravitationalFieldEvent {
  51793. private _physicsHelper;
  51794. private _scene;
  51795. private _origin;
  51796. private _radius;
  51797. private _strength;
  51798. private _falloff;
  51799. private _tickCallback;
  51800. private _sphere;
  51801. private _dataFetched;
  51802. /**
  51803. * Initializes the physics gravitational field event
  51804. * @param physicsHelper A physics helper
  51805. * @param scene BabylonJS scene
  51806. * @param origin The origin position of the gravitational field event
  51807. * @param radius The radius of the gravitational field event
  51808. * @param strength The strength of the gravitational field event
  51809. * @param falloff The falloff for the gravitational field event
  51810. */
  51811. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  51812. /**
  51813. * Returns the data related to the gravitational field event (sphere).
  51814. * @returns A gravitational field event
  51815. */
  51816. getData(): PhysicsGravitationalFieldEventData;
  51817. /**
  51818. * Enables the gravitational field.
  51819. */
  51820. enable(): void;
  51821. /**
  51822. * Disables the gravitational field.
  51823. */
  51824. disable(): void;
  51825. /**
  51826. * Disposes the sphere.
  51827. * @param force The force to dispose from the gravitational field event
  51828. */
  51829. dispose(force?: boolean): void;
  51830. private _tick;
  51831. }
  51832. /**
  51833. * Represents a physics updraft event
  51834. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51835. */
  51836. export class PhysicsUpdraftEvent {
  51837. private _scene;
  51838. private _origin;
  51839. private _radius;
  51840. private _strength;
  51841. private _height;
  51842. private _updraftMode;
  51843. private _physicsEngine;
  51844. private _originTop;
  51845. private _originDirection;
  51846. private _tickCallback;
  51847. private _cylinder;
  51848. private _cylinderPosition;
  51849. private _dataFetched;
  51850. /**
  51851. * Initializes the physics updraft event
  51852. * @param _scene BabylonJS scene
  51853. * @param _origin The origin position of the updraft
  51854. * @param _radius The radius of the updraft
  51855. * @param _strength The strength of the updraft
  51856. * @param _height The height of the updraft
  51857. * @param _updraftMode The mode of the updraft
  51858. */
  51859. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  51860. /**
  51861. * Returns the data related to the updraft event (cylinder).
  51862. * @returns A physics updraft event
  51863. */
  51864. getData(): PhysicsUpdraftEventData;
  51865. /**
  51866. * Enables the updraft.
  51867. */
  51868. enable(): void;
  51869. /**
  51870. * Disables the cortex.
  51871. */
  51872. disable(): void;
  51873. /**
  51874. * Disposes the sphere.
  51875. * @param force Specifies if the updraft should be disposed by force
  51876. */
  51877. dispose(force?: boolean): void;
  51878. private getImpostorForceAndContactPoint;
  51879. private _tick;
  51880. /*** Helpers ***/
  51881. private _prepareCylinder;
  51882. private _intersectsWithCylinder;
  51883. }
  51884. /**
  51885. * Represents a physics vortex event
  51886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51887. */
  51888. export class PhysicsVortexEvent {
  51889. private _scene;
  51890. private _origin;
  51891. private _radius;
  51892. private _strength;
  51893. private _height;
  51894. private _physicsEngine;
  51895. private _originTop;
  51896. private _centripetalForceThreshold;
  51897. private _updraftMultiplier;
  51898. private _tickCallback;
  51899. private _cylinder;
  51900. private _cylinderPosition;
  51901. private _dataFetched;
  51902. /**
  51903. * Initializes the physics vortex event
  51904. * @param _scene The BabylonJS scene
  51905. * @param _origin The origin position of the vortex
  51906. * @param _radius The radius of the vortex
  51907. * @param _strength The strength of the vortex
  51908. * @param _height The height of the vortex
  51909. */
  51910. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  51911. /**
  51912. * Returns the data related to the vortex event (cylinder).
  51913. * @returns The physics vortex event data
  51914. */
  51915. getData(): PhysicsVortexEventData;
  51916. /**
  51917. * Enables the vortex.
  51918. */
  51919. enable(): void;
  51920. /**
  51921. * Disables the cortex.
  51922. */
  51923. disable(): void;
  51924. /**
  51925. * Disposes the sphere.
  51926. * @param force
  51927. */
  51928. dispose(force?: boolean): void;
  51929. private getImpostorForceAndContactPoint;
  51930. private _tick;
  51931. /*** Helpers ***/
  51932. private _prepareCylinder;
  51933. private _intersectsWithCylinder;
  51934. }
  51935. /**
  51936. * The strenght of the force in correspondence to the distance of the affected object
  51937. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51938. */
  51939. export enum PhysicsRadialImpulseFalloff {
  51940. /** Defines that impulse is constant in strength across it's whole radius */
  51941. Constant = 0,
  51942. /** DEfines that impulse gets weaker if it's further from the origin */
  51943. Linear = 1
  51944. }
  51945. /**
  51946. * The strength of the force in correspondence to the distance of the affected object
  51947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51948. */
  51949. export enum PhysicsUpdraftMode {
  51950. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51951. Center = 0,
  51952. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51953. Perpendicular = 1
  51954. }
  51955. /**
  51956. * Interface for a physics force and contact point
  51957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51958. */
  51959. export interface PhysicsForceAndContactPoint {
  51960. /**
  51961. * The force applied at the contact point
  51962. */
  51963. force: Vector3;
  51964. /**
  51965. * The contact point
  51966. */
  51967. contactPoint: Vector3;
  51968. }
  51969. /**
  51970. * Interface for radial explosion event data
  51971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51972. */
  51973. export interface PhysicsRadialExplosionEventData {
  51974. /**
  51975. * A sphere used for the radial explosion event
  51976. */
  51977. sphere: Mesh;
  51978. /**
  51979. * An array of rays for the radial explosion event
  51980. */
  51981. rays: Array<Ray>;
  51982. }
  51983. /**
  51984. * Interface for gravitational field event data
  51985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51986. */
  51987. export interface PhysicsGravitationalFieldEventData {
  51988. /**
  51989. * A sphere mesh used for the gravitational field event
  51990. */
  51991. sphere: Mesh;
  51992. }
  51993. /**
  51994. * Interface for updraft event data
  51995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51996. */
  51997. export interface PhysicsUpdraftEventData {
  51998. /**
  51999. * A cylinder used for the updraft event
  52000. */
  52001. cylinder: Mesh;
  52002. }
  52003. /**
  52004. * Interface for vortex event data
  52005. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52006. */
  52007. export interface PhysicsVortexEventData {
  52008. /**
  52009. * A cylinder used for the vortex event
  52010. */
  52011. cylinder: Mesh;
  52012. }
  52013. }
  52014. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52015. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52016. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52017. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52018. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52019. import { Nullable } from "babylonjs/types";
  52020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52021. /**
  52022. * AmmoJS Physics plugin
  52023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52024. * @see https://github.com/kripken/ammo.js/
  52025. */
  52026. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52027. private _useDeltaForWorldStep;
  52028. /**
  52029. * Reference to the Ammo library
  52030. */
  52031. bjsAMMO: any;
  52032. /**
  52033. * Created ammoJS world which physics bodies are added to
  52034. */
  52035. world: any;
  52036. /**
  52037. * Name of the plugin
  52038. */
  52039. name: string;
  52040. private _timeStep;
  52041. private _fixedTimeStep;
  52042. private _maxSteps;
  52043. private _tmpQuaternion;
  52044. private _tmpAmmoTransform;
  52045. private _tmpAmmoQuaternion;
  52046. private _tmpAmmoConcreteContactResultCallback;
  52047. private _collisionConfiguration;
  52048. private _dispatcher;
  52049. private _overlappingPairCache;
  52050. private _solver;
  52051. private _tmpAmmoVectorA;
  52052. private _tmpAmmoVectorB;
  52053. private _tmpAmmoVectorC;
  52054. private _tmpContactCallbackResult;
  52055. private static readonly DISABLE_COLLISION_FLAG;
  52056. private static readonly KINEMATIC_FLAG;
  52057. private static readonly DISABLE_DEACTIVATION_FLAG;
  52058. /**
  52059. * Initializes the ammoJS plugin
  52060. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52061. * @param ammoInjection can be used to inject your own ammo reference
  52062. */
  52063. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  52064. /**
  52065. * Sets the gravity of the physics world (m/(s^2))
  52066. * @param gravity Gravity to set
  52067. */
  52068. setGravity(gravity: Vector3): void;
  52069. /**
  52070. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52071. * @param timeStep timestep to use in seconds
  52072. */
  52073. setTimeStep(timeStep: number): void;
  52074. /**
  52075. * 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)
  52076. * @param fixedTimeStep fixedTimeStep to use in seconds
  52077. */
  52078. setFixedTimeStep(fixedTimeStep: number): void;
  52079. /**
  52080. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52081. * @param maxSteps the maximum number of steps by the physics engine per frame
  52082. */
  52083. setMaxSteps(maxSteps: number): void;
  52084. /**
  52085. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52086. * @returns the current timestep in seconds
  52087. */
  52088. getTimeStep(): number;
  52089. private _isImpostorInContact;
  52090. private _isImpostorPairInContact;
  52091. private _stepSimulation;
  52092. /**
  52093. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52094. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52095. * After the step the babylon meshes are set to the position of the physics imposters
  52096. * @param delta amount of time to step forward
  52097. * @param impostors array of imposters to update before/after the step
  52098. */
  52099. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52100. private _tmpVector;
  52101. private _tmpMatrix;
  52102. /**
  52103. * Applies an implulse on the imposter
  52104. * @param impostor imposter to apply impulse
  52105. * @param force amount of force to be applied to the imposter
  52106. * @param contactPoint the location to apply the impulse on the imposter
  52107. */
  52108. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52109. /**
  52110. * Applies a force on the imposter
  52111. * @param impostor imposter to apply force
  52112. * @param force amount of force to be applied to the imposter
  52113. * @param contactPoint the location to apply the force on the imposter
  52114. */
  52115. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52116. /**
  52117. * Creates a physics body using the plugin
  52118. * @param impostor the imposter to create the physics body on
  52119. */
  52120. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52121. /**
  52122. * Removes the physics body from the imposter and disposes of the body's memory
  52123. * @param impostor imposter to remove the physics body from
  52124. */
  52125. removePhysicsBody(impostor: PhysicsImpostor): void;
  52126. /**
  52127. * Generates a joint
  52128. * @param impostorJoint the imposter joint to create the joint with
  52129. */
  52130. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52131. /**
  52132. * Removes a joint
  52133. * @param impostorJoint the imposter joint to remove the joint from
  52134. */
  52135. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52136. private _addMeshVerts;
  52137. private _createShape;
  52138. /**
  52139. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52140. * @param impostor imposter containing the physics body and babylon object
  52141. */
  52142. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52143. /**
  52144. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52145. * @param impostor imposter containing the physics body and babylon object
  52146. * @param newPosition new position
  52147. * @param newRotation new rotation
  52148. */
  52149. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52150. /**
  52151. * If this plugin is supported
  52152. * @returns true if its supported
  52153. */
  52154. isSupported(): boolean;
  52155. /**
  52156. * Sets the linear velocity of the physics body
  52157. * @param impostor imposter to set the velocity on
  52158. * @param velocity velocity to set
  52159. */
  52160. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52161. /**
  52162. * Sets the angular velocity of the physics body
  52163. * @param impostor imposter to set the velocity on
  52164. * @param velocity velocity to set
  52165. */
  52166. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52167. /**
  52168. * gets the linear velocity
  52169. * @param impostor imposter to get linear velocity from
  52170. * @returns linear velocity
  52171. */
  52172. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52173. /**
  52174. * gets the angular velocity
  52175. * @param impostor imposter to get angular velocity from
  52176. * @returns angular velocity
  52177. */
  52178. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52179. /**
  52180. * Sets the mass of physics body
  52181. * @param impostor imposter to set the mass on
  52182. * @param mass mass to set
  52183. */
  52184. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52185. /**
  52186. * Gets the mass of the physics body
  52187. * @param impostor imposter to get the mass from
  52188. * @returns mass
  52189. */
  52190. getBodyMass(impostor: PhysicsImpostor): number;
  52191. /**
  52192. * Gets friction of the impostor
  52193. * @param impostor impostor to get friction from
  52194. * @returns friction value
  52195. */
  52196. getBodyFriction(impostor: PhysicsImpostor): number;
  52197. /**
  52198. * Sets friction of the impostor
  52199. * @param impostor impostor to set friction on
  52200. * @param friction friction value
  52201. */
  52202. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52203. /**
  52204. * Gets restitution of the impostor
  52205. * @param impostor impostor to get restitution from
  52206. * @returns restitution value
  52207. */
  52208. getBodyRestitution(impostor: PhysicsImpostor): number;
  52209. /**
  52210. * Sets resitution of the impostor
  52211. * @param impostor impostor to set resitution on
  52212. * @param restitution resitution value
  52213. */
  52214. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52215. /**
  52216. * Sleeps the physics body and stops it from being active
  52217. * @param impostor impostor to sleep
  52218. */
  52219. sleepBody(impostor: PhysicsImpostor): void;
  52220. /**
  52221. * Activates the physics body
  52222. * @param impostor impostor to activate
  52223. */
  52224. wakeUpBody(impostor: PhysicsImpostor): void;
  52225. /**
  52226. * Updates the distance parameters of the joint
  52227. * @param joint joint to update
  52228. * @param maxDistance maximum distance of the joint
  52229. * @param minDistance minimum distance of the joint
  52230. */
  52231. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52232. /**
  52233. * Sets a motor on the joint
  52234. * @param joint joint to set motor on
  52235. * @param speed speed of the motor
  52236. * @param maxForce maximum force of the motor
  52237. * @param motorIndex index of the motor
  52238. */
  52239. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52240. /**
  52241. * Sets the motors limit
  52242. * @param joint joint to set limit on
  52243. * @param upperLimit upper limit
  52244. * @param lowerLimit lower limit
  52245. */
  52246. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52247. /**
  52248. * Syncs the position and rotation of a mesh with the impostor
  52249. * @param mesh mesh to sync
  52250. * @param impostor impostor to update the mesh with
  52251. */
  52252. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52253. /**
  52254. * Gets the radius of the impostor
  52255. * @param impostor impostor to get radius from
  52256. * @returns the radius
  52257. */
  52258. getRadius(impostor: PhysicsImpostor): number;
  52259. /**
  52260. * Gets the box size of the impostor
  52261. * @param impostor impostor to get box size from
  52262. * @param result the resulting box size
  52263. */
  52264. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52265. /**
  52266. * Disposes of the impostor
  52267. */
  52268. dispose(): void;
  52269. }
  52270. }
  52271. declare module "babylonjs/Physics/Plugins/index" {
  52272. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  52273. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  52274. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  52275. }
  52276. declare module "babylonjs/Physics/index" {
  52277. export * from "babylonjs/Physics/IPhysicsEngine";
  52278. export * from "babylonjs/Physics/physicsEngine";
  52279. export * from "babylonjs/Physics/physicsEngineComponent";
  52280. export * from "babylonjs/Physics/physicsHelper";
  52281. export * from "babylonjs/Physics/physicsImpostor";
  52282. export * from "babylonjs/Physics/physicsJoint";
  52283. export * from "babylonjs/Physics/Plugins/index";
  52284. }
  52285. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  52286. /** @hidden */
  52287. export var blackAndWhitePixelShader: {
  52288. name: string;
  52289. shader: string;
  52290. };
  52291. }
  52292. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  52293. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52294. import { Camera } from "babylonjs/Cameras/camera";
  52295. import { Engine } from "babylonjs/Engines/engine";
  52296. import "babylonjs/Shaders/blackAndWhite.fragment";
  52297. /**
  52298. * Post process used to render in black and white
  52299. */
  52300. export class BlackAndWhitePostProcess extends PostProcess {
  52301. /**
  52302. * Linear about to convert he result to black and white (default: 1)
  52303. */
  52304. degree: number;
  52305. /**
  52306. * Creates a black and white post process
  52307. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52308. * @param name The name of the effect.
  52309. * @param options The required width/height ratio to downsize to before computing the render pass.
  52310. * @param camera The camera to apply the render pass to.
  52311. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52312. * @param engine The engine which the post process will be applied. (default: current engine)
  52313. * @param reusable If the post process can be reused on the same frame. (default: false)
  52314. */
  52315. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52316. }
  52317. }
  52318. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  52319. import { Nullable } from "babylonjs/types";
  52320. import { Camera } from "babylonjs/Cameras/camera";
  52321. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52322. import { Engine } from "babylonjs/Engines/engine";
  52323. /**
  52324. * This represents a set of one or more post processes in Babylon.
  52325. * A post process can be used to apply a shader to a texture after it is rendered.
  52326. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52327. */
  52328. export class PostProcessRenderEffect {
  52329. private _postProcesses;
  52330. private _getPostProcesses;
  52331. private _singleInstance;
  52332. private _cameras;
  52333. private _indicesForCamera;
  52334. /**
  52335. * Name of the effect
  52336. * @hidden
  52337. */
  52338. _name: string;
  52339. /**
  52340. * Instantiates a post process render effect.
  52341. * A post process can be used to apply a shader to a texture after it is rendered.
  52342. * @param engine The engine the effect is tied to
  52343. * @param name The name of the effect
  52344. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52345. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52346. */
  52347. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52348. /**
  52349. * Checks if all the post processes in the effect are supported.
  52350. */
  52351. readonly isSupported: boolean;
  52352. /**
  52353. * Updates the current state of the effect
  52354. * @hidden
  52355. */
  52356. _update(): void;
  52357. /**
  52358. * Attaches the effect on cameras
  52359. * @param cameras The camera to attach to.
  52360. * @hidden
  52361. */
  52362. _attachCameras(cameras: Camera): void;
  52363. /**
  52364. * Attaches the effect on cameras
  52365. * @param cameras The camera to attach to.
  52366. * @hidden
  52367. */
  52368. _attachCameras(cameras: Camera[]): void;
  52369. /**
  52370. * Detatches the effect on cameras
  52371. * @param cameras The camera to detatch from.
  52372. * @hidden
  52373. */
  52374. _detachCameras(cameras: Camera): void;
  52375. /**
  52376. * Detatches the effect on cameras
  52377. * @param cameras The camera to detatch from.
  52378. * @hidden
  52379. */
  52380. _detachCameras(cameras: Camera[]): void;
  52381. /**
  52382. * Enables the effect on given cameras
  52383. * @param cameras The camera to enable.
  52384. * @hidden
  52385. */
  52386. _enable(cameras: Camera): void;
  52387. /**
  52388. * Enables the effect on given cameras
  52389. * @param cameras The camera to enable.
  52390. * @hidden
  52391. */
  52392. _enable(cameras: Nullable<Camera[]>): void;
  52393. /**
  52394. * Disables the effect on the given cameras
  52395. * @param cameras The camera to disable.
  52396. * @hidden
  52397. */
  52398. _disable(cameras: Camera): void;
  52399. /**
  52400. * Disables the effect on the given cameras
  52401. * @param cameras The camera to disable.
  52402. * @hidden
  52403. */
  52404. _disable(cameras: Nullable<Camera[]>): void;
  52405. /**
  52406. * Gets a list of the post processes contained in the effect.
  52407. * @param camera The camera to get the post processes on.
  52408. * @returns The list of the post processes in the effect.
  52409. */
  52410. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52411. }
  52412. }
  52413. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  52414. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52415. /** @hidden */
  52416. export var extractHighlightsPixelShader: {
  52417. name: string;
  52418. shader: string;
  52419. };
  52420. }
  52421. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  52422. import { Nullable } from "babylonjs/types";
  52423. import { Camera } from "babylonjs/Cameras/camera";
  52424. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52425. import { Engine } from "babylonjs/Engines/engine";
  52426. import "babylonjs/Shaders/extractHighlights.fragment";
  52427. /**
  52428. * 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.
  52429. */
  52430. export class ExtractHighlightsPostProcess extends PostProcess {
  52431. /**
  52432. * The luminance threshold, pixels below this value will be set to black.
  52433. */
  52434. threshold: number;
  52435. /** @hidden */
  52436. _exposure: number;
  52437. /**
  52438. * Post process which has the input texture to be used when performing highlight extraction
  52439. * @hidden
  52440. */
  52441. _inputPostProcess: Nullable<PostProcess>;
  52442. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52443. }
  52444. }
  52445. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  52446. /** @hidden */
  52447. export var bloomMergePixelShader: {
  52448. name: string;
  52449. shader: string;
  52450. };
  52451. }
  52452. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  52453. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52454. import { Nullable } from "babylonjs/types";
  52455. import { Engine } from "babylonjs/Engines/engine";
  52456. import { Camera } from "babylonjs/Cameras/camera";
  52457. import "babylonjs/Shaders/bloomMerge.fragment";
  52458. /**
  52459. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52460. */
  52461. export class BloomMergePostProcess extends PostProcess {
  52462. /** Weight of the bloom to be added to the original input. */
  52463. weight: number;
  52464. /**
  52465. * Creates a new instance of @see BloomMergePostProcess
  52466. * @param name The name of the effect.
  52467. * @param originalFromInput Post process which's input will be used for the merge.
  52468. * @param blurred Blurred highlights post process which's output will be used.
  52469. * @param weight Weight of the bloom to be added to the original input.
  52470. * @param options The required width/height ratio to downsize to before computing the render pass.
  52471. * @param camera The camera to apply the render pass to.
  52472. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52473. * @param engine The engine which the post process will be applied. (default: current engine)
  52474. * @param reusable If the post process can be reused on the same frame. (default: false)
  52475. * @param textureType Type of textures used when performing the post process. (default: 0)
  52476. * @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)
  52477. */
  52478. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52479. /** Weight of the bloom to be added to the original input. */
  52480. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52481. }
  52482. }
  52483. declare module "babylonjs/PostProcesses/bloomEffect" {
  52484. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52485. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52486. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  52487. import { Camera } from "babylonjs/Cameras/camera";
  52488. import { Scene } from "babylonjs/scene";
  52489. /**
  52490. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52491. */
  52492. export class BloomEffect extends PostProcessRenderEffect {
  52493. private bloomScale;
  52494. /**
  52495. * @hidden Internal
  52496. */
  52497. _effects: Array<PostProcess>;
  52498. /**
  52499. * @hidden Internal
  52500. */
  52501. _downscale: ExtractHighlightsPostProcess;
  52502. private _blurX;
  52503. private _blurY;
  52504. private _merge;
  52505. /**
  52506. * The luminance threshold to find bright areas of the image to bloom.
  52507. */
  52508. threshold: number;
  52509. /**
  52510. * The strength of the bloom.
  52511. */
  52512. weight: number;
  52513. /**
  52514. * Specifies the size of the bloom blur kernel, relative to the final output size
  52515. */
  52516. kernel: number;
  52517. /**
  52518. * Creates a new instance of @see BloomEffect
  52519. * @param scene The scene the effect belongs to.
  52520. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52521. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52522. * @param bloomWeight The the strength of bloom.
  52523. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52524. * @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)
  52525. */
  52526. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52527. /**
  52528. * Disposes each of the internal effects for a given camera.
  52529. * @param camera The camera to dispose the effect on.
  52530. */
  52531. disposeEffects(camera: Camera): void;
  52532. /**
  52533. * @hidden Internal
  52534. */
  52535. _updateEffects(): void;
  52536. /**
  52537. * Internal
  52538. * @returns if all the contained post processes are ready.
  52539. * @hidden
  52540. */
  52541. _isReady(): boolean;
  52542. }
  52543. }
  52544. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  52545. /** @hidden */
  52546. export var chromaticAberrationPixelShader: {
  52547. name: string;
  52548. shader: string;
  52549. };
  52550. }
  52551. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  52552. import { Vector2 } from "babylonjs/Maths/math";
  52553. import { Nullable } from "babylonjs/types";
  52554. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52555. import { Camera } from "babylonjs/Cameras/camera";
  52556. import { Engine } from "babylonjs/Engines/engine";
  52557. import "babylonjs/Shaders/chromaticAberration.fragment";
  52558. /**
  52559. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52560. */
  52561. export class ChromaticAberrationPostProcess extends PostProcess {
  52562. /**
  52563. * The amount of seperation of rgb channels (default: 30)
  52564. */
  52565. aberrationAmount: number;
  52566. /**
  52567. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52568. */
  52569. radialIntensity: number;
  52570. /**
  52571. * 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))
  52572. */
  52573. direction: Vector2;
  52574. /**
  52575. * 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))
  52576. */
  52577. centerPosition: Vector2;
  52578. /**
  52579. * Creates a new instance ChromaticAberrationPostProcess
  52580. * @param name The name of the effect.
  52581. * @param screenWidth The width of the screen to apply the effect on.
  52582. * @param screenHeight The height of the screen to apply the effect on.
  52583. * @param options The required width/height ratio to downsize to before computing the render pass.
  52584. * @param camera The camera to apply the render pass to.
  52585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52586. * @param engine The engine which the post process will be applied. (default: current engine)
  52587. * @param reusable If the post process can be reused on the same frame. (default: false)
  52588. * @param textureType Type of textures used when performing the post process. (default: 0)
  52589. * @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)
  52590. */
  52591. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52592. }
  52593. }
  52594. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  52595. /** @hidden */
  52596. export var circleOfConfusionPixelShader: {
  52597. name: string;
  52598. shader: string;
  52599. };
  52600. }
  52601. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  52602. import { Nullable } from "babylonjs/types";
  52603. import { Engine } from "babylonjs/Engines/engine";
  52604. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52605. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52606. import { Camera } from "babylonjs/Cameras/camera";
  52607. import "babylonjs/Shaders/circleOfConfusion.fragment";
  52608. /**
  52609. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52610. */
  52611. export class CircleOfConfusionPostProcess extends PostProcess {
  52612. /**
  52613. * 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.
  52614. */
  52615. lensSize: number;
  52616. /**
  52617. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52618. */
  52619. fStop: number;
  52620. /**
  52621. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52622. */
  52623. focusDistance: number;
  52624. /**
  52625. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52626. */
  52627. focalLength: number;
  52628. private _depthTexture;
  52629. /**
  52630. * Creates a new instance CircleOfConfusionPostProcess
  52631. * @param name The name of the effect.
  52632. * @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.
  52633. * @param options The required width/height ratio to downsize to before computing the render pass.
  52634. * @param camera The camera to apply the render pass to.
  52635. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52636. * @param engine The engine which the post process will be applied. (default: current engine)
  52637. * @param reusable If the post process can be reused on the same frame. (default: false)
  52638. * @param textureType Type of textures used when performing the post process. (default: 0)
  52639. * @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)
  52640. */
  52641. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52642. /**
  52643. * 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.
  52644. */
  52645. depthTexture: RenderTargetTexture;
  52646. }
  52647. }
  52648. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  52649. /** @hidden */
  52650. export var colorCorrectionPixelShader: {
  52651. name: string;
  52652. shader: string;
  52653. };
  52654. }
  52655. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  52656. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52657. import { Engine } from "babylonjs/Engines/engine";
  52658. import { Camera } from "babylonjs/Cameras/camera";
  52659. import "babylonjs/Shaders/colorCorrection.fragment";
  52660. /**
  52661. *
  52662. * This post-process allows the modification of rendered colors by using
  52663. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52664. *
  52665. * The object needs to be provided an url to a texture containing the color
  52666. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52667. * Use an image editing software to tweak the LUT to match your needs.
  52668. *
  52669. * For an example of a color LUT, see here:
  52670. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52671. * For explanations on color grading, see here:
  52672. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52673. *
  52674. */
  52675. export class ColorCorrectionPostProcess extends PostProcess {
  52676. private _colorTableTexture;
  52677. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52678. }
  52679. }
  52680. declare module "babylonjs/Shaders/convolution.fragment" {
  52681. /** @hidden */
  52682. export var convolutionPixelShader: {
  52683. name: string;
  52684. shader: string;
  52685. };
  52686. }
  52687. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  52688. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52689. import { Nullable } from "babylonjs/types";
  52690. import { Camera } from "babylonjs/Cameras/camera";
  52691. import { Engine } from "babylonjs/Engines/engine";
  52692. import "babylonjs/Shaders/convolution.fragment";
  52693. /**
  52694. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52695. * input texture to perform effects such as edge detection or sharpening
  52696. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52697. */
  52698. export class ConvolutionPostProcess extends PostProcess {
  52699. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52700. kernel: number[];
  52701. /**
  52702. * Creates a new instance ConvolutionPostProcess
  52703. * @param name The name of the effect.
  52704. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52705. * @param options The required width/height ratio to downsize to before computing the render pass.
  52706. * @param camera The camera to apply the render pass to.
  52707. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52708. * @param engine The engine which the post process will be applied. (default: current engine)
  52709. * @param reusable If the post process can be reused on the same frame. (default: false)
  52710. * @param textureType Type of textures used when performing the post process. (default: 0)
  52711. */
  52712. constructor(name: string,
  52713. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52714. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52715. /**
  52716. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52717. */
  52718. static EdgeDetect0Kernel: number[];
  52719. /**
  52720. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52721. */
  52722. static EdgeDetect1Kernel: number[];
  52723. /**
  52724. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52725. */
  52726. static EdgeDetect2Kernel: number[];
  52727. /**
  52728. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52729. */
  52730. static SharpenKernel: number[];
  52731. /**
  52732. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52733. */
  52734. static EmbossKernel: number[];
  52735. /**
  52736. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52737. */
  52738. static GaussianKernel: number[];
  52739. }
  52740. }
  52741. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  52742. import { Nullable } from "babylonjs/types";
  52743. import { Vector2 } from "babylonjs/Maths/math";
  52744. import { Camera } from "babylonjs/Cameras/camera";
  52745. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52746. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  52747. import { Engine } from "babylonjs/Engines/engine";
  52748. import { Scene } from "babylonjs/scene";
  52749. /**
  52750. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52751. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52752. * based on samples that have a large difference in distance than the center pixel.
  52753. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  52754. */
  52755. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  52756. direction: Vector2;
  52757. /**
  52758. * Creates a new instance CircleOfConfusionPostProcess
  52759. * @param name The name of the effect.
  52760. * @param scene The scene the effect belongs to.
  52761. * @param direction The direction the blur should be applied.
  52762. * @param kernel The size of the kernel used to blur.
  52763. * @param options The required width/height ratio to downsize to before computing the render pass.
  52764. * @param camera The camera to apply the render pass to.
  52765. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  52766. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  52767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52768. * @param engine The engine which the post process will be applied. (default: current engine)
  52769. * @param reusable If the post process can be reused on the same frame. (default: false)
  52770. * @param textureType Type of textures used when performing the post process. (default: 0)
  52771. * @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)
  52772. */
  52773. 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);
  52774. }
  52775. }
  52776. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  52777. /** @hidden */
  52778. export var depthOfFieldMergePixelShader: {
  52779. name: string;
  52780. shader: string;
  52781. };
  52782. }
  52783. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  52784. import { Nullable } from "babylonjs/types";
  52785. import { Camera } from "babylonjs/Cameras/camera";
  52786. import { Effect } from "babylonjs/Materials/effect";
  52787. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52788. import { Engine } from "babylonjs/Engines/engine";
  52789. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  52790. /**
  52791. * Options to be set when merging outputs from the default pipeline.
  52792. */
  52793. export class DepthOfFieldMergePostProcessOptions {
  52794. /**
  52795. * The original image to merge on top of
  52796. */
  52797. originalFromInput: PostProcess;
  52798. /**
  52799. * Parameters to perform the merge of the depth of field effect
  52800. */
  52801. depthOfField?: {
  52802. circleOfConfusion: PostProcess;
  52803. blurSteps: Array<PostProcess>;
  52804. };
  52805. /**
  52806. * Parameters to perform the merge of bloom effect
  52807. */
  52808. bloom?: {
  52809. blurred: PostProcess;
  52810. weight: number;
  52811. };
  52812. }
  52813. /**
  52814. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52815. */
  52816. export class DepthOfFieldMergePostProcess extends PostProcess {
  52817. private blurSteps;
  52818. /**
  52819. * Creates a new instance of DepthOfFieldMergePostProcess
  52820. * @param name The name of the effect.
  52821. * @param originalFromInput Post process which's input will be used for the merge.
  52822. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52823. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52824. * @param options The required width/height ratio to downsize to before computing the render pass.
  52825. * @param camera The camera to apply the render pass to.
  52826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52827. * @param engine The engine which the post process will be applied. (default: current engine)
  52828. * @param reusable If the post process can be reused on the same frame. (default: false)
  52829. * @param textureType Type of textures used when performing the post process. (default: 0)
  52830. * @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)
  52831. */
  52832. 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);
  52833. /**
  52834. * Updates the effect with the current post process compile time values and recompiles the shader.
  52835. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52836. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52837. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52838. * @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
  52839. * @param onCompiled Called when the shader has been compiled.
  52840. * @param onError Called if there is an error when compiling a shader.
  52841. */
  52842. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52843. }
  52844. }
  52845. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  52846. import { Nullable } from "babylonjs/types";
  52847. import { Camera } from "babylonjs/Cameras/camera";
  52848. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52849. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52850. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52851. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  52852. import { Scene } from "babylonjs/scene";
  52853. /**
  52854. * Specifies the level of max blur that should be applied when using the depth of field effect
  52855. */
  52856. export enum DepthOfFieldEffectBlurLevel {
  52857. /**
  52858. * Subtle blur
  52859. */
  52860. Low = 0,
  52861. /**
  52862. * Medium blur
  52863. */
  52864. Medium = 1,
  52865. /**
  52866. * Large blur
  52867. */
  52868. High = 2
  52869. }
  52870. /**
  52871. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52872. */
  52873. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52874. private _circleOfConfusion;
  52875. /**
  52876. * @hidden Internal, blurs from high to low
  52877. */
  52878. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52879. private _depthOfFieldBlurY;
  52880. private _dofMerge;
  52881. /**
  52882. * @hidden Internal post processes in depth of field effect
  52883. */
  52884. _effects: Array<PostProcess>;
  52885. /**
  52886. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52887. */
  52888. focalLength: number;
  52889. /**
  52890. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52891. */
  52892. fStop: number;
  52893. /**
  52894. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52895. */
  52896. focusDistance: number;
  52897. /**
  52898. * 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.
  52899. */
  52900. lensSize: number;
  52901. /**
  52902. * Creates a new instance DepthOfFieldEffect
  52903. * @param scene The scene the effect belongs to.
  52904. * @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.
  52905. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52906. * @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)
  52907. */
  52908. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52909. /**
  52910. * 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.
  52911. */
  52912. depthTexture: RenderTargetTexture;
  52913. /**
  52914. * Disposes each of the internal effects for a given camera.
  52915. * @param camera The camera to dispose the effect on.
  52916. */
  52917. disposeEffects(camera: Camera): void;
  52918. /**
  52919. * @hidden Internal
  52920. */
  52921. _updateEffects(): void;
  52922. /**
  52923. * Internal
  52924. * @returns if all the contained post processes are ready.
  52925. * @hidden
  52926. */
  52927. _isReady(): boolean;
  52928. }
  52929. }
  52930. declare module "babylonjs/Shaders/displayPass.fragment" {
  52931. /** @hidden */
  52932. export var displayPassPixelShader: {
  52933. name: string;
  52934. shader: string;
  52935. };
  52936. }
  52937. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  52938. import { Nullable } from "babylonjs/types";
  52939. import { Camera } from "babylonjs/Cameras/camera";
  52940. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52941. import { Engine } from "babylonjs/Engines/engine";
  52942. import "babylonjs/Shaders/displayPass.fragment";
  52943. /**
  52944. * DisplayPassPostProcess which produces an output the same as it's input
  52945. */
  52946. export class DisplayPassPostProcess extends PostProcess {
  52947. /**
  52948. * Creates the DisplayPassPostProcess
  52949. * @param name The name of the effect.
  52950. * @param options The required width/height ratio to downsize to before computing the render pass.
  52951. * @param camera The camera to apply the render pass to.
  52952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52953. * @param engine The engine which the post process will be applied. (default: current engine)
  52954. * @param reusable If the post process can be reused on the same frame. (default: false)
  52955. */
  52956. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52957. }
  52958. }
  52959. declare module "babylonjs/Shaders/filter.fragment" {
  52960. /** @hidden */
  52961. export var filterPixelShader: {
  52962. name: string;
  52963. shader: string;
  52964. };
  52965. }
  52966. declare module "babylonjs/PostProcesses/filterPostProcess" {
  52967. import { Nullable } from "babylonjs/types";
  52968. import { Matrix } from "babylonjs/Maths/math";
  52969. import { Camera } from "babylonjs/Cameras/camera";
  52970. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52971. import { Engine } from "babylonjs/Engines/engine";
  52972. import "babylonjs/Shaders/filter.fragment";
  52973. /**
  52974. * Applies a kernel filter to the image
  52975. */
  52976. export class FilterPostProcess extends PostProcess {
  52977. /** The matrix to be applied to the image */
  52978. kernelMatrix: Matrix;
  52979. /**
  52980. *
  52981. * @param name The name of the effect.
  52982. * @param kernelMatrix The matrix to be applied to the image
  52983. * @param options The required width/height ratio to downsize to before computing the render pass.
  52984. * @param camera The camera to apply the render pass to.
  52985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52986. * @param engine The engine which the post process will be applied. (default: current engine)
  52987. * @param reusable If the post process can be reused on the same frame. (default: false)
  52988. */
  52989. constructor(name: string,
  52990. /** The matrix to be applied to the image */
  52991. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52992. }
  52993. }
  52994. declare module "babylonjs/Shaders/fxaa.fragment" {
  52995. /** @hidden */
  52996. export var fxaaPixelShader: {
  52997. name: string;
  52998. shader: string;
  52999. };
  53000. }
  53001. declare module "babylonjs/Shaders/fxaa.vertex" {
  53002. /** @hidden */
  53003. export var fxaaVertexShader: {
  53004. name: string;
  53005. shader: string;
  53006. };
  53007. }
  53008. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  53009. import { Nullable } from "babylonjs/types";
  53010. import { Camera } from "babylonjs/Cameras/camera";
  53011. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53012. import { Engine } from "babylonjs/Engines/engine";
  53013. import "babylonjs/Shaders/fxaa.fragment";
  53014. import "babylonjs/Shaders/fxaa.vertex";
  53015. /**
  53016. * Fxaa post process
  53017. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53018. */
  53019. export class FxaaPostProcess extends PostProcess {
  53020. /** @hidden */
  53021. texelWidth: number;
  53022. /** @hidden */
  53023. texelHeight: number;
  53024. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53025. private _getDefines;
  53026. }
  53027. }
  53028. declare module "babylonjs/Shaders/grain.fragment" {
  53029. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53030. /** @hidden */
  53031. export var grainPixelShader: {
  53032. name: string;
  53033. shader: string;
  53034. };
  53035. }
  53036. declare module "babylonjs/PostProcesses/grainPostProcess" {
  53037. import { Nullable } from "babylonjs/types";
  53038. import { Camera } from "babylonjs/Cameras/camera";
  53039. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53040. import { Engine } from "babylonjs/Engines/engine";
  53041. import "babylonjs/Shaders/grain.fragment";
  53042. /**
  53043. * The GrainPostProcess adds noise to the image at mid luminance levels
  53044. */
  53045. export class GrainPostProcess extends PostProcess {
  53046. /**
  53047. * The intensity of the grain added (default: 30)
  53048. */
  53049. intensity: number;
  53050. /**
  53051. * If the grain should be randomized on every frame
  53052. */
  53053. animated: boolean;
  53054. /**
  53055. * Creates a new instance of @see GrainPostProcess
  53056. * @param name The name of the effect.
  53057. * @param options The required width/height ratio to downsize to before computing the render pass.
  53058. * @param camera The camera to apply the render pass to.
  53059. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53060. * @param engine The engine which the post process will be applied. (default: current engine)
  53061. * @param reusable If the post process can be reused on the same frame. (default: false)
  53062. * @param textureType Type of textures used when performing the post process. (default: 0)
  53063. * @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)
  53064. */
  53065. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53066. }
  53067. }
  53068. declare module "babylonjs/Shaders/highlights.fragment" {
  53069. /** @hidden */
  53070. export var highlightsPixelShader: {
  53071. name: string;
  53072. shader: string;
  53073. };
  53074. }
  53075. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  53076. import { Nullable } from "babylonjs/types";
  53077. import { Camera } from "babylonjs/Cameras/camera";
  53078. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53079. import { Engine } from "babylonjs/Engines/engine";
  53080. import "babylonjs/Shaders/highlights.fragment";
  53081. /**
  53082. * Extracts highlights from the image
  53083. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53084. */
  53085. export class HighlightsPostProcess extends PostProcess {
  53086. /**
  53087. * Extracts highlights from the image
  53088. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53089. * @param name The name of the effect.
  53090. * @param options The required width/height ratio to downsize to before computing the render pass.
  53091. * @param camera The camera to apply the render pass to.
  53092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53093. * @param engine The engine which the post process will be applied. (default: current engine)
  53094. * @param reusable If the post process can be reused on the same frame. (default: false)
  53095. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53096. */
  53097. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53098. }
  53099. }
  53100. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  53101. /** @hidden */
  53102. export var mrtFragmentDeclaration: {
  53103. name: string;
  53104. shader: string;
  53105. };
  53106. }
  53107. declare module "babylonjs/Shaders/geometry.fragment" {
  53108. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  53109. /** @hidden */
  53110. export var geometryPixelShader: {
  53111. name: string;
  53112. shader: string;
  53113. };
  53114. }
  53115. declare module "babylonjs/Shaders/geometry.vertex" {
  53116. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53117. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53118. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53119. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53120. /** @hidden */
  53121. export var geometryVertexShader: {
  53122. name: string;
  53123. shader: string;
  53124. };
  53125. }
  53126. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  53127. import { Matrix } from "babylonjs/Maths/math";
  53128. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53129. import { Mesh } from "babylonjs/Meshes/mesh";
  53130. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  53131. import { Effect } from "babylonjs/Materials/effect";
  53132. import { Scene } from "babylonjs/scene";
  53133. import "babylonjs/Shaders/geometry.fragment";
  53134. import "babylonjs/Shaders/geometry.vertex";
  53135. /**
  53136. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53137. */
  53138. export class GeometryBufferRenderer {
  53139. /**
  53140. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53141. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53142. */
  53143. static readonly POSITION_TEXTURE_TYPE: number;
  53144. /**
  53145. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53146. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53147. */
  53148. static readonly VELOCITY_TEXTURE_TYPE: number;
  53149. /**
  53150. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53151. * in order to compute objects velocities when enableVelocity is set to "true"
  53152. * @hidden
  53153. */
  53154. _previousTransformationMatrices: {
  53155. [index: number]: Matrix;
  53156. };
  53157. private _scene;
  53158. private _multiRenderTarget;
  53159. private _ratio;
  53160. private _enablePosition;
  53161. private _enableVelocity;
  53162. private _positionIndex;
  53163. private _velocityIndex;
  53164. protected _effect: Effect;
  53165. protected _cachedDefines: string;
  53166. /**
  53167. * Set the render list (meshes to be rendered) used in the G buffer.
  53168. */
  53169. renderList: Mesh[];
  53170. /**
  53171. * Gets wether or not G buffer are supported by the running hardware.
  53172. * This requires draw buffer supports
  53173. */
  53174. readonly isSupported: boolean;
  53175. /**
  53176. * Returns the index of the given texture type in the G-Buffer textures array
  53177. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53178. * @returns the index of the given texture type in the G-Buffer textures array
  53179. */
  53180. getTextureIndex(textureType: number): number;
  53181. /**
  53182. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53183. */
  53184. /**
  53185. * Sets whether or not objects positions are enabled for the G buffer.
  53186. */
  53187. enablePosition: boolean;
  53188. /**
  53189. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53190. */
  53191. /**
  53192. * Sets wether or not objects velocities are enabled for the G buffer.
  53193. */
  53194. enableVelocity: boolean;
  53195. /**
  53196. * Gets the scene associated with the buffer.
  53197. */
  53198. readonly scene: Scene;
  53199. /**
  53200. * Gets the ratio used by the buffer during its creation.
  53201. * How big is the buffer related to the main canvas.
  53202. */
  53203. readonly ratio: number;
  53204. /** @hidden */
  53205. static _SceneComponentInitialization: (scene: Scene) => void;
  53206. /**
  53207. * Creates a new G Buffer for the scene
  53208. * @param scene The scene the buffer belongs to
  53209. * @param ratio How big is the buffer related to the main canvas.
  53210. */
  53211. constructor(scene: Scene, ratio?: number);
  53212. /**
  53213. * Checks wether everything is ready to render a submesh to the G buffer.
  53214. * @param subMesh the submesh to check readiness for
  53215. * @param useInstances is the mesh drawn using instance or not
  53216. * @returns true if ready otherwise false
  53217. */
  53218. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53219. /**
  53220. * Gets the current underlying G Buffer.
  53221. * @returns the buffer
  53222. */
  53223. getGBuffer(): MultiRenderTarget;
  53224. /**
  53225. * Gets the number of samples used to render the buffer (anti aliasing).
  53226. */
  53227. /**
  53228. * Sets the number of samples used to render the buffer (anti aliasing).
  53229. */
  53230. samples: number;
  53231. /**
  53232. * Disposes the renderer and frees up associated resources.
  53233. */
  53234. dispose(): void;
  53235. protected _createRenderTargets(): void;
  53236. }
  53237. }
  53238. declare module "babylonjs/Shaders/motionBlur.fragment" {
  53239. /** @hidden */
  53240. export var motionBlurPixelShader: {
  53241. name: string;
  53242. shader: string;
  53243. };
  53244. }
  53245. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  53246. import { Nullable } from "babylonjs/types";
  53247. import { Camera } from "babylonjs/Cameras/camera";
  53248. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53249. import { Scene } from "babylonjs/scene";
  53250. import "babylonjs/Shaders/motionBlur.fragment";
  53251. import { Engine } from "babylonjs/Engines/engine";
  53252. /**
  53253. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53254. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53255. * As an example, all you have to do is to create the post-process:
  53256. * var mb = new BABYLON.MotionBlurPostProcess(
  53257. * 'mb', // The name of the effect.
  53258. * scene, // The scene containing the objects to blur according to their velocity.
  53259. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53260. * camera // The camera to apply the render pass to.
  53261. * );
  53262. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53263. */
  53264. export class MotionBlurPostProcess extends PostProcess {
  53265. /**
  53266. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53267. */
  53268. motionStrength: number;
  53269. /**
  53270. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53271. */
  53272. /**
  53273. * Sets the number of iterations to be used for motion blur quality
  53274. */
  53275. motionBlurSamples: number;
  53276. private _motionBlurSamples;
  53277. private _geometryBufferRenderer;
  53278. /**
  53279. * Creates a new instance MotionBlurPostProcess
  53280. * @param name The name of the effect.
  53281. * @param scene The scene containing the objects to blur according to their velocity.
  53282. * @param options The required width/height ratio to downsize to before computing the render pass.
  53283. * @param camera The camera to apply the render pass to.
  53284. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53285. * @param engine The engine which the post process will be applied. (default: current engine)
  53286. * @param reusable If the post process can be reused on the same frame. (default: false)
  53287. * @param textureType Type of textures used when performing the post process. (default: 0)
  53288. * @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)
  53289. */
  53290. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53291. /**
  53292. * Disposes the post process.
  53293. * @param camera The camera to dispose the post process on.
  53294. */
  53295. dispose(camera?: Camera): void;
  53296. }
  53297. }
  53298. declare module "babylonjs/Shaders/refraction.fragment" {
  53299. /** @hidden */
  53300. export var refractionPixelShader: {
  53301. name: string;
  53302. shader: string;
  53303. };
  53304. }
  53305. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  53306. import { Color3 } from "babylonjs/Maths/math";
  53307. import { Camera } from "babylonjs/Cameras/camera";
  53308. import { Texture } from "babylonjs/Materials/Textures/texture";
  53309. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53310. import { Engine } from "babylonjs/Engines/engine";
  53311. import "babylonjs/Shaders/refraction.fragment";
  53312. /**
  53313. * Post process which applies a refractin texture
  53314. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53315. */
  53316. export class RefractionPostProcess extends PostProcess {
  53317. /** the base color of the refraction (used to taint the rendering) */
  53318. color: Color3;
  53319. /** simulated refraction depth */
  53320. depth: number;
  53321. /** the coefficient of the base color (0 to remove base color tainting) */
  53322. colorLevel: number;
  53323. private _refTexture;
  53324. private _ownRefractionTexture;
  53325. /**
  53326. * Gets or sets the refraction texture
  53327. * Please note that you are responsible for disposing the texture if you set it manually
  53328. */
  53329. refractionTexture: Texture;
  53330. /**
  53331. * Initializes the RefractionPostProcess
  53332. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53333. * @param name The name of the effect.
  53334. * @param refractionTextureUrl Url of the refraction texture to use
  53335. * @param color the base color of the refraction (used to taint the rendering)
  53336. * @param depth simulated refraction depth
  53337. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53338. * @param camera The camera to apply the render pass to.
  53339. * @param options The required width/height ratio to downsize to before computing the render pass.
  53340. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53341. * @param engine The engine which the post process will be applied. (default: current engine)
  53342. * @param reusable If the post process can be reused on the same frame. (default: false)
  53343. */
  53344. constructor(name: string, refractionTextureUrl: string,
  53345. /** the base color of the refraction (used to taint the rendering) */
  53346. color: Color3,
  53347. /** simulated refraction depth */
  53348. depth: number,
  53349. /** the coefficient of the base color (0 to remove base color tainting) */
  53350. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53351. /**
  53352. * Disposes of the post process
  53353. * @param camera Camera to dispose post process on
  53354. */
  53355. dispose(camera: Camera): void;
  53356. }
  53357. }
  53358. declare module "babylonjs/Shaders/sharpen.fragment" {
  53359. /** @hidden */
  53360. export var sharpenPixelShader: {
  53361. name: string;
  53362. shader: string;
  53363. };
  53364. }
  53365. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  53366. import { Nullable } from "babylonjs/types";
  53367. import { Camera } from "babylonjs/Cameras/camera";
  53368. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53369. import "babylonjs/Shaders/sharpen.fragment";
  53370. import { Engine } from "babylonjs/Engines/engine";
  53371. /**
  53372. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53373. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53374. */
  53375. export class SharpenPostProcess extends PostProcess {
  53376. /**
  53377. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53378. */
  53379. colorAmount: number;
  53380. /**
  53381. * How much sharpness should be applied (default: 0.3)
  53382. */
  53383. edgeAmount: number;
  53384. /**
  53385. * Creates a new instance ConvolutionPostProcess
  53386. * @param name The name of the effect.
  53387. * @param options The required width/height ratio to downsize to before computing the render pass.
  53388. * @param camera The camera to apply the render pass to.
  53389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53390. * @param engine The engine which the post process will be applied. (default: current engine)
  53391. * @param reusable If the post process can be reused on the same frame. (default: false)
  53392. * @param textureType Type of textures used when performing the post process. (default: 0)
  53393. * @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)
  53394. */
  53395. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53396. }
  53397. }
  53398. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  53399. import { Nullable } from "babylonjs/types";
  53400. import { Camera } from "babylonjs/Cameras/camera";
  53401. import { Engine } from "babylonjs/Engines/engine";
  53402. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53403. /**
  53404. * PostProcessRenderPipeline
  53405. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53406. */
  53407. export class PostProcessRenderPipeline {
  53408. private engine;
  53409. private _renderEffects;
  53410. private _renderEffectsForIsolatedPass;
  53411. /**
  53412. * @hidden
  53413. */
  53414. protected _cameras: Camera[];
  53415. /** @hidden */
  53416. _name: string;
  53417. /**
  53418. * Gets pipeline name
  53419. */
  53420. readonly name: string;
  53421. /**
  53422. * Initializes a PostProcessRenderPipeline
  53423. * @param engine engine to add the pipeline to
  53424. * @param name name of the pipeline
  53425. */
  53426. constructor(engine: Engine, name: string);
  53427. /**
  53428. * Gets the class name
  53429. * @returns "PostProcessRenderPipeline"
  53430. */
  53431. getClassName(): string;
  53432. /**
  53433. * If all the render effects in the pipeline are supported
  53434. */
  53435. readonly isSupported: boolean;
  53436. /**
  53437. * Adds an effect to the pipeline
  53438. * @param renderEffect the effect to add
  53439. */
  53440. addEffect(renderEffect: PostProcessRenderEffect): void;
  53441. /** @hidden */
  53442. _rebuild(): void;
  53443. /** @hidden */
  53444. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53445. /** @hidden */
  53446. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53447. /** @hidden */
  53448. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53449. /** @hidden */
  53450. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53451. /** @hidden */
  53452. _attachCameras(cameras: Camera, unique: boolean): void;
  53453. /** @hidden */
  53454. _attachCameras(cameras: Camera[], unique: boolean): void;
  53455. /** @hidden */
  53456. _detachCameras(cameras: Camera): void;
  53457. /** @hidden */
  53458. _detachCameras(cameras: Nullable<Camera[]>): void;
  53459. /** @hidden */
  53460. _update(): void;
  53461. /** @hidden */
  53462. _reset(): void;
  53463. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53464. /**
  53465. * Disposes of the pipeline
  53466. */
  53467. dispose(): void;
  53468. }
  53469. }
  53470. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  53471. import { IAnimatable } from "babylonjs/Misc/tools";
  53472. import { Camera } from "babylonjs/Cameras/camera";
  53473. import { IDisposable } from "babylonjs/scene";
  53474. import { Scene } from "babylonjs/scene";
  53475. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  53476. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53477. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53478. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  53479. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53480. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53481. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  53482. import { Animation } from "babylonjs/Animations/animation";
  53483. /**
  53484. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53485. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53486. */
  53487. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53488. private _scene;
  53489. private _camerasToBeAttached;
  53490. /**
  53491. * ID of the sharpen post process,
  53492. */
  53493. private readonly SharpenPostProcessId;
  53494. /**
  53495. * @ignore
  53496. * ID of the image processing post process;
  53497. */
  53498. readonly ImageProcessingPostProcessId: string;
  53499. /**
  53500. * @ignore
  53501. * ID of the Fast Approximate Anti-Aliasing post process;
  53502. */
  53503. readonly FxaaPostProcessId: string;
  53504. /**
  53505. * ID of the chromatic aberration post process,
  53506. */
  53507. private readonly ChromaticAberrationPostProcessId;
  53508. /**
  53509. * ID of the grain post process
  53510. */
  53511. private readonly GrainPostProcessId;
  53512. /**
  53513. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53514. */
  53515. sharpen: SharpenPostProcess;
  53516. private _sharpenEffect;
  53517. private bloom;
  53518. /**
  53519. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53520. */
  53521. depthOfField: DepthOfFieldEffect;
  53522. /**
  53523. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53524. */
  53525. fxaa: FxaaPostProcess;
  53526. /**
  53527. * Image post processing pass used to perform operations such as tone mapping or color grading.
  53528. */
  53529. imageProcessing: ImageProcessingPostProcess;
  53530. /**
  53531. * Chromatic aberration post process which will shift rgb colors in the image
  53532. */
  53533. chromaticAberration: ChromaticAberrationPostProcess;
  53534. private _chromaticAberrationEffect;
  53535. /**
  53536. * Grain post process which add noise to the image
  53537. */
  53538. grain: GrainPostProcess;
  53539. private _grainEffect;
  53540. /**
  53541. * Glow post process which adds a glow to emissive areas of the image
  53542. */
  53543. private _glowLayer;
  53544. /**
  53545. * Animations which can be used to tweak settings over a period of time
  53546. */
  53547. animations: Animation[];
  53548. private _imageProcessingConfigurationObserver;
  53549. private _sharpenEnabled;
  53550. private _bloomEnabled;
  53551. private _depthOfFieldEnabled;
  53552. private _depthOfFieldBlurLevel;
  53553. private _fxaaEnabled;
  53554. private _imageProcessingEnabled;
  53555. private _defaultPipelineTextureType;
  53556. private _bloomScale;
  53557. private _chromaticAberrationEnabled;
  53558. private _grainEnabled;
  53559. private _buildAllowed;
  53560. /**
  53561. * Gets active scene
  53562. */
  53563. readonly scene: Scene;
  53564. /**
  53565. * Enable or disable the sharpen process from the pipeline
  53566. */
  53567. sharpenEnabled: boolean;
  53568. private _resizeObserver;
  53569. private _hardwareScaleLevel;
  53570. private _bloomKernel;
  53571. /**
  53572. * Specifies the size of the bloom blur kernel, relative to the final output size
  53573. */
  53574. bloomKernel: number;
  53575. /**
  53576. * Specifies the weight of the bloom in the final rendering
  53577. */
  53578. private _bloomWeight;
  53579. /**
  53580. * Specifies the luma threshold for the area that will be blurred by the bloom
  53581. */
  53582. private _bloomThreshold;
  53583. private _hdr;
  53584. /**
  53585. * The strength of the bloom.
  53586. */
  53587. bloomWeight: number;
  53588. /**
  53589. * The strength of the bloom.
  53590. */
  53591. bloomThreshold: number;
  53592. /**
  53593. * The scale of the bloom, lower value will provide better performance.
  53594. */
  53595. bloomScale: number;
  53596. /**
  53597. * Enable or disable the bloom from the pipeline
  53598. */
  53599. bloomEnabled: boolean;
  53600. private _rebuildBloom;
  53601. /**
  53602. * If the depth of field is enabled.
  53603. */
  53604. depthOfFieldEnabled: boolean;
  53605. /**
  53606. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53607. */
  53608. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53609. /**
  53610. * If the anti aliasing is enabled.
  53611. */
  53612. fxaaEnabled: boolean;
  53613. private _samples;
  53614. /**
  53615. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53616. */
  53617. samples: number;
  53618. /**
  53619. * If image processing is enabled.
  53620. */
  53621. imageProcessingEnabled: boolean;
  53622. /**
  53623. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53624. */
  53625. glowLayerEnabled: boolean;
  53626. /**
  53627. * Enable or disable the chromaticAberration process from the pipeline
  53628. */
  53629. chromaticAberrationEnabled: boolean;
  53630. /**
  53631. * Enable or disable the grain process from the pipeline
  53632. */
  53633. grainEnabled: boolean;
  53634. /**
  53635. * @constructor
  53636. * @param name - The rendering pipeline name (default: "")
  53637. * @param hdr - If high dynamic range textures should be used (default: true)
  53638. * @param scene - The scene linked to this pipeline (default: the last created scene)
  53639. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  53640. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  53641. */
  53642. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  53643. /**
  53644. * Get the class name
  53645. * @returns "DefaultRenderingPipeline"
  53646. */
  53647. getClassName(): string;
  53648. /**
  53649. * Force the compilation of the entire pipeline.
  53650. */
  53651. prepare(): void;
  53652. private _hasCleared;
  53653. private _prevPostProcess;
  53654. private _prevPrevPostProcess;
  53655. private _setAutoClearAndTextureSharing;
  53656. private _depthOfFieldSceneObserver;
  53657. private _buildPipeline;
  53658. private _disposePostProcesses;
  53659. /**
  53660. * Adds a camera to the pipeline
  53661. * @param camera the camera to be added
  53662. */
  53663. addCamera(camera: Camera): void;
  53664. /**
  53665. * Removes a camera from the pipeline
  53666. * @param camera the camera to remove
  53667. */
  53668. removeCamera(camera: Camera): void;
  53669. /**
  53670. * Dispose of the pipeline and stop all post processes
  53671. */
  53672. dispose(): void;
  53673. /**
  53674. * Serialize the rendering pipeline (Used when exporting)
  53675. * @returns the serialized object
  53676. */
  53677. serialize(): any;
  53678. /**
  53679. * Parse the serialized pipeline
  53680. * @param source Source pipeline.
  53681. * @param scene The scene to load the pipeline to.
  53682. * @param rootUrl The URL of the serialized pipeline.
  53683. * @returns An instantiated pipeline from the serialized object.
  53684. */
  53685. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  53686. }
  53687. }
  53688. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  53689. /** @hidden */
  53690. export var lensHighlightsPixelShader: {
  53691. name: string;
  53692. shader: string;
  53693. };
  53694. }
  53695. declare module "babylonjs/Shaders/depthOfField.fragment" {
  53696. /** @hidden */
  53697. export var depthOfFieldPixelShader: {
  53698. name: string;
  53699. shader: string;
  53700. };
  53701. }
  53702. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  53703. import { Camera } from "babylonjs/Cameras/camera";
  53704. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53705. import { Scene } from "babylonjs/scene";
  53706. import "babylonjs/Shaders/chromaticAberration.fragment";
  53707. import "babylonjs/Shaders/lensHighlights.fragment";
  53708. import "babylonjs/Shaders/depthOfField.fragment";
  53709. /**
  53710. * BABYLON.JS Chromatic Aberration GLSL Shader
  53711. * Author: Olivier Guyot
  53712. * Separates very slightly R, G and B colors on the edges of the screen
  53713. * Inspired by Francois Tarlier & Martins Upitis
  53714. */
  53715. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  53716. /**
  53717. * @ignore
  53718. * The chromatic aberration PostProcess id in the pipeline
  53719. */
  53720. LensChromaticAberrationEffect: string;
  53721. /**
  53722. * @ignore
  53723. * The highlights enhancing PostProcess id in the pipeline
  53724. */
  53725. HighlightsEnhancingEffect: string;
  53726. /**
  53727. * @ignore
  53728. * The depth-of-field PostProcess id in the pipeline
  53729. */
  53730. LensDepthOfFieldEffect: string;
  53731. private _scene;
  53732. private _depthTexture;
  53733. private _grainTexture;
  53734. private _chromaticAberrationPostProcess;
  53735. private _highlightsPostProcess;
  53736. private _depthOfFieldPostProcess;
  53737. private _edgeBlur;
  53738. private _grainAmount;
  53739. private _chromaticAberration;
  53740. private _distortion;
  53741. private _highlightsGain;
  53742. private _highlightsThreshold;
  53743. private _dofDistance;
  53744. private _dofAperture;
  53745. private _dofDarken;
  53746. private _dofPentagon;
  53747. private _blurNoise;
  53748. /**
  53749. * @constructor
  53750. *
  53751. * Effect parameters are as follow:
  53752. * {
  53753. * chromatic_aberration: number; // from 0 to x (1 for realism)
  53754. * edge_blur: number; // from 0 to x (1 for realism)
  53755. * distortion: number; // from 0 to x (1 for realism)
  53756. * grain_amount: number; // from 0 to 1
  53757. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  53758. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  53759. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  53760. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  53761. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  53762. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  53763. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  53764. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  53765. * }
  53766. * Note: if an effect parameter is unset, effect is disabled
  53767. *
  53768. * @param name The rendering pipeline name
  53769. * @param parameters - An object containing all parameters (see above)
  53770. * @param scene The scene linked to this pipeline
  53771. * @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)
  53772. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53773. */
  53774. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  53775. /**
  53776. * Sets the amount of blur at the edges
  53777. * @param amount blur amount
  53778. */
  53779. setEdgeBlur(amount: number): void;
  53780. /**
  53781. * Sets edge blur to 0
  53782. */
  53783. disableEdgeBlur(): void;
  53784. /**
  53785. * Sets the amout of grain
  53786. * @param amount Amount of grain
  53787. */
  53788. setGrainAmount(amount: number): void;
  53789. /**
  53790. * Set grain amount to 0
  53791. */
  53792. disableGrain(): void;
  53793. /**
  53794. * Sets the chromatic aberration amount
  53795. * @param amount amount of chromatic aberration
  53796. */
  53797. setChromaticAberration(amount: number): void;
  53798. /**
  53799. * Sets chromatic aberration amount to 0
  53800. */
  53801. disableChromaticAberration(): void;
  53802. /**
  53803. * Sets the EdgeDistortion amount
  53804. * @param amount amount of EdgeDistortion
  53805. */
  53806. setEdgeDistortion(amount: number): void;
  53807. /**
  53808. * Sets edge distortion to 0
  53809. */
  53810. disableEdgeDistortion(): void;
  53811. /**
  53812. * Sets the FocusDistance amount
  53813. * @param amount amount of FocusDistance
  53814. */
  53815. setFocusDistance(amount: number): void;
  53816. /**
  53817. * Disables depth of field
  53818. */
  53819. disableDepthOfField(): void;
  53820. /**
  53821. * Sets the Aperture amount
  53822. * @param amount amount of Aperture
  53823. */
  53824. setAperture(amount: number): void;
  53825. /**
  53826. * Sets the DarkenOutOfFocus amount
  53827. * @param amount amount of DarkenOutOfFocus
  53828. */
  53829. setDarkenOutOfFocus(amount: number): void;
  53830. /**
  53831. * Creates a pentagon bokeh effect
  53832. */
  53833. enablePentagonBokeh(): void;
  53834. /**
  53835. * Disables the pentagon bokeh effect
  53836. */
  53837. disablePentagonBokeh(): void;
  53838. /**
  53839. * Enables noise blur
  53840. */
  53841. enableNoiseBlur(): void;
  53842. /**
  53843. * Disables noise blur
  53844. */
  53845. disableNoiseBlur(): void;
  53846. /**
  53847. * Sets the HighlightsGain amount
  53848. * @param amount amount of HighlightsGain
  53849. */
  53850. setHighlightsGain(amount: number): void;
  53851. /**
  53852. * Sets the HighlightsThreshold amount
  53853. * @param amount amount of HighlightsThreshold
  53854. */
  53855. setHighlightsThreshold(amount: number): void;
  53856. /**
  53857. * Disables highlights
  53858. */
  53859. disableHighlights(): void;
  53860. /**
  53861. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53862. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53863. */
  53864. dispose(disableDepthRender?: boolean): void;
  53865. private _createChromaticAberrationPostProcess;
  53866. private _createHighlightsPostProcess;
  53867. private _createDepthOfFieldPostProcess;
  53868. private _createGrainTexture;
  53869. }
  53870. }
  53871. declare module "babylonjs/Shaders/ssao2.fragment" {
  53872. /** @hidden */
  53873. export var ssao2PixelShader: {
  53874. name: string;
  53875. shader: string;
  53876. };
  53877. }
  53878. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  53879. /** @hidden */
  53880. export var ssaoCombinePixelShader: {
  53881. name: string;
  53882. shader: string;
  53883. };
  53884. }
  53885. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  53886. import { Camera } from "babylonjs/Cameras/camera";
  53887. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53888. import { Scene } from "babylonjs/scene";
  53889. import "babylonjs/Shaders/ssao2.fragment";
  53890. import "babylonjs/Shaders/ssaoCombine.fragment";
  53891. /**
  53892. * Render pipeline to produce ssao effect
  53893. */
  53894. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53895. /**
  53896. * @ignore
  53897. * The PassPostProcess id in the pipeline that contains the original scene color
  53898. */
  53899. SSAOOriginalSceneColorEffect: string;
  53900. /**
  53901. * @ignore
  53902. * The SSAO PostProcess id in the pipeline
  53903. */
  53904. SSAORenderEffect: string;
  53905. /**
  53906. * @ignore
  53907. * The horizontal blur PostProcess id in the pipeline
  53908. */
  53909. SSAOBlurHRenderEffect: string;
  53910. /**
  53911. * @ignore
  53912. * The vertical blur PostProcess id in the pipeline
  53913. */
  53914. SSAOBlurVRenderEffect: string;
  53915. /**
  53916. * @ignore
  53917. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53918. */
  53919. SSAOCombineRenderEffect: string;
  53920. /**
  53921. * The output strength of the SSAO post-process. Default value is 1.0.
  53922. */
  53923. totalStrength: number;
  53924. /**
  53925. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53926. */
  53927. maxZ: number;
  53928. /**
  53929. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53930. */
  53931. minZAspect: number;
  53932. private _samples;
  53933. /**
  53934. * Number of samples used for the SSAO calculations. Default value is 8
  53935. */
  53936. samples: number;
  53937. private _textureSamples;
  53938. /**
  53939. * Number of samples to use for antialiasing
  53940. */
  53941. textureSamples: number;
  53942. /**
  53943. * Ratio object used for SSAO ratio and blur ratio
  53944. */
  53945. private _ratio;
  53946. /**
  53947. * Dynamically generated sphere sampler.
  53948. */
  53949. private _sampleSphere;
  53950. /**
  53951. * Blur filter offsets
  53952. */
  53953. private _samplerOffsets;
  53954. private _expensiveBlur;
  53955. /**
  53956. * If bilateral blur should be used
  53957. */
  53958. expensiveBlur: boolean;
  53959. /**
  53960. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53961. */
  53962. radius: number;
  53963. /**
  53964. * The base color of the SSAO post-process
  53965. * The final result is "base + ssao" between [0, 1]
  53966. */
  53967. base: number;
  53968. /**
  53969. * Support test.
  53970. */
  53971. static readonly IsSupported: boolean;
  53972. private _scene;
  53973. private _depthTexture;
  53974. private _normalTexture;
  53975. private _randomTexture;
  53976. private _originalColorPostProcess;
  53977. private _ssaoPostProcess;
  53978. private _blurHPostProcess;
  53979. private _blurVPostProcess;
  53980. private _ssaoCombinePostProcess;
  53981. private _firstUpdate;
  53982. /**
  53983. * Gets active scene
  53984. */
  53985. readonly scene: Scene;
  53986. /**
  53987. * @constructor
  53988. * @param name The rendering pipeline name
  53989. * @param scene The scene linked to this pipeline
  53990. * @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 }
  53991. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53992. */
  53993. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53994. /**
  53995. * Get the class name
  53996. * @returns "SSAO2RenderingPipeline"
  53997. */
  53998. getClassName(): string;
  53999. /**
  54000. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54001. */
  54002. dispose(disableGeometryBufferRenderer?: boolean): void;
  54003. private _createBlurPostProcess;
  54004. /** @hidden */
  54005. _rebuild(): void;
  54006. private _bits;
  54007. private _radicalInverse_VdC;
  54008. private _hammersley;
  54009. private _hemisphereSample_uniform;
  54010. private _generateHemisphere;
  54011. private _createSSAOPostProcess;
  54012. private _createSSAOCombinePostProcess;
  54013. private _createRandomTexture;
  54014. /**
  54015. * Serialize the rendering pipeline (Used when exporting)
  54016. * @returns the serialized object
  54017. */
  54018. serialize(): any;
  54019. /**
  54020. * Parse the serialized pipeline
  54021. * @param source Source pipeline.
  54022. * @param scene The scene to load the pipeline to.
  54023. * @param rootUrl The URL of the serialized pipeline.
  54024. * @returns An instantiated pipeline from the serialized object.
  54025. */
  54026. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54027. }
  54028. }
  54029. declare module "babylonjs/Shaders/ssao.fragment" {
  54030. /** @hidden */
  54031. export var ssaoPixelShader: {
  54032. name: string;
  54033. shader: string;
  54034. };
  54035. }
  54036. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  54037. import { Camera } from "babylonjs/Cameras/camera";
  54038. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54039. import { Scene } from "babylonjs/scene";
  54040. import "babylonjs/Shaders/ssao.fragment";
  54041. import "babylonjs/Shaders/ssaoCombine.fragment";
  54042. /**
  54043. * Render pipeline to produce ssao effect
  54044. */
  54045. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54046. /**
  54047. * @ignore
  54048. * The PassPostProcess id in the pipeline that contains the original scene color
  54049. */
  54050. SSAOOriginalSceneColorEffect: string;
  54051. /**
  54052. * @ignore
  54053. * The SSAO PostProcess id in the pipeline
  54054. */
  54055. SSAORenderEffect: string;
  54056. /**
  54057. * @ignore
  54058. * The horizontal blur PostProcess id in the pipeline
  54059. */
  54060. SSAOBlurHRenderEffect: string;
  54061. /**
  54062. * @ignore
  54063. * The vertical blur PostProcess id in the pipeline
  54064. */
  54065. SSAOBlurVRenderEffect: string;
  54066. /**
  54067. * @ignore
  54068. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54069. */
  54070. SSAOCombineRenderEffect: string;
  54071. /**
  54072. * The output strength of the SSAO post-process. Default value is 1.0.
  54073. */
  54074. totalStrength: number;
  54075. /**
  54076. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54077. */
  54078. radius: number;
  54079. /**
  54080. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54081. * Must not be equal to fallOff and superior to fallOff.
  54082. * Default value is 0.0075
  54083. */
  54084. area: number;
  54085. /**
  54086. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54087. * Must not be equal to area and inferior to area.
  54088. * Default value is 0.000001
  54089. */
  54090. fallOff: number;
  54091. /**
  54092. * The base color of the SSAO post-process
  54093. * The final result is "base + ssao" between [0, 1]
  54094. */
  54095. base: number;
  54096. private _scene;
  54097. private _depthTexture;
  54098. private _randomTexture;
  54099. private _originalColorPostProcess;
  54100. private _ssaoPostProcess;
  54101. private _blurHPostProcess;
  54102. private _blurVPostProcess;
  54103. private _ssaoCombinePostProcess;
  54104. private _firstUpdate;
  54105. /**
  54106. * Gets active scene
  54107. */
  54108. readonly scene: Scene;
  54109. /**
  54110. * @constructor
  54111. * @param name - The rendering pipeline name
  54112. * @param scene - The scene linked to this pipeline
  54113. * @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 }
  54114. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54115. */
  54116. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54117. /**
  54118. * Get the class name
  54119. * @returns "SSAORenderingPipeline"
  54120. */
  54121. getClassName(): string;
  54122. /**
  54123. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54124. */
  54125. dispose(disableDepthRender?: boolean): void;
  54126. private _createBlurPostProcess;
  54127. /** @hidden */
  54128. _rebuild(): void;
  54129. private _createSSAOPostProcess;
  54130. private _createSSAOCombinePostProcess;
  54131. private _createRandomTexture;
  54132. }
  54133. }
  54134. declare module "babylonjs/Shaders/standard.fragment" {
  54135. /** @hidden */
  54136. export var standardPixelShader: {
  54137. name: string;
  54138. shader: string;
  54139. };
  54140. }
  54141. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  54142. import { Nullable } from "babylonjs/types";
  54143. import { IAnimatable } from "babylonjs/Misc/tools";
  54144. import { Camera } from "babylonjs/Cameras/camera";
  54145. import { Texture } from "babylonjs/Materials/Textures/texture";
  54146. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54147. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54148. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54149. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54150. import { IDisposable } from "babylonjs/scene";
  54151. import { SpotLight } from "babylonjs/Lights/spotLight";
  54152. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  54153. import { Scene } from "babylonjs/scene";
  54154. import { Animation } from "babylonjs/Animations/animation";
  54155. import "babylonjs/Shaders/standard.fragment";
  54156. /**
  54157. * Standard rendering pipeline
  54158. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54159. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54160. */
  54161. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54162. /**
  54163. * Public members
  54164. */
  54165. /**
  54166. * Post-process which contains the original scene color before the pipeline applies all the effects
  54167. */
  54168. originalPostProcess: Nullable<PostProcess>;
  54169. /**
  54170. * Post-process used to down scale an image x4
  54171. */
  54172. downSampleX4PostProcess: Nullable<PostProcess>;
  54173. /**
  54174. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54175. */
  54176. brightPassPostProcess: Nullable<PostProcess>;
  54177. /**
  54178. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54179. */
  54180. blurHPostProcesses: PostProcess[];
  54181. /**
  54182. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54183. */
  54184. blurVPostProcesses: PostProcess[];
  54185. /**
  54186. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54187. */
  54188. textureAdderPostProcess: Nullable<PostProcess>;
  54189. /**
  54190. * Post-process used to create volumetric lighting effect
  54191. */
  54192. volumetricLightPostProcess: Nullable<PostProcess>;
  54193. /**
  54194. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54195. */
  54196. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54197. /**
  54198. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54199. */
  54200. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54201. /**
  54202. * Post-process used to merge the volumetric light effect and the real scene color
  54203. */
  54204. volumetricLightMergePostProces: Nullable<PostProcess>;
  54205. /**
  54206. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54207. */
  54208. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54209. /**
  54210. * Base post-process used to calculate the average luminance of the final image for HDR
  54211. */
  54212. luminancePostProcess: Nullable<PostProcess>;
  54213. /**
  54214. * Post-processes used to create down sample post-processes in order to get
  54215. * the average luminance of the final image for HDR
  54216. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54217. */
  54218. luminanceDownSamplePostProcesses: PostProcess[];
  54219. /**
  54220. * Post-process used to create a HDR effect (light adaptation)
  54221. */
  54222. hdrPostProcess: Nullable<PostProcess>;
  54223. /**
  54224. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54225. */
  54226. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54227. /**
  54228. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54229. */
  54230. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54231. /**
  54232. * Post-process used to merge the final HDR post-process and the real scene color
  54233. */
  54234. hdrFinalPostProcess: Nullable<PostProcess>;
  54235. /**
  54236. * Post-process used to create a lens flare effect
  54237. */
  54238. lensFlarePostProcess: Nullable<PostProcess>;
  54239. /**
  54240. * Post-process that merges the result of the lens flare post-process and the real scene color
  54241. */
  54242. lensFlareComposePostProcess: Nullable<PostProcess>;
  54243. /**
  54244. * Post-process used to create a motion blur effect
  54245. */
  54246. motionBlurPostProcess: Nullable<PostProcess>;
  54247. /**
  54248. * Post-process used to create a depth of field effect
  54249. */
  54250. depthOfFieldPostProcess: Nullable<PostProcess>;
  54251. /**
  54252. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54253. */
  54254. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54255. /**
  54256. * Represents the brightness threshold in order to configure the illuminated surfaces
  54257. */
  54258. brightThreshold: number;
  54259. /**
  54260. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54261. */
  54262. blurWidth: number;
  54263. /**
  54264. * Sets if the blur for highlighted surfaces must be only horizontal
  54265. */
  54266. horizontalBlur: boolean;
  54267. /**
  54268. * Sets the overall exposure used by the pipeline
  54269. */
  54270. exposure: number;
  54271. /**
  54272. * Texture used typically to simulate "dirty" on camera lens
  54273. */
  54274. lensTexture: Nullable<Texture>;
  54275. /**
  54276. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54277. */
  54278. volumetricLightCoefficient: number;
  54279. /**
  54280. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54281. */
  54282. volumetricLightPower: number;
  54283. /**
  54284. * Used the set the blur intensity to smooth the volumetric lights
  54285. */
  54286. volumetricLightBlurScale: number;
  54287. /**
  54288. * Light (spot or directional) used to generate the volumetric lights rays
  54289. * The source light must have a shadow generate so the pipeline can get its
  54290. * depth map
  54291. */
  54292. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54293. /**
  54294. * For eye adaptation, represents the minimum luminance the eye can see
  54295. */
  54296. hdrMinimumLuminance: number;
  54297. /**
  54298. * For eye adaptation, represents the decrease luminance speed
  54299. */
  54300. hdrDecreaseRate: number;
  54301. /**
  54302. * For eye adaptation, represents the increase luminance speed
  54303. */
  54304. hdrIncreaseRate: number;
  54305. /**
  54306. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54307. */
  54308. lensColorTexture: Nullable<Texture>;
  54309. /**
  54310. * The overall strengh for the lens flare effect
  54311. */
  54312. lensFlareStrength: number;
  54313. /**
  54314. * Dispersion coefficient for lens flare ghosts
  54315. */
  54316. lensFlareGhostDispersal: number;
  54317. /**
  54318. * Main lens flare halo width
  54319. */
  54320. lensFlareHaloWidth: number;
  54321. /**
  54322. * Based on the lens distortion effect, defines how much the lens flare result
  54323. * is distorted
  54324. */
  54325. lensFlareDistortionStrength: number;
  54326. /**
  54327. * Lens star texture must be used to simulate rays on the flares and is available
  54328. * in the documentation
  54329. */
  54330. lensStarTexture: Nullable<Texture>;
  54331. /**
  54332. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54333. * flare effect by taking account of the dirt texture
  54334. */
  54335. lensFlareDirtTexture: Nullable<Texture>;
  54336. /**
  54337. * Represents the focal length for the depth of field effect
  54338. */
  54339. depthOfFieldDistance: number;
  54340. /**
  54341. * Represents the blur intensity for the blurred part of the depth of field effect
  54342. */
  54343. depthOfFieldBlurWidth: number;
  54344. /**
  54345. * For motion blur, defines how much the image is blurred by the movement
  54346. */
  54347. motionStrength: number;
  54348. /**
  54349. * List of animations for the pipeline (IAnimatable implementation)
  54350. */
  54351. animations: Animation[];
  54352. /**
  54353. * Private members
  54354. */
  54355. private _scene;
  54356. private _currentDepthOfFieldSource;
  54357. private _basePostProcess;
  54358. private _hdrCurrentLuminance;
  54359. private _floatTextureType;
  54360. private _ratio;
  54361. private _bloomEnabled;
  54362. private _depthOfFieldEnabled;
  54363. private _vlsEnabled;
  54364. private _lensFlareEnabled;
  54365. private _hdrEnabled;
  54366. private _motionBlurEnabled;
  54367. private _fxaaEnabled;
  54368. private _motionBlurSamples;
  54369. private _volumetricLightStepsCount;
  54370. private _samples;
  54371. /**
  54372. * @ignore
  54373. * Specifies if the bloom pipeline is enabled
  54374. */
  54375. BloomEnabled: boolean;
  54376. /**
  54377. * @ignore
  54378. * Specifies if the depth of field pipeline is enabed
  54379. */
  54380. DepthOfFieldEnabled: boolean;
  54381. /**
  54382. * @ignore
  54383. * Specifies if the lens flare pipeline is enabed
  54384. */
  54385. LensFlareEnabled: boolean;
  54386. /**
  54387. * @ignore
  54388. * Specifies if the HDR pipeline is enabled
  54389. */
  54390. HDREnabled: boolean;
  54391. /**
  54392. * @ignore
  54393. * Specifies if the volumetric lights scattering effect is enabled
  54394. */
  54395. VLSEnabled: boolean;
  54396. /**
  54397. * @ignore
  54398. * Specifies if the motion blur effect is enabled
  54399. */
  54400. MotionBlurEnabled: boolean;
  54401. /**
  54402. * Specifies if anti-aliasing is enabled
  54403. */
  54404. fxaaEnabled: boolean;
  54405. /**
  54406. * Specifies the number of steps used to calculate the volumetric lights
  54407. * Typically in interval [50, 200]
  54408. */
  54409. volumetricLightStepsCount: number;
  54410. /**
  54411. * Specifies the number of samples used for the motion blur effect
  54412. * Typically in interval [16, 64]
  54413. */
  54414. motionBlurSamples: number;
  54415. /**
  54416. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54417. */
  54418. samples: number;
  54419. /**
  54420. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54421. * @constructor
  54422. * @param name The rendering pipeline name
  54423. * @param scene The scene linked to this pipeline
  54424. * @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)
  54425. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54426. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54427. */
  54428. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54429. private _buildPipeline;
  54430. private _createDownSampleX4PostProcess;
  54431. private _createBrightPassPostProcess;
  54432. private _createBlurPostProcesses;
  54433. private _createTextureAdderPostProcess;
  54434. private _createVolumetricLightPostProcess;
  54435. private _createLuminancePostProcesses;
  54436. private _createHdrPostProcess;
  54437. private _createLensFlarePostProcess;
  54438. private _createDepthOfFieldPostProcess;
  54439. private _createMotionBlurPostProcess;
  54440. private _getDepthTexture;
  54441. private _disposePostProcesses;
  54442. /**
  54443. * Dispose of the pipeline and stop all post processes
  54444. */
  54445. dispose(): void;
  54446. /**
  54447. * Serialize the rendering pipeline (Used when exporting)
  54448. * @returns the serialized object
  54449. */
  54450. serialize(): any;
  54451. /**
  54452. * Parse the serialized pipeline
  54453. * @param source Source pipeline.
  54454. * @param scene The scene to load the pipeline to.
  54455. * @param rootUrl The URL of the serialized pipeline.
  54456. * @returns An instantiated pipeline from the serialized object.
  54457. */
  54458. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54459. /**
  54460. * Luminance steps
  54461. */
  54462. static LuminanceSteps: number;
  54463. }
  54464. }
  54465. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  54466. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  54467. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  54468. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  54469. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  54470. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  54471. }
  54472. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  54473. import { Camera } from "babylonjs/Cameras/camera";
  54474. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54475. /**
  54476. * PostProcessRenderPipelineManager class
  54477. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54478. */
  54479. export class PostProcessRenderPipelineManager {
  54480. private _renderPipelines;
  54481. /**
  54482. * Initializes a PostProcessRenderPipelineManager
  54483. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54484. */
  54485. constructor();
  54486. /**
  54487. * Gets the list of supported render pipelines
  54488. */
  54489. readonly supportedPipelines: PostProcessRenderPipeline[];
  54490. /**
  54491. * Adds a pipeline to the manager
  54492. * @param renderPipeline The pipeline to add
  54493. */
  54494. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  54495. /**
  54496. * Attaches a camera to the pipeline
  54497. * @param renderPipelineName The name of the pipeline to attach to
  54498. * @param cameras the camera to attach
  54499. * @param unique if the camera can be attached multiple times to the pipeline
  54500. */
  54501. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  54502. /**
  54503. * Detaches a camera from the pipeline
  54504. * @param renderPipelineName The name of the pipeline to detach from
  54505. * @param cameras the camera to detach
  54506. */
  54507. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  54508. /**
  54509. * Enables an effect by name on a pipeline
  54510. * @param renderPipelineName the name of the pipeline to enable the effect in
  54511. * @param renderEffectName the name of the effect to enable
  54512. * @param cameras the cameras that the effect should be enabled on
  54513. */
  54514. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54515. /**
  54516. * Disables an effect by name on a pipeline
  54517. * @param renderPipelineName the name of the pipeline to disable the effect in
  54518. * @param renderEffectName the name of the effect to disable
  54519. * @param cameras the cameras that the effect should be disabled on
  54520. */
  54521. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54522. /**
  54523. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  54524. */
  54525. update(): void;
  54526. /** @hidden */
  54527. _rebuild(): void;
  54528. /**
  54529. * Disposes of the manager and pipelines
  54530. */
  54531. dispose(): void;
  54532. }
  54533. }
  54534. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  54535. import { ISceneComponent } from "babylonjs/sceneComponent";
  54536. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54537. import { Scene } from "babylonjs/scene";
  54538. module "babylonjs/scene" {
  54539. interface Scene {
  54540. /** @hidden (Backing field) */
  54541. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54542. /**
  54543. * Gets the postprocess render pipeline manager
  54544. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54545. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54546. */
  54547. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54548. }
  54549. }
  54550. /**
  54551. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54552. */
  54553. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54554. /**
  54555. * The component name helpfull to identify the component in the list of scene components.
  54556. */
  54557. readonly name: string;
  54558. /**
  54559. * The scene the component belongs to.
  54560. */
  54561. scene: Scene;
  54562. /**
  54563. * Creates a new instance of the component for the given scene
  54564. * @param scene Defines the scene to register the component in
  54565. */
  54566. constructor(scene: Scene);
  54567. /**
  54568. * Registers the component in a given scene
  54569. */
  54570. register(): void;
  54571. /**
  54572. * Rebuilds the elements related to this component in case of
  54573. * context lost for instance.
  54574. */
  54575. rebuild(): void;
  54576. /**
  54577. * Disposes the component and the associated ressources
  54578. */
  54579. dispose(): void;
  54580. private _gatherRenderTargets;
  54581. }
  54582. }
  54583. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  54584. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  54585. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54586. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54587. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54588. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54589. }
  54590. declare module "babylonjs/Shaders/tonemap.fragment" {
  54591. /** @hidden */
  54592. export var tonemapPixelShader: {
  54593. name: string;
  54594. shader: string;
  54595. };
  54596. }
  54597. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  54598. import { Camera } from "babylonjs/Cameras/camera";
  54599. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54600. import "babylonjs/Shaders/tonemap.fragment";
  54601. import { Engine } from "babylonjs/Engines/engine";
  54602. /** Defines operator used for tonemapping */
  54603. export enum TonemappingOperator {
  54604. /** Hable */
  54605. Hable = 0,
  54606. /** Reinhard */
  54607. Reinhard = 1,
  54608. /** HejiDawson */
  54609. HejiDawson = 2,
  54610. /** Photographic */
  54611. Photographic = 3
  54612. }
  54613. /**
  54614. * Defines a post process to apply tone mapping
  54615. */
  54616. export class TonemapPostProcess extends PostProcess {
  54617. private _operator;
  54618. /** Defines the required exposure adjustement */
  54619. exposureAdjustment: number;
  54620. /**
  54621. * Creates a new TonemapPostProcess
  54622. * @param name defines the name of the postprocess
  54623. * @param _operator defines the operator to use
  54624. * @param exposureAdjustment defines the required exposure adjustement
  54625. * @param camera defines the camera to use (can be null)
  54626. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54627. * @param engine defines the hosting engine (can be ignore if camera is set)
  54628. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54629. */
  54630. constructor(name: string, _operator: TonemappingOperator,
  54631. /** Defines the required exposure adjustement */
  54632. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54633. }
  54634. }
  54635. declare module "babylonjs/Shaders/depth.vertex" {
  54636. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54637. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54638. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54639. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54640. /** @hidden */
  54641. export var depthVertexShader: {
  54642. name: string;
  54643. shader: string;
  54644. };
  54645. }
  54646. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  54647. /** @hidden */
  54648. export var volumetricLightScatteringPixelShader: {
  54649. name: string;
  54650. shader: string;
  54651. };
  54652. }
  54653. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  54654. /** @hidden */
  54655. export var volumetricLightScatteringPassPixelShader: {
  54656. name: string;
  54657. shader: string;
  54658. };
  54659. }
  54660. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  54661. import { Vector3 } from "babylonjs/Maths/math";
  54662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54663. import { Mesh } from "babylonjs/Meshes/mesh";
  54664. import { Camera } from "babylonjs/Cameras/camera";
  54665. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54666. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54667. import { Scene } from "babylonjs/scene";
  54668. import "babylonjs/Meshes/Builders/planeBuilder";
  54669. import "babylonjs/Shaders/depth.vertex";
  54670. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  54671. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  54672. import { Engine } from "babylonjs/Engines/engine";
  54673. /**
  54674. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54675. */
  54676. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54677. private _volumetricLightScatteringPass;
  54678. private _volumetricLightScatteringRTT;
  54679. private _viewPort;
  54680. private _screenCoordinates;
  54681. private _cachedDefines;
  54682. /**
  54683. * If not undefined, the mesh position is computed from the attached node position
  54684. */
  54685. attachedNode: {
  54686. position: Vector3;
  54687. };
  54688. /**
  54689. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54690. */
  54691. customMeshPosition: Vector3;
  54692. /**
  54693. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54694. */
  54695. useCustomMeshPosition: boolean;
  54696. /**
  54697. * If the post-process should inverse the light scattering direction
  54698. */
  54699. invert: boolean;
  54700. /**
  54701. * The internal mesh used by the post-process
  54702. */
  54703. mesh: Mesh;
  54704. /**
  54705. * @hidden
  54706. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54707. */
  54708. useDiffuseColor: boolean;
  54709. /**
  54710. * Array containing the excluded meshes not rendered in the internal pass
  54711. */
  54712. excludedMeshes: AbstractMesh[];
  54713. /**
  54714. * Controls the overall intensity of the post-process
  54715. */
  54716. exposure: number;
  54717. /**
  54718. * Dissipates each sample's contribution in range [0, 1]
  54719. */
  54720. decay: number;
  54721. /**
  54722. * Controls the overall intensity of each sample
  54723. */
  54724. weight: number;
  54725. /**
  54726. * Controls the density of each sample
  54727. */
  54728. density: number;
  54729. /**
  54730. * @constructor
  54731. * @param name The post-process name
  54732. * @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)
  54733. * @param camera The camera that the post-process will be attached to
  54734. * @param mesh The mesh used to create the light scattering
  54735. * @param samples The post-process quality, default 100
  54736. * @param samplingModeThe post-process filtering mode
  54737. * @param engine The babylon engine
  54738. * @param reusable If the post-process is reusable
  54739. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  54740. */
  54741. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  54742. /**
  54743. * Returns the string "VolumetricLightScatteringPostProcess"
  54744. * @returns "VolumetricLightScatteringPostProcess"
  54745. */
  54746. getClassName(): string;
  54747. private _isReady;
  54748. /**
  54749. * Sets the new light position for light scattering effect
  54750. * @param position The new custom light position
  54751. */
  54752. setCustomMeshPosition(position: Vector3): void;
  54753. /**
  54754. * Returns the light position for light scattering effect
  54755. * @return Vector3 The custom light position
  54756. */
  54757. getCustomMeshPosition(): Vector3;
  54758. /**
  54759. * Disposes the internal assets and detaches the post-process from the camera
  54760. */
  54761. dispose(camera: Camera): void;
  54762. /**
  54763. * Returns the render target texture used by the post-process
  54764. * @return the render target texture used by the post-process
  54765. */
  54766. getPass(): RenderTargetTexture;
  54767. private _meshExcluded;
  54768. private _createPass;
  54769. private _updateMeshScreenCoordinates;
  54770. /**
  54771. * Creates a default mesh for the Volumeric Light Scattering post-process
  54772. * @param name The mesh name
  54773. * @param scene The scene where to create the mesh
  54774. * @return the default mesh
  54775. */
  54776. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  54777. }
  54778. }
  54779. declare module "babylonjs/PostProcesses/index" {
  54780. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  54781. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  54782. export * from "babylonjs/PostProcesses/bloomEffect";
  54783. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  54784. export * from "babylonjs/PostProcesses/blurPostProcess";
  54785. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54786. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  54787. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  54788. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  54789. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54790. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  54791. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  54792. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  54793. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54794. export * from "babylonjs/PostProcesses/filterPostProcess";
  54795. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  54796. export * from "babylonjs/PostProcesses/grainPostProcess";
  54797. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  54798. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54799. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  54800. export * from "babylonjs/PostProcesses/passPostProcess";
  54801. export * from "babylonjs/PostProcesses/postProcess";
  54802. export * from "babylonjs/PostProcesses/postProcessManager";
  54803. export * from "babylonjs/PostProcesses/refractionPostProcess";
  54804. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  54805. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  54806. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  54807. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  54808. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  54809. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  54810. }
  54811. declare module "babylonjs/Probes/index" {
  54812. export * from "babylonjs/Probes/reflectionProbe";
  54813. }
  54814. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  54815. import { Scene } from "babylonjs/scene";
  54816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54817. import { Color3 } from "babylonjs/Maths/math";
  54818. import { SmartArray } from "babylonjs/Misc/smartArray";
  54819. import { ISceneComponent } from "babylonjs/sceneComponent";
  54820. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  54821. import "babylonjs/Meshes/Builders/boxBuilder";
  54822. import "babylonjs/Shaders/color.fragment";
  54823. import "babylonjs/Shaders/color.vertex";
  54824. module "babylonjs/scene" {
  54825. interface Scene {
  54826. /** @hidden (Backing field) */
  54827. _boundingBoxRenderer: BoundingBoxRenderer;
  54828. /** @hidden (Backing field) */
  54829. _forceShowBoundingBoxes: boolean;
  54830. /**
  54831. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54832. */
  54833. forceShowBoundingBoxes: boolean;
  54834. /**
  54835. * Gets the bounding box renderer associated with the scene
  54836. * @returns a BoundingBoxRenderer
  54837. */
  54838. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54839. }
  54840. }
  54841. module "babylonjs/Meshes/abstractMesh" {
  54842. interface AbstractMesh {
  54843. /** @hidden (Backing field) */
  54844. _showBoundingBox: boolean;
  54845. /**
  54846. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  54847. */
  54848. showBoundingBox: boolean;
  54849. }
  54850. }
  54851. /**
  54852. * Component responsible of rendering the bounding box of the meshes in a scene.
  54853. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54854. */
  54855. export class BoundingBoxRenderer implements ISceneComponent {
  54856. /**
  54857. * The component name helpfull to identify the component in the list of scene components.
  54858. */
  54859. readonly name: string;
  54860. /**
  54861. * The scene the component belongs to.
  54862. */
  54863. scene: Scene;
  54864. /**
  54865. * Color of the bounding box lines placed in front of an object
  54866. */
  54867. frontColor: Color3;
  54868. /**
  54869. * Color of the bounding box lines placed behind an object
  54870. */
  54871. backColor: Color3;
  54872. /**
  54873. * Defines if the renderer should show the back lines or not
  54874. */
  54875. showBackLines: boolean;
  54876. /**
  54877. * @hidden
  54878. */
  54879. renderList: SmartArray<BoundingBox>;
  54880. private _colorShader;
  54881. private _vertexBuffers;
  54882. private _indexBuffer;
  54883. /**
  54884. * Instantiates a new bounding box renderer in a scene.
  54885. * @param scene the scene the renderer renders in
  54886. */
  54887. constructor(scene: Scene);
  54888. /**
  54889. * Registers the component in a given scene
  54890. */
  54891. register(): void;
  54892. private _evaluateSubMesh;
  54893. private _activeMesh;
  54894. private _prepareRessources;
  54895. private _createIndexBuffer;
  54896. /**
  54897. * Rebuilds the elements related to this component in case of
  54898. * context lost for instance.
  54899. */
  54900. rebuild(): void;
  54901. /**
  54902. * @hidden
  54903. */
  54904. reset(): void;
  54905. /**
  54906. * Render the bounding boxes of a specific rendering group
  54907. * @param renderingGroupId defines the rendering group to render
  54908. */
  54909. render(renderingGroupId: number): void;
  54910. /**
  54911. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54912. * @param mesh Define the mesh to render the occlusion bounding box for
  54913. */
  54914. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54915. /**
  54916. * Dispose and release the resources attached to this renderer.
  54917. */
  54918. dispose(): void;
  54919. }
  54920. }
  54921. declare module "babylonjs/Shaders/depth.fragment" {
  54922. /** @hidden */
  54923. export var depthPixelShader: {
  54924. name: string;
  54925. shader: string;
  54926. };
  54927. }
  54928. declare module "babylonjs/Rendering/depthRenderer" {
  54929. import { Nullable } from "babylonjs/types";
  54930. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54931. import { Scene } from "babylonjs/scene";
  54932. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54933. import { Camera } from "babylonjs/Cameras/camera";
  54934. import "babylonjs/Shaders/depth.fragment";
  54935. import "babylonjs/Shaders/depth.vertex";
  54936. /**
  54937. * This represents a depth renderer in Babylon.
  54938. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54939. */
  54940. export class DepthRenderer {
  54941. private _scene;
  54942. private _depthMap;
  54943. private _effect;
  54944. private _cachedDefines;
  54945. private _camera;
  54946. /**
  54947. * Specifiess that the depth renderer will only be used within
  54948. * the camera it is created for.
  54949. * This can help forcing its rendering during the camera processing.
  54950. */
  54951. useOnlyInActiveCamera: boolean;
  54952. /** @hidden */
  54953. static _SceneComponentInitialization: (scene: Scene) => void;
  54954. /**
  54955. * Instantiates a depth renderer
  54956. * @param scene The scene the renderer belongs to
  54957. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54958. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54959. */
  54960. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54961. /**
  54962. * Creates the depth rendering effect and checks if the effect is ready.
  54963. * @param subMesh The submesh to be used to render the depth map of
  54964. * @param useInstances If multiple world instances should be used
  54965. * @returns if the depth renderer is ready to render the depth map
  54966. */
  54967. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54968. /**
  54969. * Gets the texture which the depth map will be written to.
  54970. * @returns The depth map texture
  54971. */
  54972. getDepthMap(): RenderTargetTexture;
  54973. /**
  54974. * Disposes of the depth renderer.
  54975. */
  54976. dispose(): void;
  54977. }
  54978. }
  54979. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  54980. import { Nullable } from "babylonjs/types";
  54981. import { Scene } from "babylonjs/scene";
  54982. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  54983. import { Camera } from "babylonjs/Cameras/camera";
  54984. import { ISceneComponent } from "babylonjs/sceneComponent";
  54985. module "babylonjs/scene" {
  54986. interface Scene {
  54987. /** @hidden (Backing field) */
  54988. _depthRenderer: {
  54989. [id: string]: DepthRenderer;
  54990. };
  54991. /**
  54992. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54993. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54994. * @returns the created depth renderer
  54995. */
  54996. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54997. /**
  54998. * Disables a depth renderer for a given camera
  54999. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  55000. */
  55001. disableDepthRenderer(camera?: Nullable<Camera>): void;
  55002. }
  55003. }
  55004. /**
  55005. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  55006. * in several rendering techniques.
  55007. */
  55008. export class DepthRendererSceneComponent implements ISceneComponent {
  55009. /**
  55010. * The component name helpfull to identify the component in the list of scene components.
  55011. */
  55012. readonly name: string;
  55013. /**
  55014. * The scene the component belongs to.
  55015. */
  55016. scene: Scene;
  55017. /**
  55018. * Creates a new instance of the component for the given scene
  55019. * @param scene Defines the scene to register the component in
  55020. */
  55021. constructor(scene: Scene);
  55022. /**
  55023. * Registers the component in a given scene
  55024. */
  55025. register(): void;
  55026. /**
  55027. * Rebuilds the elements related to this component in case of
  55028. * context lost for instance.
  55029. */
  55030. rebuild(): void;
  55031. /**
  55032. * Disposes the component and the associated ressources
  55033. */
  55034. dispose(): void;
  55035. private _gatherRenderTargets;
  55036. private _gatherActiveCameraRenderTargets;
  55037. }
  55038. }
  55039. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55040. import { Nullable } from "babylonjs/types";
  55041. import { Scene } from "babylonjs/scene";
  55042. import { ISceneComponent } from "babylonjs/sceneComponent";
  55043. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55044. module "babylonjs/scene" {
  55045. interface Scene {
  55046. /** @hidden (Backing field) */
  55047. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55048. /**
  55049. * Gets or Sets the current geometry buffer associated to the scene.
  55050. */
  55051. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55052. /**
  55053. * Enables a GeometryBufferRender and associates it with the scene
  55054. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55055. * @returns the GeometryBufferRenderer
  55056. */
  55057. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55058. /**
  55059. * Disables the GeometryBufferRender associated with the scene
  55060. */
  55061. disableGeometryBufferRenderer(): void;
  55062. }
  55063. }
  55064. /**
  55065. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55066. * in several rendering techniques.
  55067. */
  55068. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55069. /**
  55070. * The component name helpful to identify the component in the list of scene components.
  55071. */
  55072. readonly name: string;
  55073. /**
  55074. * The scene the component belongs to.
  55075. */
  55076. scene: Scene;
  55077. /**
  55078. * Creates a new instance of the component for the given scene
  55079. * @param scene Defines the scene to register the component in
  55080. */
  55081. constructor(scene: Scene);
  55082. /**
  55083. * Registers the component in a given scene
  55084. */
  55085. register(): void;
  55086. /**
  55087. * Rebuilds the elements related to this component in case of
  55088. * context lost for instance.
  55089. */
  55090. rebuild(): void;
  55091. /**
  55092. * Disposes the component and the associated ressources
  55093. */
  55094. dispose(): void;
  55095. private _gatherRenderTargets;
  55096. }
  55097. }
  55098. declare module "babylonjs/Shaders/outline.fragment" {
  55099. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55100. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  55101. /** @hidden */
  55102. export var outlinePixelShader: {
  55103. name: string;
  55104. shader: string;
  55105. };
  55106. }
  55107. declare module "babylonjs/Shaders/outline.vertex" {
  55108. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55109. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55110. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55111. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55112. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55113. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  55114. /** @hidden */
  55115. export var outlineVertexShader: {
  55116. name: string;
  55117. shader: string;
  55118. };
  55119. }
  55120. declare module "babylonjs/Rendering/outlineRenderer" {
  55121. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55122. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  55123. import { Scene } from "babylonjs/scene";
  55124. import { ISceneComponent } from "babylonjs/sceneComponent";
  55125. import "babylonjs/Shaders/outline.fragment";
  55126. import "babylonjs/Shaders/outline.vertex";
  55127. module "babylonjs/scene" {
  55128. interface Scene {
  55129. /** @hidden */
  55130. _outlineRenderer: OutlineRenderer;
  55131. /**
  55132. * Gets the outline renderer associated with the scene
  55133. * @returns a OutlineRenderer
  55134. */
  55135. getOutlineRenderer(): OutlineRenderer;
  55136. }
  55137. }
  55138. module "babylonjs/Meshes/abstractMesh" {
  55139. interface AbstractMesh {
  55140. /** @hidden (Backing field) */
  55141. _renderOutline: boolean;
  55142. /**
  55143. * Gets or sets a boolean indicating if the outline must be rendered as well
  55144. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55145. */
  55146. renderOutline: boolean;
  55147. /** @hidden (Backing field) */
  55148. _renderOverlay: boolean;
  55149. /**
  55150. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55151. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55152. */
  55153. renderOverlay: boolean;
  55154. }
  55155. }
  55156. /**
  55157. * This class is responsible to draw bothe outline/overlay of meshes.
  55158. * It should not be used directly but through the available method on mesh.
  55159. */
  55160. export class OutlineRenderer implements ISceneComponent {
  55161. /**
  55162. * The name of the component. Each component must have a unique name.
  55163. */
  55164. name: string;
  55165. /**
  55166. * The scene the component belongs to.
  55167. */
  55168. scene: Scene;
  55169. /**
  55170. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55171. */
  55172. zOffset: number;
  55173. private _engine;
  55174. private _effect;
  55175. private _cachedDefines;
  55176. private _savedDepthWrite;
  55177. /**
  55178. * Instantiates a new outline renderer. (There could be only one per scene).
  55179. * @param scene Defines the scene it belongs to
  55180. */
  55181. constructor(scene: Scene);
  55182. /**
  55183. * Register the component to one instance of a scene.
  55184. */
  55185. register(): void;
  55186. /**
  55187. * Rebuilds the elements related to this component in case of
  55188. * context lost for instance.
  55189. */
  55190. rebuild(): void;
  55191. /**
  55192. * Disposes the component and the associated ressources.
  55193. */
  55194. dispose(): void;
  55195. /**
  55196. * Renders the outline in the canvas.
  55197. * @param subMesh Defines the sumesh to render
  55198. * @param batch Defines the batch of meshes in case of instances
  55199. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55200. */
  55201. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55202. /**
  55203. * Returns whether or not the outline renderer is ready for a given submesh.
  55204. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55205. * @param subMesh Defines the submesh to check readyness for
  55206. * @param useInstances Defines wheter wee are trying to render instances or not
  55207. * @returns true if ready otherwise false
  55208. */
  55209. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55210. private _beforeRenderingMesh;
  55211. private _afterRenderingMesh;
  55212. }
  55213. }
  55214. declare module "babylonjs/Rendering/index" {
  55215. export * from "babylonjs/Rendering/boundingBoxRenderer";
  55216. export * from "babylonjs/Rendering/depthRenderer";
  55217. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  55218. export * from "babylonjs/Rendering/edgesRenderer";
  55219. export * from "babylonjs/Rendering/geometryBufferRenderer";
  55220. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55221. export * from "babylonjs/Rendering/outlineRenderer";
  55222. export * from "babylonjs/Rendering/renderingGroup";
  55223. export * from "babylonjs/Rendering/renderingManager";
  55224. export * from "babylonjs/Rendering/utilityLayerRenderer";
  55225. }
  55226. declare module "babylonjs/Sprites/index" {
  55227. export * from "babylonjs/Sprites/sprite";
  55228. export * from "babylonjs/Sprites/spriteManager";
  55229. export * from "babylonjs/Sprites/spriteSceneComponent";
  55230. }
  55231. declare module "babylonjs/Misc/assetsManager" {
  55232. import { Scene } from "babylonjs/scene";
  55233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55234. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  55235. import { Skeleton } from "babylonjs/Bones/skeleton";
  55236. import { Observable } from "babylonjs/Misc/observable";
  55237. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55238. import { Texture } from "babylonjs/Materials/Textures/texture";
  55239. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55240. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  55241. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  55242. /**
  55243. * Defines the list of states available for a task inside a AssetsManager
  55244. */
  55245. export enum AssetTaskState {
  55246. /**
  55247. * Initialization
  55248. */
  55249. INIT = 0,
  55250. /**
  55251. * Running
  55252. */
  55253. RUNNING = 1,
  55254. /**
  55255. * Done
  55256. */
  55257. DONE = 2,
  55258. /**
  55259. * Error
  55260. */
  55261. ERROR = 3
  55262. }
  55263. /**
  55264. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55265. */
  55266. export abstract class AbstractAssetTask {
  55267. /**
  55268. * Task name
  55269. */ name: string;
  55270. /**
  55271. * Callback called when the task is successful
  55272. */
  55273. onSuccess: (task: any) => void;
  55274. /**
  55275. * Callback called when the task is not successful
  55276. */
  55277. onError: (task: any, message?: string, exception?: any) => void;
  55278. /**
  55279. * Creates a new AssetsManager
  55280. * @param name defines the name of the task
  55281. */
  55282. constructor(
  55283. /**
  55284. * Task name
  55285. */ name: string);
  55286. private _isCompleted;
  55287. private _taskState;
  55288. private _errorObject;
  55289. /**
  55290. * Get if the task is completed
  55291. */
  55292. readonly isCompleted: boolean;
  55293. /**
  55294. * Gets the current state of the task
  55295. */
  55296. readonly taskState: AssetTaskState;
  55297. /**
  55298. * Gets the current error object (if task is in error)
  55299. */
  55300. readonly errorObject: {
  55301. message?: string;
  55302. exception?: any;
  55303. };
  55304. /**
  55305. * Internal only
  55306. * @hidden
  55307. */
  55308. _setErrorObject(message?: string, exception?: any): void;
  55309. /**
  55310. * Execute the current task
  55311. * @param scene defines the scene where you want your assets to be loaded
  55312. * @param onSuccess is a callback called when the task is successfully executed
  55313. * @param onError is a callback called if an error occurs
  55314. */
  55315. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55316. /**
  55317. * Execute the current task
  55318. * @param scene defines the scene where you want your assets to be loaded
  55319. * @param onSuccess is a callback called when the task is successfully executed
  55320. * @param onError is a callback called if an error occurs
  55321. */
  55322. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55323. /**
  55324. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55325. * This can be used with failed tasks that have the reason for failure fixed.
  55326. */
  55327. reset(): void;
  55328. private onErrorCallback;
  55329. private onDoneCallback;
  55330. }
  55331. /**
  55332. * Define the interface used by progress events raised during assets loading
  55333. */
  55334. export interface IAssetsProgressEvent {
  55335. /**
  55336. * Defines the number of remaining tasks to process
  55337. */
  55338. remainingCount: number;
  55339. /**
  55340. * Defines the total number of tasks
  55341. */
  55342. totalCount: number;
  55343. /**
  55344. * Defines the task that was just processed
  55345. */
  55346. task: AbstractAssetTask;
  55347. }
  55348. /**
  55349. * Class used to share progress information about assets loading
  55350. */
  55351. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55352. /**
  55353. * Defines the number of remaining tasks to process
  55354. */
  55355. remainingCount: number;
  55356. /**
  55357. * Defines the total number of tasks
  55358. */
  55359. totalCount: number;
  55360. /**
  55361. * Defines the task that was just processed
  55362. */
  55363. task: AbstractAssetTask;
  55364. /**
  55365. * Creates a AssetsProgressEvent
  55366. * @param remainingCount defines the number of remaining tasks to process
  55367. * @param totalCount defines the total number of tasks
  55368. * @param task defines the task that was just processed
  55369. */
  55370. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55371. }
  55372. /**
  55373. * Define a task used by AssetsManager to load meshes
  55374. */
  55375. export class MeshAssetTask extends AbstractAssetTask {
  55376. /**
  55377. * Defines the name of the task
  55378. */
  55379. name: string;
  55380. /**
  55381. * Defines the list of mesh's names you want to load
  55382. */
  55383. meshesNames: any;
  55384. /**
  55385. * Defines the root url to use as a base to load your meshes and associated resources
  55386. */
  55387. rootUrl: string;
  55388. /**
  55389. * Defines the filename of the scene to load from
  55390. */
  55391. sceneFilename: string;
  55392. /**
  55393. * Gets the list of loaded meshes
  55394. */
  55395. loadedMeshes: Array<AbstractMesh>;
  55396. /**
  55397. * Gets the list of loaded particle systems
  55398. */
  55399. loadedParticleSystems: Array<IParticleSystem>;
  55400. /**
  55401. * Gets the list of loaded skeletons
  55402. */
  55403. loadedSkeletons: Array<Skeleton>;
  55404. /**
  55405. * Gets the list of loaded animation groups
  55406. */
  55407. loadedAnimationGroups: Array<AnimationGroup>;
  55408. /**
  55409. * Callback called when the task is successful
  55410. */
  55411. onSuccess: (task: MeshAssetTask) => void;
  55412. /**
  55413. * Callback called when the task is successful
  55414. */
  55415. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55416. /**
  55417. * Creates a new MeshAssetTask
  55418. * @param name defines the name of the task
  55419. * @param meshesNames defines the list of mesh's names you want to load
  55420. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55421. * @param sceneFilename defines the filename of the scene to load from
  55422. */
  55423. constructor(
  55424. /**
  55425. * Defines the name of the task
  55426. */
  55427. name: string,
  55428. /**
  55429. * Defines the list of mesh's names you want to load
  55430. */
  55431. meshesNames: any,
  55432. /**
  55433. * Defines the root url to use as a base to load your meshes and associated resources
  55434. */
  55435. rootUrl: string,
  55436. /**
  55437. * Defines the filename of the scene to load from
  55438. */
  55439. sceneFilename: string);
  55440. /**
  55441. * Execute the current task
  55442. * @param scene defines the scene where you want your assets to be loaded
  55443. * @param onSuccess is a callback called when the task is successfully executed
  55444. * @param onError is a callback called if an error occurs
  55445. */
  55446. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55447. }
  55448. /**
  55449. * Define a task used by AssetsManager to load text content
  55450. */
  55451. export class TextFileAssetTask extends AbstractAssetTask {
  55452. /**
  55453. * Defines the name of the task
  55454. */
  55455. name: string;
  55456. /**
  55457. * Defines the location of the file to load
  55458. */
  55459. url: string;
  55460. /**
  55461. * Gets the loaded text string
  55462. */
  55463. text: string;
  55464. /**
  55465. * Callback called when the task is successful
  55466. */
  55467. onSuccess: (task: TextFileAssetTask) => void;
  55468. /**
  55469. * Callback called when the task is successful
  55470. */
  55471. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55472. /**
  55473. * Creates a new TextFileAssetTask object
  55474. * @param name defines the name of the task
  55475. * @param url defines the location of the file to load
  55476. */
  55477. constructor(
  55478. /**
  55479. * Defines the name of the task
  55480. */
  55481. name: string,
  55482. /**
  55483. * Defines the location of the file to load
  55484. */
  55485. url: string);
  55486. /**
  55487. * Execute the current task
  55488. * @param scene defines the scene where you want your assets to be loaded
  55489. * @param onSuccess is a callback called when the task is successfully executed
  55490. * @param onError is a callback called if an error occurs
  55491. */
  55492. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55493. }
  55494. /**
  55495. * Define a task used by AssetsManager to load binary data
  55496. */
  55497. export class BinaryFileAssetTask extends AbstractAssetTask {
  55498. /**
  55499. * Defines the name of the task
  55500. */
  55501. name: string;
  55502. /**
  55503. * Defines the location of the file to load
  55504. */
  55505. url: string;
  55506. /**
  55507. * Gets the lodaded data (as an array buffer)
  55508. */
  55509. data: ArrayBuffer;
  55510. /**
  55511. * Callback called when the task is successful
  55512. */
  55513. onSuccess: (task: BinaryFileAssetTask) => void;
  55514. /**
  55515. * Callback called when the task is successful
  55516. */
  55517. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55518. /**
  55519. * Creates a new BinaryFileAssetTask object
  55520. * @param name defines the name of the new task
  55521. * @param url defines the location of the file to load
  55522. */
  55523. constructor(
  55524. /**
  55525. * Defines the name of the task
  55526. */
  55527. name: string,
  55528. /**
  55529. * Defines the location of the file to load
  55530. */
  55531. url: string);
  55532. /**
  55533. * Execute the current task
  55534. * @param scene defines the scene where you want your assets to be loaded
  55535. * @param onSuccess is a callback called when the task is successfully executed
  55536. * @param onError is a callback called if an error occurs
  55537. */
  55538. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55539. }
  55540. /**
  55541. * Define a task used by AssetsManager to load images
  55542. */
  55543. export class ImageAssetTask extends AbstractAssetTask {
  55544. /**
  55545. * Defines the name of the task
  55546. */
  55547. name: string;
  55548. /**
  55549. * Defines the location of the image to load
  55550. */
  55551. url: string;
  55552. /**
  55553. * Gets the loaded images
  55554. */
  55555. image: HTMLImageElement;
  55556. /**
  55557. * Callback called when the task is successful
  55558. */
  55559. onSuccess: (task: ImageAssetTask) => void;
  55560. /**
  55561. * Callback called when the task is successful
  55562. */
  55563. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55564. /**
  55565. * Creates a new ImageAssetTask
  55566. * @param name defines the name of the task
  55567. * @param url defines the location of the image to load
  55568. */
  55569. constructor(
  55570. /**
  55571. * Defines the name of the task
  55572. */
  55573. name: string,
  55574. /**
  55575. * Defines the location of the image to load
  55576. */
  55577. url: string);
  55578. /**
  55579. * Execute the current task
  55580. * @param scene defines the scene where you want your assets to be loaded
  55581. * @param onSuccess is a callback called when the task is successfully executed
  55582. * @param onError is a callback called if an error occurs
  55583. */
  55584. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55585. }
  55586. /**
  55587. * Defines the interface used by texture loading tasks
  55588. */
  55589. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55590. /**
  55591. * Gets the loaded texture
  55592. */
  55593. texture: TEX;
  55594. }
  55595. /**
  55596. * Define a task used by AssetsManager to load 2D textures
  55597. */
  55598. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55599. /**
  55600. * Defines the name of the task
  55601. */
  55602. name: string;
  55603. /**
  55604. * Defines the location of the file to load
  55605. */
  55606. url: string;
  55607. /**
  55608. * Defines if mipmap should not be generated (default is false)
  55609. */
  55610. noMipmap?: boolean | undefined;
  55611. /**
  55612. * Defines if texture must be inverted on Y axis (default is false)
  55613. */
  55614. invertY?: boolean | undefined;
  55615. /**
  55616. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55617. */
  55618. samplingMode: number;
  55619. /**
  55620. * Gets the loaded texture
  55621. */
  55622. texture: Texture;
  55623. /**
  55624. * Callback called when the task is successful
  55625. */
  55626. onSuccess: (task: TextureAssetTask) => void;
  55627. /**
  55628. * Callback called when the task is successful
  55629. */
  55630. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55631. /**
  55632. * Creates a new TextureAssetTask object
  55633. * @param name defines the name of the task
  55634. * @param url defines the location of the file to load
  55635. * @param noMipmap defines if mipmap should not be generated (default is false)
  55636. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55637. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55638. */
  55639. constructor(
  55640. /**
  55641. * Defines the name of the task
  55642. */
  55643. name: string,
  55644. /**
  55645. * Defines the location of the file to load
  55646. */
  55647. url: string,
  55648. /**
  55649. * Defines if mipmap should not be generated (default is false)
  55650. */
  55651. noMipmap?: boolean | undefined,
  55652. /**
  55653. * Defines if texture must be inverted on Y axis (default is false)
  55654. */
  55655. invertY?: boolean | undefined,
  55656. /**
  55657. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55658. */
  55659. samplingMode?: number);
  55660. /**
  55661. * Execute the current task
  55662. * @param scene defines the scene where you want your assets to be loaded
  55663. * @param onSuccess is a callback called when the task is successfully executed
  55664. * @param onError is a callback called if an error occurs
  55665. */
  55666. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55667. }
  55668. /**
  55669. * Define a task used by AssetsManager to load cube textures
  55670. */
  55671. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55672. /**
  55673. * Defines the name of the task
  55674. */
  55675. name: string;
  55676. /**
  55677. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55678. */
  55679. url: string;
  55680. /**
  55681. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55682. */
  55683. extensions?: string[] | undefined;
  55684. /**
  55685. * Defines if mipmaps should not be generated (default is false)
  55686. */
  55687. noMipmap?: boolean | undefined;
  55688. /**
  55689. * Defines the explicit list of files (undefined by default)
  55690. */
  55691. files?: string[] | undefined;
  55692. /**
  55693. * Gets the loaded texture
  55694. */
  55695. texture: CubeTexture;
  55696. /**
  55697. * Callback called when the task is successful
  55698. */
  55699. onSuccess: (task: CubeTextureAssetTask) => void;
  55700. /**
  55701. * Callback called when the task is successful
  55702. */
  55703. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  55704. /**
  55705. * Creates a new CubeTextureAssetTask
  55706. * @param name defines the name of the task
  55707. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55708. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55709. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55710. * @param files defines the explicit list of files (undefined by default)
  55711. */
  55712. constructor(
  55713. /**
  55714. * Defines the name of the task
  55715. */
  55716. name: string,
  55717. /**
  55718. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55719. */
  55720. url: string,
  55721. /**
  55722. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55723. */
  55724. extensions?: string[] | undefined,
  55725. /**
  55726. * Defines if mipmaps should not be generated (default is false)
  55727. */
  55728. noMipmap?: boolean | undefined,
  55729. /**
  55730. * Defines the explicit list of files (undefined by default)
  55731. */
  55732. files?: string[] | undefined);
  55733. /**
  55734. * Execute the current task
  55735. * @param scene defines the scene where you want your assets to be loaded
  55736. * @param onSuccess is a callback called when the task is successfully executed
  55737. * @param onError is a callback called if an error occurs
  55738. */
  55739. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55740. }
  55741. /**
  55742. * Define a task used by AssetsManager to load HDR cube textures
  55743. */
  55744. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  55745. /**
  55746. * Defines the name of the task
  55747. */
  55748. name: string;
  55749. /**
  55750. * Defines the location of the file to load
  55751. */
  55752. url: string;
  55753. /**
  55754. * Defines the desired size (the more it increases the longer the generation will be)
  55755. */
  55756. size: number;
  55757. /**
  55758. * Defines if mipmaps should not be generated (default is false)
  55759. */
  55760. noMipmap: boolean;
  55761. /**
  55762. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55763. */
  55764. generateHarmonics: boolean;
  55765. /**
  55766. * 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)
  55767. */
  55768. gammaSpace: boolean;
  55769. /**
  55770. * Internal Use Only
  55771. */
  55772. reserved: boolean;
  55773. /**
  55774. * Gets the loaded texture
  55775. */
  55776. texture: HDRCubeTexture;
  55777. /**
  55778. * Callback called when the task is successful
  55779. */
  55780. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55781. /**
  55782. * Callback called when the task is successful
  55783. */
  55784. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55785. /**
  55786. * Creates a new HDRCubeTextureAssetTask object
  55787. * @param name defines the name of the task
  55788. * @param url defines the location of the file to load
  55789. * @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.
  55790. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55791. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55792. * @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)
  55793. * @param reserved Internal use only
  55794. */
  55795. constructor(
  55796. /**
  55797. * Defines the name of the task
  55798. */
  55799. name: string,
  55800. /**
  55801. * Defines the location of the file to load
  55802. */
  55803. url: string,
  55804. /**
  55805. * Defines the desired size (the more it increases the longer the generation will be)
  55806. */
  55807. size: number,
  55808. /**
  55809. * Defines if mipmaps should not be generated (default is false)
  55810. */
  55811. noMipmap?: boolean,
  55812. /**
  55813. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55814. */
  55815. generateHarmonics?: boolean,
  55816. /**
  55817. * 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)
  55818. */
  55819. gammaSpace?: boolean,
  55820. /**
  55821. * Internal Use Only
  55822. */
  55823. reserved?: boolean);
  55824. /**
  55825. * Execute the current task
  55826. * @param scene defines the scene where you want your assets to be loaded
  55827. * @param onSuccess is a callback called when the task is successfully executed
  55828. * @param onError is a callback called if an error occurs
  55829. */
  55830. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55831. }
  55832. /**
  55833. * This class can be used to easily import assets into a scene
  55834. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55835. */
  55836. export class AssetsManager {
  55837. private _scene;
  55838. private _isLoading;
  55839. protected _tasks: AbstractAssetTask[];
  55840. protected _waitingTasksCount: number;
  55841. protected _totalTasksCount: number;
  55842. /**
  55843. * Callback called when all tasks are processed
  55844. */
  55845. onFinish: (tasks: AbstractAssetTask[]) => void;
  55846. /**
  55847. * Callback called when a task is successful
  55848. */
  55849. onTaskSuccess: (task: AbstractAssetTask) => void;
  55850. /**
  55851. * Callback called when a task had an error
  55852. */
  55853. onTaskError: (task: AbstractAssetTask) => void;
  55854. /**
  55855. * Callback called when a task is done (whatever the result is)
  55856. */
  55857. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55858. /**
  55859. * Observable called when all tasks are processed
  55860. */
  55861. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55862. /**
  55863. * Observable called when a task had an error
  55864. */
  55865. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55866. /**
  55867. * Observable called when a task is successful
  55868. */
  55869. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55870. /**
  55871. * Observable called when a task is done (whatever the result is)
  55872. */
  55873. onProgressObservable: Observable<IAssetsProgressEvent>;
  55874. /**
  55875. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55876. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55877. */
  55878. useDefaultLoadingScreen: boolean;
  55879. /**
  55880. * Creates a new AssetsManager
  55881. * @param scene defines the scene to work on
  55882. */
  55883. constructor(scene: Scene);
  55884. /**
  55885. * Add a MeshAssetTask to the list of active tasks
  55886. * @param taskName defines the name of the new task
  55887. * @param meshesNames defines the name of meshes to load
  55888. * @param rootUrl defines the root url to use to locate files
  55889. * @param sceneFilename defines the filename of the scene file
  55890. * @returns a new MeshAssetTask object
  55891. */
  55892. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55893. /**
  55894. * Add a TextFileAssetTask to the list of active tasks
  55895. * @param taskName defines the name of the new task
  55896. * @param url defines the url of the file to load
  55897. * @returns a new TextFileAssetTask object
  55898. */
  55899. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55900. /**
  55901. * Add a BinaryFileAssetTask to the list of active tasks
  55902. * @param taskName defines the name of the new task
  55903. * @param url defines the url of the file to load
  55904. * @returns a new BinaryFileAssetTask object
  55905. */
  55906. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55907. /**
  55908. * Add a ImageAssetTask to the list of active tasks
  55909. * @param taskName defines the name of the new task
  55910. * @param url defines the url of the file to load
  55911. * @returns a new ImageAssetTask object
  55912. */
  55913. addImageTask(taskName: string, url: string): ImageAssetTask;
  55914. /**
  55915. * Add a TextureAssetTask to the list of active tasks
  55916. * @param taskName defines the name of the new task
  55917. * @param url defines the url of the file to load
  55918. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55919. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55920. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55921. * @returns a new TextureAssetTask object
  55922. */
  55923. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55924. /**
  55925. * Add a CubeTextureAssetTask to the list of active tasks
  55926. * @param taskName defines the name of the new task
  55927. * @param url defines the url of the file to load
  55928. * @param extensions defines the extension to use to load the cube map (can be null)
  55929. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55930. * @param files defines the list of files to load (can be null)
  55931. * @returns a new CubeTextureAssetTask object
  55932. */
  55933. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55934. /**
  55935. *
  55936. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55937. * @param taskName defines the name of the new task
  55938. * @param url defines the url of the file to load
  55939. * @param size defines the size you want for the cubemap (can be null)
  55940. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55941. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55942. * @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)
  55943. * @param reserved Internal use only
  55944. * @returns a new HDRCubeTextureAssetTask object
  55945. */
  55946. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55947. /**
  55948. * Remove a task from the assets manager.
  55949. * @param task the task to remove
  55950. */
  55951. removeTask(task: AbstractAssetTask): void;
  55952. private _decreaseWaitingTasksCount;
  55953. private _runTask;
  55954. /**
  55955. * Reset the AssetsManager and remove all tasks
  55956. * @return the current instance of the AssetsManager
  55957. */
  55958. reset(): AssetsManager;
  55959. /**
  55960. * Start the loading process
  55961. * @return the current instance of the AssetsManager
  55962. */
  55963. load(): AssetsManager;
  55964. }
  55965. }
  55966. declare module "babylonjs/Misc/deferred" {
  55967. /**
  55968. * Wrapper class for promise with external resolve and reject.
  55969. */
  55970. export class Deferred<T> {
  55971. /**
  55972. * The promise associated with this deferred object.
  55973. */
  55974. readonly promise: Promise<T>;
  55975. private _resolve;
  55976. private _reject;
  55977. /**
  55978. * The resolve method of the promise associated with this deferred object.
  55979. */
  55980. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55981. /**
  55982. * The reject method of the promise associated with this deferred object.
  55983. */
  55984. readonly reject: (reason?: any) => void;
  55985. /**
  55986. * Constructor for this deferred object.
  55987. */
  55988. constructor();
  55989. }
  55990. }
  55991. declare module "babylonjs/Misc/filesInput" {
  55992. import { Engine } from "babylonjs/Engines/engine";
  55993. import { Scene } from "babylonjs/scene";
  55994. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  55995. /**
  55996. * Class used to help managing file picking and drag'n'drop
  55997. */
  55998. export class FilesInput {
  55999. /**
  56000. * List of files ready to be loaded
  56001. */
  56002. static readonly FilesToLoad: {
  56003. [key: string]: File;
  56004. };
  56005. /**
  56006. * Callback called when a file is processed
  56007. */
  56008. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  56009. private _engine;
  56010. private _currentScene;
  56011. private _sceneLoadedCallback;
  56012. private _progressCallback;
  56013. private _additionalRenderLoopLogicCallback;
  56014. private _textureLoadingCallback;
  56015. private _startingProcessingFilesCallback;
  56016. private _onReloadCallback;
  56017. private _errorCallback;
  56018. private _elementToMonitor;
  56019. private _sceneFileToLoad;
  56020. private _filesToLoad;
  56021. /**
  56022. * Creates a new FilesInput
  56023. * @param engine defines the rendering engine
  56024. * @param scene defines the hosting scene
  56025. * @param sceneLoadedCallback callback called when scene is loaded
  56026. * @param progressCallback callback called to track progress
  56027. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  56028. * @param textureLoadingCallback callback called when a texture is loading
  56029. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  56030. * @param onReloadCallback callback called when a reload is requested
  56031. * @param errorCallback callback call if an error occurs
  56032. */
  56033. 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);
  56034. private _dragEnterHandler;
  56035. private _dragOverHandler;
  56036. private _dropHandler;
  56037. /**
  56038. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56039. * @param elementToMonitor defines the DOM element to track
  56040. */
  56041. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56042. /**
  56043. * Release all associated resources
  56044. */
  56045. dispose(): void;
  56046. private renderFunction;
  56047. private drag;
  56048. private drop;
  56049. private _traverseFolder;
  56050. private _processFiles;
  56051. /**
  56052. * Load files from a drop event
  56053. * @param event defines the drop event to use as source
  56054. */
  56055. loadFiles(event: any): void;
  56056. private _processReload;
  56057. /**
  56058. * Reload the current scene from the loaded files
  56059. */
  56060. reload(): void;
  56061. }
  56062. }
  56063. declare module "babylonjs/Misc/HighDynamicRange/index" {
  56064. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  56065. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  56066. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56067. }
  56068. declare module "babylonjs/Misc/sceneOptimizer" {
  56069. import { Scene, IDisposable } from "babylonjs/scene";
  56070. import { Observable } from "babylonjs/Misc/observable";
  56071. /**
  56072. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56073. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56074. */
  56075. export class SceneOptimization {
  56076. /**
  56077. * Defines the priority of this optimization (0 by default which means first in the list)
  56078. */
  56079. priority: number;
  56080. /**
  56081. * Gets a string describing the action executed by the current optimization
  56082. * @returns description string
  56083. */
  56084. getDescription(): string;
  56085. /**
  56086. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56087. * @param scene defines the current scene where to apply this optimization
  56088. * @param optimizer defines the current optimizer
  56089. * @returns true if everything that can be done was applied
  56090. */
  56091. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56092. /**
  56093. * Creates the SceneOptimization object
  56094. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56095. * @param desc defines the description associated with the optimization
  56096. */
  56097. constructor(
  56098. /**
  56099. * Defines the priority of this optimization (0 by default which means first in the list)
  56100. */
  56101. priority?: number);
  56102. }
  56103. /**
  56104. * Defines an optimization used to reduce the size of render target textures
  56105. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56106. */
  56107. export class TextureOptimization extends SceneOptimization {
  56108. /**
  56109. * Defines the priority of this optimization (0 by default which means first in the list)
  56110. */
  56111. priority: number;
  56112. /**
  56113. * 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
  56114. */
  56115. maximumSize: number;
  56116. /**
  56117. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56118. */
  56119. step: number;
  56120. /**
  56121. * Gets a string describing the action executed by the current optimization
  56122. * @returns description string
  56123. */
  56124. getDescription(): string;
  56125. /**
  56126. * Creates the TextureOptimization object
  56127. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56128. * @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
  56129. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56130. */
  56131. constructor(
  56132. /**
  56133. * Defines the priority of this optimization (0 by default which means first in the list)
  56134. */
  56135. priority?: number,
  56136. /**
  56137. * 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
  56138. */
  56139. maximumSize?: number,
  56140. /**
  56141. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56142. */
  56143. step?: number);
  56144. /**
  56145. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56146. * @param scene defines the current scene where to apply this optimization
  56147. * @param optimizer defines the current optimizer
  56148. * @returns true if everything that can be done was applied
  56149. */
  56150. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56151. }
  56152. /**
  56153. * Defines an optimization used to increase or decrease the rendering resolution
  56154. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56155. */
  56156. export class HardwareScalingOptimization extends SceneOptimization {
  56157. /**
  56158. * Defines the priority of this optimization (0 by default which means first in the list)
  56159. */
  56160. priority: number;
  56161. /**
  56162. * Defines the maximum scale to use (2 by default)
  56163. */
  56164. maximumScale: number;
  56165. /**
  56166. * Defines the step to use between two passes (0.5 by default)
  56167. */
  56168. step: number;
  56169. private _currentScale;
  56170. private _directionOffset;
  56171. /**
  56172. * Gets a string describing the action executed by the current optimization
  56173. * @return description string
  56174. */
  56175. getDescription(): string;
  56176. /**
  56177. * Creates the HardwareScalingOptimization object
  56178. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56179. * @param maximumScale defines the maximum scale to use (2 by default)
  56180. * @param step defines the step to use between two passes (0.5 by default)
  56181. */
  56182. constructor(
  56183. /**
  56184. * Defines the priority of this optimization (0 by default which means first in the list)
  56185. */
  56186. priority?: number,
  56187. /**
  56188. * Defines the maximum scale to use (2 by default)
  56189. */
  56190. maximumScale?: number,
  56191. /**
  56192. * Defines the step to use between two passes (0.5 by default)
  56193. */
  56194. step?: number);
  56195. /**
  56196. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56197. * @param scene defines the current scene where to apply this optimization
  56198. * @param optimizer defines the current optimizer
  56199. * @returns true if everything that can be done was applied
  56200. */
  56201. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56202. }
  56203. /**
  56204. * Defines an optimization used to remove shadows
  56205. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56206. */
  56207. export class ShadowsOptimization extends SceneOptimization {
  56208. /**
  56209. * Gets a string describing the action executed by the current optimization
  56210. * @return description string
  56211. */
  56212. getDescription(): string;
  56213. /**
  56214. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56215. * @param scene defines the current scene where to apply this optimization
  56216. * @param optimizer defines the current optimizer
  56217. * @returns true if everything that can be done was applied
  56218. */
  56219. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56220. }
  56221. /**
  56222. * Defines an optimization used to turn post-processes off
  56223. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56224. */
  56225. export class PostProcessesOptimization extends SceneOptimization {
  56226. /**
  56227. * Gets a string describing the action executed by the current optimization
  56228. * @return description string
  56229. */
  56230. getDescription(): string;
  56231. /**
  56232. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56233. * @param scene defines the current scene where to apply this optimization
  56234. * @param optimizer defines the current optimizer
  56235. * @returns true if everything that can be done was applied
  56236. */
  56237. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56238. }
  56239. /**
  56240. * Defines an optimization used to turn lens flares off
  56241. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56242. */
  56243. export class LensFlaresOptimization extends SceneOptimization {
  56244. /**
  56245. * Gets a string describing the action executed by the current optimization
  56246. * @return description string
  56247. */
  56248. getDescription(): string;
  56249. /**
  56250. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56251. * @param scene defines the current scene where to apply this optimization
  56252. * @param optimizer defines the current optimizer
  56253. * @returns true if everything that can be done was applied
  56254. */
  56255. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56256. }
  56257. /**
  56258. * Defines an optimization based on user defined callback.
  56259. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56260. */
  56261. export class CustomOptimization extends SceneOptimization {
  56262. /**
  56263. * Callback called to apply the custom optimization.
  56264. */
  56265. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56266. /**
  56267. * Callback called to get custom description
  56268. */
  56269. onGetDescription: () => string;
  56270. /**
  56271. * Gets a string describing the action executed by the current optimization
  56272. * @returns description string
  56273. */
  56274. getDescription(): string;
  56275. /**
  56276. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56277. * @param scene defines the current scene where to apply this optimization
  56278. * @param optimizer defines the current optimizer
  56279. * @returns true if everything that can be done was applied
  56280. */
  56281. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56282. }
  56283. /**
  56284. * Defines an optimization used to turn particles off
  56285. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56286. */
  56287. export class ParticlesOptimization extends SceneOptimization {
  56288. /**
  56289. * Gets a string describing the action executed by the current optimization
  56290. * @return description string
  56291. */
  56292. getDescription(): string;
  56293. /**
  56294. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56295. * @param scene defines the current scene where to apply this optimization
  56296. * @param optimizer defines the current optimizer
  56297. * @returns true if everything that can be done was applied
  56298. */
  56299. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56300. }
  56301. /**
  56302. * Defines an optimization used to turn render targets off
  56303. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56304. */
  56305. export class RenderTargetsOptimization extends SceneOptimization {
  56306. /**
  56307. * Gets a string describing the action executed by the current optimization
  56308. * @return description string
  56309. */
  56310. getDescription(): string;
  56311. /**
  56312. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56313. * @param scene defines the current scene where to apply this optimization
  56314. * @param optimizer defines the current optimizer
  56315. * @returns true if everything that can be done was applied
  56316. */
  56317. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56318. }
  56319. /**
  56320. * Defines an optimization used to merge meshes with compatible materials
  56321. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56322. */
  56323. export class MergeMeshesOptimization extends SceneOptimization {
  56324. private static _UpdateSelectionTree;
  56325. /**
  56326. * Gets or sets a boolean which defines if optimization octree has to be updated
  56327. */
  56328. /**
  56329. * Gets or sets a boolean which defines if optimization octree has to be updated
  56330. */
  56331. static UpdateSelectionTree: boolean;
  56332. /**
  56333. * Gets a string describing the action executed by the current optimization
  56334. * @return description string
  56335. */
  56336. getDescription(): string;
  56337. private _canBeMerged;
  56338. /**
  56339. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56340. * @param scene defines the current scene where to apply this optimization
  56341. * @param optimizer defines the current optimizer
  56342. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56343. * @returns true if everything that can be done was applied
  56344. */
  56345. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56346. }
  56347. /**
  56348. * Defines a list of options used by SceneOptimizer
  56349. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56350. */
  56351. export class SceneOptimizerOptions {
  56352. /**
  56353. * Defines the target frame rate to reach (60 by default)
  56354. */
  56355. targetFrameRate: number;
  56356. /**
  56357. * Defines the interval between two checkes (2000ms by default)
  56358. */
  56359. trackerDuration: number;
  56360. /**
  56361. * Gets the list of optimizations to apply
  56362. */
  56363. optimizations: SceneOptimization[];
  56364. /**
  56365. * Creates a new list of options used by SceneOptimizer
  56366. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56367. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56368. */
  56369. constructor(
  56370. /**
  56371. * Defines the target frame rate to reach (60 by default)
  56372. */
  56373. targetFrameRate?: number,
  56374. /**
  56375. * Defines the interval between two checkes (2000ms by default)
  56376. */
  56377. trackerDuration?: number);
  56378. /**
  56379. * Add a new optimization
  56380. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56381. * @returns the current SceneOptimizerOptions
  56382. */
  56383. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56384. /**
  56385. * Add a new custom optimization
  56386. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56387. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56388. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56389. * @returns the current SceneOptimizerOptions
  56390. */
  56391. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56392. /**
  56393. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56394. * @param targetFrameRate defines the target frame rate (60 by default)
  56395. * @returns a SceneOptimizerOptions object
  56396. */
  56397. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56398. /**
  56399. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56400. * @param targetFrameRate defines the target frame rate (60 by default)
  56401. * @returns a SceneOptimizerOptions object
  56402. */
  56403. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56404. /**
  56405. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56406. * @param targetFrameRate defines the target frame rate (60 by default)
  56407. * @returns a SceneOptimizerOptions object
  56408. */
  56409. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56410. }
  56411. /**
  56412. * Class used to run optimizations in order to reach a target frame rate
  56413. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56414. */
  56415. export class SceneOptimizer implements IDisposable {
  56416. private _isRunning;
  56417. private _options;
  56418. private _scene;
  56419. private _currentPriorityLevel;
  56420. private _targetFrameRate;
  56421. private _trackerDuration;
  56422. private _currentFrameRate;
  56423. private _sceneDisposeObserver;
  56424. private _improvementMode;
  56425. /**
  56426. * Defines an observable called when the optimizer reaches the target frame rate
  56427. */
  56428. onSuccessObservable: Observable<SceneOptimizer>;
  56429. /**
  56430. * Defines an observable called when the optimizer enables an optimization
  56431. */
  56432. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56433. /**
  56434. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56435. */
  56436. onFailureObservable: Observable<SceneOptimizer>;
  56437. /**
  56438. * Gets a boolean indicating if the optimizer is in improvement mode
  56439. */
  56440. readonly isInImprovementMode: boolean;
  56441. /**
  56442. * Gets the current priority level (0 at start)
  56443. */
  56444. readonly currentPriorityLevel: number;
  56445. /**
  56446. * Gets the current frame rate checked by the SceneOptimizer
  56447. */
  56448. readonly currentFrameRate: number;
  56449. /**
  56450. * Gets or sets the current target frame rate (60 by default)
  56451. */
  56452. /**
  56453. * Gets or sets the current target frame rate (60 by default)
  56454. */
  56455. targetFrameRate: number;
  56456. /**
  56457. * Gets or sets the current interval between two checks (every 2000ms by default)
  56458. */
  56459. /**
  56460. * Gets or sets the current interval between two checks (every 2000ms by default)
  56461. */
  56462. trackerDuration: number;
  56463. /**
  56464. * Gets the list of active optimizations
  56465. */
  56466. readonly optimizations: SceneOptimization[];
  56467. /**
  56468. * Creates a new SceneOptimizer
  56469. * @param scene defines the scene to work on
  56470. * @param options defines the options to use with the SceneOptimizer
  56471. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56472. * @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)
  56473. */
  56474. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56475. /**
  56476. * Stops the current optimizer
  56477. */
  56478. stop(): void;
  56479. /**
  56480. * Reset the optimizer to initial step (current priority level = 0)
  56481. */
  56482. reset(): void;
  56483. /**
  56484. * Start the optimizer. By default it will try to reach a specific framerate
  56485. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56486. */
  56487. start(): void;
  56488. private _checkCurrentState;
  56489. /**
  56490. * Release all resources
  56491. */
  56492. dispose(): void;
  56493. /**
  56494. * Helper function to create a SceneOptimizer with one single line of code
  56495. * @param scene defines the scene to work on
  56496. * @param options defines the options to use with the SceneOptimizer
  56497. * @param onSuccess defines a callback to call on success
  56498. * @param onFailure defines a callback to call on failure
  56499. * @returns the new SceneOptimizer object
  56500. */
  56501. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56502. }
  56503. }
  56504. declare module "babylonjs/Misc/sceneSerializer" {
  56505. import { Scene } from "babylonjs/scene";
  56506. /**
  56507. * Class used to serialize a scene into a string
  56508. */
  56509. export class SceneSerializer {
  56510. /**
  56511. * Clear cache used by a previous serialization
  56512. */
  56513. static ClearCache(): void;
  56514. /**
  56515. * Serialize a scene into a JSON compatible object
  56516. * @param scene defines the scene to serialize
  56517. * @returns a JSON compatible object
  56518. */
  56519. static Serialize(scene: Scene): any;
  56520. /**
  56521. * Serialize a mesh into a JSON compatible object
  56522. * @param toSerialize defines the mesh to serialize
  56523. * @param withParents defines if parents must be serialized as well
  56524. * @param withChildren defines if children must be serialized as well
  56525. * @returns a JSON compatible object
  56526. */
  56527. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56528. }
  56529. }
  56530. declare module "babylonjs/Misc/videoRecorder" {
  56531. import { Nullable } from "babylonjs/types";
  56532. import { Engine } from "babylonjs/Engines/engine";
  56533. /**
  56534. * This represents the different options avilable for the video capture.
  56535. */
  56536. export interface VideoRecorderOptions {
  56537. /** Defines the mime type of the video */
  56538. mimeType: string;
  56539. /** Defines the video the video should be recorded at */
  56540. fps: number;
  56541. /** Defines the chunk size for the recording data */
  56542. recordChunckSize: number;
  56543. /** The audio tracks to attach to the record */
  56544. audioTracks?: MediaStreamTrack[];
  56545. }
  56546. /**
  56547. * This can helps recording videos from BabylonJS.
  56548. * This is based on the available WebRTC functionalities of the browser.
  56549. *
  56550. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56551. */
  56552. export class VideoRecorder {
  56553. private static readonly _defaultOptions;
  56554. /**
  56555. * Returns wehther or not the VideoRecorder is available in your browser.
  56556. * @param engine Defines the Babylon Engine to check the support for
  56557. * @returns true if supported otherwise false
  56558. */
  56559. static IsSupported(engine: Engine): boolean;
  56560. private readonly _options;
  56561. private _canvas;
  56562. private _mediaRecorder;
  56563. private _recordedChunks;
  56564. private _fileName;
  56565. private _resolve;
  56566. private _reject;
  56567. /**
  56568. * True wether a recording is already in progress.
  56569. */
  56570. readonly isRecording: boolean;
  56571. /**
  56572. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56573. * a video file.
  56574. * @param engine Defines the BabylonJS Engine you wish to record
  56575. * @param options Defines options that can be used to customized the capture
  56576. */
  56577. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56578. /**
  56579. * Stops the current recording before the default capture timeout passed in the startRecording
  56580. * functions.
  56581. */
  56582. stopRecording(): void;
  56583. /**
  56584. * Starts recording the canvas for a max duration specified in parameters.
  56585. * @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.
  56586. * @param maxDuration Defines the maximum recording time in seconds.
  56587. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56588. * @return a promise callback at the end of the recording with the video data in Blob.
  56589. */
  56590. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56591. /**
  56592. * Releases internal resources used during the recording.
  56593. */
  56594. dispose(): void;
  56595. private _handleDataAvailable;
  56596. private _handleError;
  56597. private _handleStop;
  56598. }
  56599. }
  56600. declare module "babylonjs/Misc/workerPool" {
  56601. import { IDisposable } from "babylonjs/scene";
  56602. /**
  56603. * Helper class to push actions to a pool of workers.
  56604. */
  56605. export class WorkerPool implements IDisposable {
  56606. private _workerInfos;
  56607. private _pendingActions;
  56608. /**
  56609. * Constructor
  56610. * @param workers Array of workers to use for actions
  56611. */
  56612. constructor(workers: Array<Worker>);
  56613. /**
  56614. * Terminates all workers and clears any pending actions.
  56615. */
  56616. dispose(): void;
  56617. /**
  56618. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56619. * pended until a worker has completed its action.
  56620. * @param action The action to perform. Call onComplete when the action is complete.
  56621. */
  56622. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56623. private _execute;
  56624. }
  56625. }
  56626. declare module "babylonjs/Misc/screenshotTools" {
  56627. import { Camera } from "babylonjs/Cameras/camera";
  56628. import { Engine } from "babylonjs/Engines/engine";
  56629. /**
  56630. * Class containing a set of static utilities functions for screenshots
  56631. */
  56632. export class ScreenshotTools {
  56633. /**
  56634. * Captures a screenshot of the current rendering
  56635. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56636. * @param engine defines the rendering engine
  56637. * @param camera defines the source camera
  56638. * @param size This parameter can be set to a single number or to an object with the
  56639. * following (optional) properties: precision, width, height. If a single number is passed,
  56640. * it will be used for both width and height. If an object is passed, the screenshot size
  56641. * will be derived from the parameters. The precision property is a multiplier allowing
  56642. * rendering at a higher or lower resolution
  56643. * @param successCallback defines the callback receives a single parameter which contains the
  56644. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56645. * src parameter of an <img> to display it
  56646. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56647. * Check your browser for supported MIME types
  56648. */
  56649. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56650. /**
  56651. * Generates an image screenshot from the specified camera.
  56652. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56653. * @param engine The engine to use for rendering
  56654. * @param camera The camera to use for rendering
  56655. * @param size This parameter can be set to a single number or to an object with the
  56656. * following (optional) properties: precision, width, height. If a single number is passed,
  56657. * it will be used for both width and height. If an object is passed, the screenshot size
  56658. * will be derived from the parameters. The precision property is a multiplier allowing
  56659. * rendering at a higher or lower resolution
  56660. * @param successCallback The callback receives a single parameter which contains the
  56661. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56662. * src parameter of an <img> to display it
  56663. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56664. * Check your browser for supported MIME types
  56665. * @param samples Texture samples (default: 1)
  56666. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56667. * @param fileName A name for for the downloaded file.
  56668. */
  56669. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56670. }
  56671. }
  56672. declare module "babylonjs/Misc/index" {
  56673. export * from "babylonjs/Misc/andOrNotEvaluator";
  56674. export * from "babylonjs/Misc/assetsManager";
  56675. export * from "babylonjs/Misc/dds";
  56676. export * from "babylonjs/Misc/decorators";
  56677. export * from "babylonjs/Misc/deferred";
  56678. export * from "babylonjs/Misc/environmentTextureTools";
  56679. export * from "babylonjs/Misc/filesInput";
  56680. export * from "babylonjs/Misc/HighDynamicRange/index";
  56681. export * from "babylonjs/Misc/khronosTextureContainer";
  56682. export * from "babylonjs/Misc/observable";
  56683. export * from "babylonjs/Misc/performanceMonitor";
  56684. export * from "babylonjs/Misc/promise";
  56685. export * from "babylonjs/Misc/sceneOptimizer";
  56686. export * from "babylonjs/Misc/sceneSerializer";
  56687. export * from "babylonjs/Misc/smartArray";
  56688. export * from "babylonjs/Misc/stringDictionary";
  56689. export * from "babylonjs/Misc/tags";
  56690. export * from "babylonjs/Misc/textureTools";
  56691. export * from "babylonjs/Misc/tga";
  56692. export * from "babylonjs/Misc/tools";
  56693. export * from "babylonjs/Misc/videoRecorder";
  56694. export * from "babylonjs/Misc/virtualJoystick";
  56695. export * from "babylonjs/Misc/workerPool";
  56696. export * from "babylonjs/Misc/logger";
  56697. export * from "babylonjs/Misc/typeStore";
  56698. export * from "babylonjs/Misc/filesInputStore";
  56699. export * from "babylonjs/Misc/deepCopier";
  56700. export * from "babylonjs/Misc/pivotTools";
  56701. export * from "babylonjs/Misc/precisionDate";
  56702. export * from "babylonjs/Misc/screenshotTools";
  56703. export * from "babylonjs/Misc/typeStore";
  56704. }
  56705. declare module "babylonjs/index" {
  56706. export * from "babylonjs/abstractScene";
  56707. export * from "babylonjs/Actions/index";
  56708. export * from "babylonjs/Animations/index";
  56709. export * from "babylonjs/assetContainer";
  56710. export * from "babylonjs/Audio/index";
  56711. export * from "babylonjs/Behaviors/index";
  56712. export * from "babylonjs/Bones/index";
  56713. export * from "babylonjs/Cameras/index";
  56714. export * from "babylonjs/Collisions/index";
  56715. export * from "babylonjs/Culling/index";
  56716. export * from "babylonjs/Debug/index";
  56717. export * from "babylonjs/Engines/index";
  56718. export * from "babylonjs/Events/index";
  56719. export * from "babylonjs/Gamepads/index";
  56720. export * from "babylonjs/Gizmos/index";
  56721. export * from "babylonjs/Helpers/index";
  56722. export * from "babylonjs/Instrumentation/index";
  56723. export * from "babylonjs/Layers/index";
  56724. export * from "babylonjs/LensFlares/index";
  56725. export * from "babylonjs/Lights/index";
  56726. export * from "babylonjs/Loading/index";
  56727. export * from "babylonjs/Materials/index";
  56728. export * from "babylonjs/Maths/index";
  56729. export * from "babylonjs/Meshes/index";
  56730. export * from "babylonjs/Morph/index";
  56731. export * from "babylonjs/node";
  56732. export * from "babylonjs/Offline/index";
  56733. export * from "babylonjs/Particles/index";
  56734. export * from "babylonjs/Physics/index";
  56735. export * from "babylonjs/PostProcesses/index";
  56736. export * from "babylonjs/Probes/index";
  56737. export * from "babylonjs/Rendering/index";
  56738. export * from "babylonjs/scene";
  56739. export * from "babylonjs/sceneComponent";
  56740. export * from "babylonjs/Sprites/index";
  56741. export * from "babylonjs/States/index";
  56742. export * from "babylonjs/Misc/index";
  56743. export * from "babylonjs/types";
  56744. }
  56745. declare module "babylonjs/Animations/pathCursor" {
  56746. import { Path2, Vector3 } from "babylonjs/Maths/math";
  56747. /**
  56748. * A cursor which tracks a point on a path
  56749. */
  56750. export class PathCursor {
  56751. private path;
  56752. /**
  56753. * Stores path cursor callbacks for when an onchange event is triggered
  56754. */
  56755. private _onchange;
  56756. /**
  56757. * The value of the path cursor
  56758. */
  56759. value: number;
  56760. /**
  56761. * The animation array of the path cursor
  56762. */
  56763. animations: Animation[];
  56764. /**
  56765. * Initializes the path cursor
  56766. * @param path The path to track
  56767. */
  56768. constructor(path: Path2);
  56769. /**
  56770. * Gets the cursor point on the path
  56771. * @returns A point on the path cursor at the cursor location
  56772. */
  56773. getPoint(): Vector3;
  56774. /**
  56775. * Moves the cursor ahead by the step amount
  56776. * @param step The amount to move the cursor forward
  56777. * @returns This path cursor
  56778. */
  56779. moveAhead(step?: number): PathCursor;
  56780. /**
  56781. * Moves the cursor behind by the step amount
  56782. * @param step The amount to move the cursor back
  56783. * @returns This path cursor
  56784. */
  56785. moveBack(step?: number): PathCursor;
  56786. /**
  56787. * Moves the cursor by the step amount
  56788. * If the step amount is greater than one, an exception is thrown
  56789. * @param step The amount to move the cursor
  56790. * @returns This path cursor
  56791. */
  56792. move(step: number): PathCursor;
  56793. /**
  56794. * Ensures that the value is limited between zero and one
  56795. * @returns This path cursor
  56796. */
  56797. private ensureLimits;
  56798. /**
  56799. * Runs onchange callbacks on change (used by the animation engine)
  56800. * @returns This path cursor
  56801. */
  56802. private raiseOnChange;
  56803. /**
  56804. * Executes a function on change
  56805. * @param f A path cursor onchange callback
  56806. * @returns This path cursor
  56807. */
  56808. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56809. }
  56810. }
  56811. declare module "babylonjs/Legacy/legacy" {
  56812. export * from "babylonjs/index";
  56813. }
  56814. declare module "babylonjs/Shaders/blur.fragment" {
  56815. /** @hidden */
  56816. export var blurPixelShader: {
  56817. name: string;
  56818. shader: string;
  56819. };
  56820. }
  56821. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  56822. /** @hidden */
  56823. export var bones300Declaration: {
  56824. name: string;
  56825. shader: string;
  56826. };
  56827. }
  56828. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  56829. /** @hidden */
  56830. export var instances300Declaration: {
  56831. name: string;
  56832. shader: string;
  56833. };
  56834. }
  56835. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  56836. /** @hidden */
  56837. export var pointCloudVertexDeclaration: {
  56838. name: string;
  56839. shader: string;
  56840. };
  56841. }
  56842. // Mixins
  56843. interface Window {
  56844. mozIndexedDB: IDBFactory;
  56845. webkitIndexedDB: IDBFactory;
  56846. msIndexedDB: IDBFactory;
  56847. webkitURL: typeof URL;
  56848. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56849. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56850. WebGLRenderingContext: WebGLRenderingContext;
  56851. MSGesture: MSGesture;
  56852. CANNON: any;
  56853. AudioContext: AudioContext;
  56854. webkitAudioContext: AudioContext;
  56855. PointerEvent: any;
  56856. Math: Math;
  56857. Uint8Array: Uint8ArrayConstructor;
  56858. Float32Array: Float32ArrayConstructor;
  56859. mozURL: typeof URL;
  56860. msURL: typeof URL;
  56861. VRFrameData: any; // WebVR, from specs 1.1
  56862. DracoDecoderModule: any;
  56863. setImmediate(handler: (...args: any[]) => void): number;
  56864. }
  56865. interface Document {
  56866. mozCancelFullScreen(): void;
  56867. msCancelFullScreen(): void;
  56868. webkitCancelFullScreen(): void;
  56869. requestPointerLock(): void;
  56870. exitPointerLock(): void;
  56871. mozFullScreen: boolean;
  56872. msIsFullScreen: boolean;
  56873. readonly webkitIsFullScreen: boolean;
  56874. readonly pointerLockElement: Element;
  56875. mozPointerLockElement: HTMLElement;
  56876. msPointerLockElement: HTMLElement;
  56877. webkitPointerLockElement: HTMLElement;
  56878. }
  56879. interface HTMLCanvasElement {
  56880. requestPointerLock(): void;
  56881. msRequestPointerLock?(): void;
  56882. mozRequestPointerLock?(): void;
  56883. webkitRequestPointerLock?(): void;
  56884. /** Track wether a record is in progress */
  56885. isRecording: boolean;
  56886. /** Capture Stream method defined by some browsers */
  56887. captureStream(fps?: number): MediaStream;
  56888. }
  56889. interface CanvasRenderingContext2D {
  56890. msImageSmoothingEnabled: boolean;
  56891. }
  56892. interface MouseEvent {
  56893. mozMovementX: number;
  56894. mozMovementY: number;
  56895. webkitMovementX: number;
  56896. webkitMovementY: number;
  56897. msMovementX: number;
  56898. msMovementY: number;
  56899. }
  56900. interface Navigator {
  56901. mozGetVRDevices: (any: any) => any;
  56902. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56903. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56904. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56905. webkitGetGamepads(): Gamepad[];
  56906. msGetGamepads(): Gamepad[];
  56907. webkitGamepads(): Gamepad[];
  56908. }
  56909. interface HTMLVideoElement {
  56910. mozSrcObject: any;
  56911. }
  56912. interface Math {
  56913. fround(x: number): number;
  56914. imul(a: number, b: number): number;
  56915. }
  56916. interface WebGLProgram {
  56917. context?: WebGLRenderingContext;
  56918. vertexShader?: WebGLShader;
  56919. fragmentShader?: WebGLShader;
  56920. isParallelCompiled: boolean;
  56921. onCompiled?: () => void;
  56922. }
  56923. interface WebGLRenderingContext {
  56924. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56925. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56926. vertexAttribDivisor(index: number, divisor: number): void;
  56927. createVertexArray(): any;
  56928. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56929. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56930. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56931. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56932. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56933. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56934. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56935. // Queries
  56936. createQuery(): WebGLQuery;
  56937. deleteQuery(query: WebGLQuery): void;
  56938. beginQuery(target: number, query: WebGLQuery): void;
  56939. endQuery(target: number): void;
  56940. getQueryParameter(query: WebGLQuery, pname: number): any;
  56941. getQuery(target: number, pname: number): any;
  56942. MAX_SAMPLES: number;
  56943. RGBA8: number;
  56944. READ_FRAMEBUFFER: number;
  56945. DRAW_FRAMEBUFFER: number;
  56946. UNIFORM_BUFFER: number;
  56947. HALF_FLOAT_OES: number;
  56948. RGBA16F: number;
  56949. RGBA32F: number;
  56950. R32F: number;
  56951. RG32F: number;
  56952. RGB32F: number;
  56953. R16F: number;
  56954. RG16F: number;
  56955. RGB16F: number;
  56956. RED: number;
  56957. RG: number;
  56958. R8: number;
  56959. RG8: number;
  56960. UNSIGNED_INT_24_8: number;
  56961. DEPTH24_STENCIL8: number;
  56962. /* Multiple Render Targets */
  56963. drawBuffers(buffers: number[]): void;
  56964. readBuffer(src: number): void;
  56965. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  56966. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  56967. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  56968. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56969. // Occlusion Query
  56970. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56971. ANY_SAMPLES_PASSED: number;
  56972. QUERY_RESULT_AVAILABLE: number;
  56973. QUERY_RESULT: number;
  56974. }
  56975. interface WebGLBuffer {
  56976. references: number;
  56977. capacity: number;
  56978. is32Bits: boolean;
  56979. }
  56980. interface WebGLProgram {
  56981. transformFeedback?: WebGLTransformFeedback | null;
  56982. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56983. }
  56984. interface EXT_disjoint_timer_query {
  56985. QUERY_COUNTER_BITS_EXT: number;
  56986. TIME_ELAPSED_EXT: number;
  56987. TIMESTAMP_EXT: number;
  56988. GPU_DISJOINT_EXT: number;
  56989. QUERY_RESULT_EXT: number;
  56990. QUERY_RESULT_AVAILABLE_EXT: number;
  56991. queryCounterEXT(query: WebGLQuery, target: number): void;
  56992. createQueryEXT(): WebGLQuery;
  56993. beginQueryEXT(target: number, query: WebGLQuery): void;
  56994. endQueryEXT(target: number): void;
  56995. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56996. deleteQueryEXT(query: WebGLQuery): void;
  56997. }
  56998. interface WebGLUniformLocation {
  56999. _currentState: any;
  57000. }
  57001. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  57002. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  57003. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  57004. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57005. interface WebGLRenderingContext {
  57006. readonly RASTERIZER_DISCARD: number;
  57007. readonly DEPTH_COMPONENT24: number;
  57008. readonly TEXTURE_3D: number;
  57009. readonly TEXTURE_2D_ARRAY: number;
  57010. readonly TEXTURE_COMPARE_FUNC: number;
  57011. readonly TEXTURE_COMPARE_MODE: number;
  57012. readonly COMPARE_REF_TO_TEXTURE: number;
  57013. readonly TEXTURE_WRAP_R: number;
  57014. readonly HALF_FLOAT: number;
  57015. readonly RGB8: number;
  57016. readonly RED_INTEGER: number;
  57017. readonly RG_INTEGER: number;
  57018. readonly RGB_INTEGER: number;
  57019. readonly RGBA_INTEGER: number;
  57020. readonly R8_SNORM: number;
  57021. readonly RG8_SNORM: number;
  57022. readonly RGB8_SNORM: number;
  57023. readonly RGBA8_SNORM: number;
  57024. readonly R8I: number;
  57025. readonly RG8I: number;
  57026. readonly RGB8I: number;
  57027. readonly RGBA8I: number;
  57028. readonly R8UI: number;
  57029. readonly RG8UI: number;
  57030. readonly RGB8UI: number;
  57031. readonly RGBA8UI: number;
  57032. readonly R16I: number;
  57033. readonly RG16I: number;
  57034. readonly RGB16I: number;
  57035. readonly RGBA16I: number;
  57036. readonly R16UI: number;
  57037. readonly RG16UI: number;
  57038. readonly RGB16UI: number;
  57039. readonly RGBA16UI: number;
  57040. readonly R32I: number;
  57041. readonly RG32I: number;
  57042. readonly RGB32I: number;
  57043. readonly RGBA32I: number;
  57044. readonly R32UI: number;
  57045. readonly RG32UI: number;
  57046. readonly RGB32UI: number;
  57047. readonly RGBA32UI: number;
  57048. readonly RGB10_A2UI: number;
  57049. readonly R11F_G11F_B10F: number;
  57050. readonly RGB9_E5: number;
  57051. readonly RGB10_A2: number;
  57052. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  57053. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  57054. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  57055. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  57056. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  57057. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  57058. 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;
  57059. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  57060. readonly TRANSFORM_FEEDBACK: number;
  57061. readonly INTERLEAVED_ATTRIBS: number;
  57062. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  57063. createTransformFeedback(): WebGLTransformFeedback;
  57064. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  57065. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  57066. beginTransformFeedback(primitiveMode: number): void;
  57067. endTransformFeedback(): void;
  57068. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  57069. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57070. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57071. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57072. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  57073. }
  57074. interface ImageBitmap {
  57075. readonly width: number;
  57076. readonly height: number;
  57077. close(): void;
  57078. }
  57079. interface WebGLQuery extends WebGLObject {
  57080. }
  57081. declare var WebGLQuery: {
  57082. prototype: WebGLQuery;
  57083. new(): WebGLQuery;
  57084. };
  57085. interface WebGLSampler extends WebGLObject {
  57086. }
  57087. declare var WebGLSampler: {
  57088. prototype: WebGLSampler;
  57089. new(): WebGLSampler;
  57090. };
  57091. interface WebGLSync extends WebGLObject {
  57092. }
  57093. declare var WebGLSync: {
  57094. prototype: WebGLSync;
  57095. new(): WebGLSync;
  57096. };
  57097. interface WebGLTransformFeedback extends WebGLObject {
  57098. }
  57099. declare var WebGLTransformFeedback: {
  57100. prototype: WebGLTransformFeedback;
  57101. new(): WebGLTransformFeedback;
  57102. };
  57103. interface WebGLVertexArrayObject extends WebGLObject {
  57104. }
  57105. declare var WebGLVertexArrayObject: {
  57106. prototype: WebGLVertexArrayObject;
  57107. new(): WebGLVertexArrayObject;
  57108. };
  57109. // Type definitions for WebVR API
  57110. // Project: https://w3c.github.io/webvr/
  57111. // Definitions by: six a <https://github.com/lostfictions>
  57112. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57113. interface VRDisplay extends EventTarget {
  57114. /**
  57115. * Dictionary of capabilities describing the VRDisplay.
  57116. */
  57117. readonly capabilities: VRDisplayCapabilities;
  57118. /**
  57119. * z-depth defining the far plane of the eye view frustum
  57120. * enables mapping of values in the render target depth
  57121. * attachment to scene coordinates. Initially set to 10000.0.
  57122. */
  57123. depthFar: number;
  57124. /**
  57125. * z-depth defining the near plane of the eye view frustum
  57126. * enables mapping of values in the render target depth
  57127. * attachment to scene coordinates. Initially set to 0.01.
  57128. */
  57129. depthNear: number;
  57130. /**
  57131. * An identifier for this distinct VRDisplay. Used as an
  57132. * association point in the Gamepad API.
  57133. */
  57134. readonly displayId: number;
  57135. /**
  57136. * A display name, a user-readable name identifying it.
  57137. */
  57138. readonly displayName: string;
  57139. readonly isConnected: boolean;
  57140. readonly isPresenting: boolean;
  57141. /**
  57142. * If this VRDisplay supports room-scale experiences, the optional
  57143. * stage attribute contains details on the room-scale parameters.
  57144. */
  57145. readonly stageParameters: VRStageParameters | null;
  57146. /**
  57147. * Passing the value returned by `requestAnimationFrame` to
  57148. * `cancelAnimationFrame` will unregister the callback.
  57149. * @param handle Define the hanle of the request to cancel
  57150. */
  57151. cancelAnimationFrame(handle: number): void;
  57152. /**
  57153. * Stops presenting to the VRDisplay.
  57154. * @returns a promise to know when it stopped
  57155. */
  57156. exitPresent(): Promise<void>;
  57157. /**
  57158. * Return the current VREyeParameters for the given eye.
  57159. * @param whichEye Define the eye we want the parameter for
  57160. * @returns the eye parameters
  57161. */
  57162. getEyeParameters(whichEye: string): VREyeParameters;
  57163. /**
  57164. * Populates the passed VRFrameData with the information required to render
  57165. * the current frame.
  57166. * @param frameData Define the data structure to populate
  57167. * @returns true if ok otherwise false
  57168. */
  57169. getFrameData(frameData: VRFrameData): boolean;
  57170. /**
  57171. * Get the layers currently being presented.
  57172. * @returns the list of VR layers
  57173. */
  57174. getLayers(): VRLayer[];
  57175. /**
  57176. * Return a VRPose containing the future predicted pose of the VRDisplay
  57177. * when the current frame will be presented. The value returned will not
  57178. * change until JavaScript has returned control to the browser.
  57179. *
  57180. * The VRPose will contain the position, orientation, velocity,
  57181. * and acceleration of each of these properties.
  57182. * @returns the pose object
  57183. */
  57184. getPose(): VRPose;
  57185. /**
  57186. * Return the current instantaneous pose of the VRDisplay, with no
  57187. * prediction applied.
  57188. * @returns the current instantaneous pose
  57189. */
  57190. getImmediatePose(): VRPose;
  57191. /**
  57192. * The callback passed to `requestAnimationFrame` will be called
  57193. * any time a new frame should be rendered. When the VRDisplay is
  57194. * presenting the callback will be called at the native refresh
  57195. * rate of the HMD. When not presenting this function acts
  57196. * identically to how window.requestAnimationFrame acts. Content should
  57197. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57198. * asynchronously from other displays and at differing refresh rates.
  57199. * @param callback Define the eaction to run next frame
  57200. * @returns the request handle it
  57201. */
  57202. requestAnimationFrame(callback: FrameRequestCallback): number;
  57203. /**
  57204. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57205. * Repeat calls while already presenting will update the VRLayers being displayed.
  57206. * @param layers Define the list of layer to present
  57207. * @returns a promise to know when the request has been fulfilled
  57208. */
  57209. requestPresent(layers: VRLayer[]): Promise<void>;
  57210. /**
  57211. * Reset the pose for this display, treating its current position and
  57212. * orientation as the "origin/zero" values. VRPose.position,
  57213. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57214. * updated when calling resetPose(). This should be called in only
  57215. * sitting-space experiences.
  57216. */
  57217. resetPose(): void;
  57218. /**
  57219. * The VRLayer provided to the VRDisplay will be captured and presented
  57220. * in the HMD. Calling this function has the same effect on the source
  57221. * canvas as any other operation that uses its source image, and canvases
  57222. * created without preserveDrawingBuffer set to true will be cleared.
  57223. * @param pose Define the pose to submit
  57224. */
  57225. submitFrame(pose?: VRPose): void;
  57226. }
  57227. declare var VRDisplay: {
  57228. prototype: VRDisplay;
  57229. new(): VRDisplay;
  57230. };
  57231. interface VRLayer {
  57232. leftBounds?: number[] | Float32Array | null;
  57233. rightBounds?: number[] | Float32Array | null;
  57234. source?: HTMLCanvasElement | null;
  57235. }
  57236. interface VRDisplayCapabilities {
  57237. readonly canPresent: boolean;
  57238. readonly hasExternalDisplay: boolean;
  57239. readonly hasOrientation: boolean;
  57240. readonly hasPosition: boolean;
  57241. readonly maxLayers: number;
  57242. }
  57243. interface VREyeParameters {
  57244. /** @deprecated */
  57245. readonly fieldOfView: VRFieldOfView;
  57246. readonly offset: Float32Array;
  57247. readonly renderHeight: number;
  57248. readonly renderWidth: number;
  57249. }
  57250. interface VRFieldOfView {
  57251. readonly downDegrees: number;
  57252. readonly leftDegrees: number;
  57253. readonly rightDegrees: number;
  57254. readonly upDegrees: number;
  57255. }
  57256. interface VRFrameData {
  57257. readonly leftProjectionMatrix: Float32Array;
  57258. readonly leftViewMatrix: Float32Array;
  57259. readonly pose: VRPose;
  57260. readonly rightProjectionMatrix: Float32Array;
  57261. readonly rightViewMatrix: Float32Array;
  57262. readonly timestamp: number;
  57263. }
  57264. interface VRPose {
  57265. readonly angularAcceleration: Float32Array | null;
  57266. readonly angularVelocity: Float32Array | null;
  57267. readonly linearAcceleration: Float32Array | null;
  57268. readonly linearVelocity: Float32Array | null;
  57269. readonly orientation: Float32Array | null;
  57270. readonly position: Float32Array | null;
  57271. readonly timestamp: number;
  57272. }
  57273. interface VRStageParameters {
  57274. sittingToStandingTransform?: Float32Array;
  57275. sizeX?: number;
  57276. sizeY?: number;
  57277. }
  57278. interface Navigator {
  57279. getVRDisplays(): Promise<VRDisplay[]>;
  57280. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57281. }
  57282. interface Window {
  57283. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57284. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57285. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57286. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57287. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57288. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57289. }
  57290. interface Gamepad {
  57291. readonly displayId: number;
  57292. }
  57293. interface XRDevice {
  57294. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57295. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57296. }
  57297. interface XRSession {
  57298. getInputSources(): Array<any>;
  57299. baseLayer: XRWebGLLayer;
  57300. requestFrameOfReference(type: string): Promise<void>;
  57301. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57302. end(): Promise<void>;
  57303. requestAnimationFrame: Function;
  57304. addEventListener: Function;
  57305. }
  57306. interface XRSessionCreationOptions {
  57307. outputContext?: WebGLRenderingContext | null;
  57308. immersive?: boolean;
  57309. environmentIntegration?: boolean;
  57310. }
  57311. interface XRLayer {
  57312. getViewport: Function;
  57313. framebufferWidth: number;
  57314. framebufferHeight: number;
  57315. }
  57316. interface XRView {
  57317. projectionMatrix: Float32Array;
  57318. }
  57319. interface XRFrame {
  57320. getDevicePose: Function;
  57321. getInputPose: Function;
  57322. views: Array<XRView>;
  57323. baseLayer: XRLayer;
  57324. }
  57325. interface XRFrameOfReference {
  57326. }
  57327. interface XRWebGLLayer extends XRLayer {
  57328. framebuffer: WebGLFramebuffer;
  57329. }
  57330. declare var XRWebGLLayer: {
  57331. prototype: XRWebGLLayer;
  57332. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57333. };
  57334. declare module "babylonjs" {
  57335. export * from "babylonjs/Legacy/legacy";
  57336. }
  57337. declare module BABYLON {
  57338. /** Alias type for value that can be null */
  57339. export type Nullable<T> = T | null;
  57340. /**
  57341. * Alias type for number that are floats
  57342. * @ignorenaming
  57343. */
  57344. export type float = number;
  57345. /**
  57346. * Alias type for number that are doubles.
  57347. * @ignorenaming
  57348. */
  57349. export type double = number;
  57350. /**
  57351. * Alias type for number that are integer
  57352. * @ignorenaming
  57353. */
  57354. export type int = number;
  57355. /** Alias type for number array or Float32Array */
  57356. export type FloatArray = number[] | Float32Array;
  57357. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  57358. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  57359. /**
  57360. * Alias for types that can be used by a Buffer or VertexBuffer.
  57361. */
  57362. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  57363. /**
  57364. * Alias type for primitive types
  57365. * @ignorenaming
  57366. */
  57367. type Primitive = undefined | null | boolean | string | number | Function;
  57368. /**
  57369. * Type modifier to make all the properties of an object Readonly
  57370. */
  57371. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  57372. /**
  57373. * Type modifier to make all the properties of an object Readonly recursively
  57374. */
  57375. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  57376. /** @hidden */
  57377. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  57378. }
  57379. /** @hidden */
  57380. /** @hidden */
  57381. type DeepImmutableObject<T> = {
  57382. readonly [K in keyof T]: DeepImmutable<T[K]>;
  57383. };
  57384. }
  57385. declare module BABYLON {
  57386. /**
  57387. * Class containing a set of static utilities functions for arrays.
  57388. */
  57389. export class ArrayTools {
  57390. /**
  57391. * Returns an array of the given size filled with element built from the given constructor and the paramters
  57392. * @param size the number of element to construct and put in the array
  57393. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  57394. * @returns a new array filled with new objects
  57395. */
  57396. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  57397. }
  57398. }
  57399. declare module BABYLON {
  57400. /**
  57401. * Scalar computation library
  57402. */
  57403. export class Scalar {
  57404. /**
  57405. * Two pi constants convenient for computation.
  57406. */
  57407. static TwoPi: number;
  57408. /**
  57409. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57410. * @param a number
  57411. * @param b number
  57412. * @param epsilon (default = 1.401298E-45)
  57413. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57414. */
  57415. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  57416. /**
  57417. * Returns a string : the upper case translation of the number i to hexadecimal.
  57418. * @param i number
  57419. * @returns the upper case translation of the number i to hexadecimal.
  57420. */
  57421. static ToHex(i: number): string;
  57422. /**
  57423. * Returns -1 if value is negative and +1 is value is positive.
  57424. * @param value the value
  57425. * @returns the value itself if it's equal to zero.
  57426. */
  57427. static Sign(value: number): number;
  57428. /**
  57429. * Returns the value itself if it's between min and max.
  57430. * Returns min if the value is lower than min.
  57431. * Returns max if the value is greater than max.
  57432. * @param value the value to clmap
  57433. * @param min the min value to clamp to (default: 0)
  57434. * @param max the max value to clamp to (default: 1)
  57435. * @returns the clamped value
  57436. */
  57437. static Clamp(value: number, min?: number, max?: number): number;
  57438. /**
  57439. * the log2 of value.
  57440. * @param value the value to compute log2 of
  57441. * @returns the log2 of value.
  57442. */
  57443. static Log2(value: number): number;
  57444. /**
  57445. * Loops the value, so that it is never larger than length and never smaller than 0.
  57446. *
  57447. * This is similar to the modulo operator but it works with floating point numbers.
  57448. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  57449. * With t = 5 and length = 2.5, the result would be 0.0.
  57450. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  57451. * @param value the value
  57452. * @param length the length
  57453. * @returns the looped value
  57454. */
  57455. static Repeat(value: number, length: number): number;
  57456. /**
  57457. * Normalize the value between 0.0 and 1.0 using min and max values
  57458. * @param value value to normalize
  57459. * @param min max to normalize between
  57460. * @param max min to normalize between
  57461. * @returns the normalized value
  57462. */
  57463. static Normalize(value: number, min: number, max: number): number;
  57464. /**
  57465. * Denormalize the value from 0.0 and 1.0 using min and max values
  57466. * @param normalized value to denormalize
  57467. * @param min max to denormalize between
  57468. * @param max min to denormalize between
  57469. * @returns the denormalized value
  57470. */
  57471. static Denormalize(normalized: number, min: number, max: number): number;
  57472. /**
  57473. * Calculates the shortest difference between two given angles given in degrees.
  57474. * @param current current angle in degrees
  57475. * @param target target angle in degrees
  57476. * @returns the delta
  57477. */
  57478. static DeltaAngle(current: number, target: number): number;
  57479. /**
  57480. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  57481. * @param tx value
  57482. * @param length length
  57483. * @returns The returned value will move back and forth between 0 and length
  57484. */
  57485. static PingPong(tx: number, length: number): number;
  57486. /**
  57487. * Interpolates between min and max with smoothing at the limits.
  57488. *
  57489. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  57490. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  57491. * @param from from
  57492. * @param to to
  57493. * @param tx value
  57494. * @returns the smooth stepped value
  57495. */
  57496. static SmoothStep(from: number, to: number, tx: number): number;
  57497. /**
  57498. * Moves a value current towards target.
  57499. *
  57500. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  57501. * Negative values of maxDelta pushes the value away from target.
  57502. * @param current current value
  57503. * @param target target value
  57504. * @param maxDelta max distance to move
  57505. * @returns resulting value
  57506. */
  57507. static MoveTowards(current: number, target: number, maxDelta: number): number;
  57508. /**
  57509. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57510. *
  57511. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  57512. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  57513. * @param current current value
  57514. * @param target target value
  57515. * @param maxDelta max distance to move
  57516. * @returns resulting angle
  57517. */
  57518. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  57519. /**
  57520. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  57521. * @param start start value
  57522. * @param end target value
  57523. * @param amount amount to lerp between
  57524. * @returns the lerped value
  57525. */
  57526. static Lerp(start: number, end: number, amount: number): number;
  57527. /**
  57528. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57529. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  57530. * @param start start value
  57531. * @param end target value
  57532. * @param amount amount to lerp between
  57533. * @returns the lerped value
  57534. */
  57535. static LerpAngle(start: number, end: number, amount: number): number;
  57536. /**
  57537. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  57538. * @param a start value
  57539. * @param b target value
  57540. * @param value value between a and b
  57541. * @returns the inverseLerp value
  57542. */
  57543. static InverseLerp(a: number, b: number, value: number): number;
  57544. /**
  57545. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  57546. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  57547. * @param value1 spline value
  57548. * @param tangent1 spline value
  57549. * @param value2 spline value
  57550. * @param tangent2 spline value
  57551. * @param amount input value
  57552. * @returns hermite result
  57553. */
  57554. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  57555. /**
  57556. * Returns a random float number between and min and max values
  57557. * @param min min value of random
  57558. * @param max max value of random
  57559. * @returns random value
  57560. */
  57561. static RandomRange(min: number, max: number): number;
  57562. /**
  57563. * This function returns percentage of a number in a given range.
  57564. *
  57565. * RangeToPercent(40,20,60) will return 0.5 (50%)
  57566. * RangeToPercent(34,0,100) will return 0.34 (34%)
  57567. * @param number to convert to percentage
  57568. * @param min min range
  57569. * @param max max range
  57570. * @returns the percentage
  57571. */
  57572. static RangeToPercent(number: number, min: number, max: number): number;
  57573. /**
  57574. * This function returns number that corresponds to the percentage in a given range.
  57575. *
  57576. * PercentToRange(0.34,0,100) will return 34.
  57577. * @param percent to convert to number
  57578. * @param min min range
  57579. * @param max max range
  57580. * @returns the number
  57581. */
  57582. static PercentToRange(percent: number, min: number, max: number): number;
  57583. /**
  57584. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  57585. * @param angle The angle to normalize in radian.
  57586. * @return The converted angle.
  57587. */
  57588. static NormalizeRadians(angle: number): number;
  57589. }
  57590. }
  57591. declare module BABYLON {
  57592. /**
  57593. * Constant used to convert a value to gamma space
  57594. * @ignorenaming
  57595. */
  57596. export const ToGammaSpace: number;
  57597. /**
  57598. * Constant used to convert a value to linear space
  57599. * @ignorenaming
  57600. */
  57601. export const ToLinearSpace = 2.2;
  57602. /**
  57603. * Constant used to define the minimal number value in Babylon.js
  57604. * @ignorenaming
  57605. */
  57606. export const Epsilon = 0.001;
  57607. /**
  57608. * Class used to hold a RBG color
  57609. */
  57610. export class Color3 {
  57611. /**
  57612. * Defines the red component (between 0 and 1, default is 0)
  57613. */
  57614. r: number;
  57615. /**
  57616. * Defines the green component (between 0 and 1, default is 0)
  57617. */
  57618. g: number;
  57619. /**
  57620. * Defines the blue component (between 0 and 1, default is 0)
  57621. */
  57622. b: number;
  57623. /**
  57624. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  57625. * @param r defines the red component (between 0 and 1, default is 0)
  57626. * @param g defines the green component (between 0 and 1, default is 0)
  57627. * @param b defines the blue component (between 0 and 1, default is 0)
  57628. */
  57629. constructor(
  57630. /**
  57631. * Defines the red component (between 0 and 1, default is 0)
  57632. */
  57633. r?: number,
  57634. /**
  57635. * Defines the green component (between 0 and 1, default is 0)
  57636. */
  57637. g?: number,
  57638. /**
  57639. * Defines the blue component (between 0 and 1, default is 0)
  57640. */
  57641. b?: number);
  57642. /**
  57643. * Creates a string with the Color3 current values
  57644. * @returns the string representation of the Color3 object
  57645. */
  57646. toString(): string;
  57647. /**
  57648. * Returns the string "Color3"
  57649. * @returns "Color3"
  57650. */
  57651. getClassName(): string;
  57652. /**
  57653. * Compute the Color3 hash code
  57654. * @returns an unique number that can be used to hash Color3 objects
  57655. */
  57656. getHashCode(): number;
  57657. /**
  57658. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  57659. * @param array defines the array where to store the r,g,b components
  57660. * @param index defines an optional index in the target array to define where to start storing values
  57661. * @returns the current Color3 object
  57662. */
  57663. toArray(array: FloatArray, index?: number): Color3;
  57664. /**
  57665. * Returns a new Color4 object from the current Color3 and the given alpha
  57666. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  57667. * @returns a new Color4 object
  57668. */
  57669. toColor4(alpha?: number): Color4;
  57670. /**
  57671. * Returns a new array populated with 3 numeric elements : red, green and blue values
  57672. * @returns the new array
  57673. */
  57674. asArray(): number[];
  57675. /**
  57676. * Returns the luminance value
  57677. * @returns a float value
  57678. */
  57679. toLuminance(): number;
  57680. /**
  57681. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  57682. * @param otherColor defines the second operand
  57683. * @returns the new Color3 object
  57684. */
  57685. multiply(otherColor: DeepImmutable<Color3>): Color3;
  57686. /**
  57687. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  57688. * @param otherColor defines the second operand
  57689. * @param result defines the Color3 object where to store the result
  57690. * @returns the current Color3
  57691. */
  57692. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57693. /**
  57694. * Determines equality between Color3 objects
  57695. * @param otherColor defines the second operand
  57696. * @returns true if the rgb values are equal to the given ones
  57697. */
  57698. equals(otherColor: DeepImmutable<Color3>): boolean;
  57699. /**
  57700. * Determines equality between the current Color3 object and a set of r,b,g values
  57701. * @param r defines the red component to check
  57702. * @param g defines the green component to check
  57703. * @param b defines the blue component to check
  57704. * @returns true if the rgb values are equal to the given ones
  57705. */
  57706. equalsFloats(r: number, g: number, b: number): boolean;
  57707. /**
  57708. * Multiplies in place each rgb value by scale
  57709. * @param scale defines the scaling factor
  57710. * @returns the updated Color3
  57711. */
  57712. scale(scale: number): Color3;
  57713. /**
  57714. * Multiplies the rgb values by scale and stores the result into "result"
  57715. * @param scale defines the scaling factor
  57716. * @param result defines the Color3 object where to store the result
  57717. * @returns the unmodified current Color3
  57718. */
  57719. scaleToRef(scale: number, result: Color3): Color3;
  57720. /**
  57721. * Scale the current Color3 values by a factor and add the result to a given Color3
  57722. * @param scale defines the scale factor
  57723. * @param result defines color to store the result into
  57724. * @returns the unmodified current Color3
  57725. */
  57726. scaleAndAddToRef(scale: number, result: Color3): Color3;
  57727. /**
  57728. * Clamps the rgb values by the min and max values and stores the result into "result"
  57729. * @param min defines minimum clamping value (default is 0)
  57730. * @param max defines maximum clamping value (default is 1)
  57731. * @param result defines color to store the result into
  57732. * @returns the original Color3
  57733. */
  57734. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  57735. /**
  57736. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  57737. * @param otherColor defines the second operand
  57738. * @returns the new Color3
  57739. */
  57740. add(otherColor: DeepImmutable<Color3>): Color3;
  57741. /**
  57742. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  57743. * @param otherColor defines the second operand
  57744. * @param result defines Color3 object to store the result into
  57745. * @returns the unmodified current Color3
  57746. */
  57747. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57748. /**
  57749. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  57750. * @param otherColor defines the second operand
  57751. * @returns the new Color3
  57752. */
  57753. subtract(otherColor: DeepImmutable<Color3>): Color3;
  57754. /**
  57755. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  57756. * @param otherColor defines the second operand
  57757. * @param result defines Color3 object to store the result into
  57758. * @returns the unmodified current Color3
  57759. */
  57760. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57761. /**
  57762. * Copy the current object
  57763. * @returns a new Color3 copied the current one
  57764. */
  57765. clone(): Color3;
  57766. /**
  57767. * Copies the rgb values from the source in the current Color3
  57768. * @param source defines the source Color3 object
  57769. * @returns the updated Color3 object
  57770. */
  57771. copyFrom(source: DeepImmutable<Color3>): Color3;
  57772. /**
  57773. * Updates the Color3 rgb values from the given floats
  57774. * @param r defines the red component to read from
  57775. * @param g defines the green component to read from
  57776. * @param b defines the blue component to read from
  57777. * @returns the current Color3 object
  57778. */
  57779. copyFromFloats(r: number, g: number, b: number): Color3;
  57780. /**
  57781. * Updates the Color3 rgb values from the given floats
  57782. * @param r defines the red component to read from
  57783. * @param g defines the green component to read from
  57784. * @param b defines the blue component to read from
  57785. * @returns the current Color3 object
  57786. */
  57787. set(r: number, g: number, b: number): Color3;
  57788. /**
  57789. * Compute the Color3 hexadecimal code as a string
  57790. * @returns a string containing the hexadecimal representation of the Color3 object
  57791. */
  57792. toHexString(): string;
  57793. /**
  57794. * Computes a new Color3 converted from the current one to linear space
  57795. * @returns a new Color3 object
  57796. */
  57797. toLinearSpace(): Color3;
  57798. /**
  57799. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  57800. * @param convertedColor defines the Color3 object where to store the linear space version
  57801. * @returns the unmodified Color3
  57802. */
  57803. toLinearSpaceToRef(convertedColor: Color3): Color3;
  57804. /**
  57805. * Computes a new Color3 converted from the current one to gamma space
  57806. * @returns a new Color3 object
  57807. */
  57808. toGammaSpace(): Color3;
  57809. /**
  57810. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  57811. * @param convertedColor defines the Color3 object where to store the gamma space version
  57812. * @returns the unmodified Color3
  57813. */
  57814. toGammaSpaceToRef(convertedColor: Color3): Color3;
  57815. private static _BlackReadOnly;
  57816. /**
  57817. * Creates a new Color3 from the string containing valid hexadecimal values
  57818. * @param hex defines a string containing valid hexadecimal values
  57819. * @returns a new Color3 object
  57820. */
  57821. static FromHexString(hex: string): Color3;
  57822. /**
  57823. * Creates a new Vector3 from the starting index of the given array
  57824. * @param array defines the source array
  57825. * @param offset defines an offset in the source array
  57826. * @returns a new Color3 object
  57827. */
  57828. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  57829. /**
  57830. * Creates a new Color3 from integer values (< 256)
  57831. * @param r defines the red component to read from (value between 0 and 255)
  57832. * @param g defines the green component to read from (value between 0 and 255)
  57833. * @param b defines the blue component to read from (value between 0 and 255)
  57834. * @returns a new Color3 object
  57835. */
  57836. static FromInts(r: number, g: number, b: number): Color3;
  57837. /**
  57838. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57839. * @param start defines the start Color3 value
  57840. * @param end defines the end Color3 value
  57841. * @param amount defines the gradient value between start and end
  57842. * @returns a new Color3 object
  57843. */
  57844. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  57845. /**
  57846. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57847. * @param left defines the start value
  57848. * @param right defines the end value
  57849. * @param amount defines the gradient factor
  57850. * @param result defines the Color3 object where to store the result
  57851. */
  57852. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  57853. /**
  57854. * Returns a Color3 value containing a red color
  57855. * @returns a new Color3 object
  57856. */
  57857. static Red(): Color3;
  57858. /**
  57859. * Returns a Color3 value containing a green color
  57860. * @returns a new Color3 object
  57861. */
  57862. static Green(): Color3;
  57863. /**
  57864. * Returns a Color3 value containing a blue color
  57865. * @returns a new Color3 object
  57866. */
  57867. static Blue(): Color3;
  57868. /**
  57869. * Returns a Color3 value containing a black color
  57870. * @returns a new Color3 object
  57871. */
  57872. static Black(): Color3;
  57873. /**
  57874. * Gets a Color3 value containing a black color that must not be updated
  57875. */
  57876. static readonly BlackReadOnly: DeepImmutable<Color3>;
  57877. /**
  57878. * Returns a Color3 value containing a white color
  57879. * @returns a new Color3 object
  57880. */
  57881. static White(): Color3;
  57882. /**
  57883. * Returns a Color3 value containing a purple color
  57884. * @returns a new Color3 object
  57885. */
  57886. static Purple(): Color3;
  57887. /**
  57888. * Returns a Color3 value containing a magenta color
  57889. * @returns a new Color3 object
  57890. */
  57891. static Magenta(): Color3;
  57892. /**
  57893. * Returns a Color3 value containing a yellow color
  57894. * @returns a new Color3 object
  57895. */
  57896. static Yellow(): Color3;
  57897. /**
  57898. * Returns a Color3 value containing a gray color
  57899. * @returns a new Color3 object
  57900. */
  57901. static Gray(): Color3;
  57902. /**
  57903. * Returns a Color3 value containing a teal color
  57904. * @returns a new Color3 object
  57905. */
  57906. static Teal(): Color3;
  57907. /**
  57908. * Returns a Color3 value containing a random color
  57909. * @returns a new Color3 object
  57910. */
  57911. static Random(): Color3;
  57912. }
  57913. /**
  57914. * Class used to hold a RBGA color
  57915. */
  57916. export class Color4 {
  57917. /**
  57918. * Defines the red component (between 0 and 1, default is 0)
  57919. */
  57920. r: number;
  57921. /**
  57922. * Defines the green component (between 0 and 1, default is 0)
  57923. */
  57924. g: number;
  57925. /**
  57926. * Defines the blue component (between 0 and 1, default is 0)
  57927. */
  57928. b: number;
  57929. /**
  57930. * Defines the alpha component (between 0 and 1, default is 1)
  57931. */
  57932. a: number;
  57933. /**
  57934. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  57935. * @param r defines the red component (between 0 and 1, default is 0)
  57936. * @param g defines the green component (between 0 and 1, default is 0)
  57937. * @param b defines the blue component (between 0 and 1, default is 0)
  57938. * @param a defines the alpha component (between 0 and 1, default is 1)
  57939. */
  57940. constructor(
  57941. /**
  57942. * Defines the red component (between 0 and 1, default is 0)
  57943. */
  57944. r?: number,
  57945. /**
  57946. * Defines the green component (between 0 and 1, default is 0)
  57947. */
  57948. g?: number,
  57949. /**
  57950. * Defines the blue component (between 0 and 1, default is 0)
  57951. */
  57952. b?: number,
  57953. /**
  57954. * Defines the alpha component (between 0 and 1, default is 1)
  57955. */
  57956. a?: number);
  57957. /**
  57958. * Adds in place the given Color4 values to the current Color4 object
  57959. * @param right defines the second operand
  57960. * @returns the current updated Color4 object
  57961. */
  57962. addInPlace(right: DeepImmutable<Color4>): Color4;
  57963. /**
  57964. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  57965. * @returns the new array
  57966. */
  57967. asArray(): number[];
  57968. /**
  57969. * Stores from the starting index in the given array the Color4 successive values
  57970. * @param array defines the array where to store the r,g,b components
  57971. * @param index defines an optional index in the target array to define where to start storing values
  57972. * @returns the current Color4 object
  57973. */
  57974. toArray(array: number[], index?: number): Color4;
  57975. /**
  57976. * Determines equality between Color4 objects
  57977. * @param otherColor defines the second operand
  57978. * @returns true if the rgba values are equal to the given ones
  57979. */
  57980. equals(otherColor: DeepImmutable<Color4>): boolean;
  57981. /**
  57982. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  57983. * @param right defines the second operand
  57984. * @returns a new Color4 object
  57985. */
  57986. add(right: DeepImmutable<Color4>): Color4;
  57987. /**
  57988. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  57989. * @param right defines the second operand
  57990. * @returns a new Color4 object
  57991. */
  57992. subtract(right: DeepImmutable<Color4>): Color4;
  57993. /**
  57994. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  57995. * @param right defines the second operand
  57996. * @param result defines the Color4 object where to store the result
  57997. * @returns the current Color4 object
  57998. */
  57999. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  58000. /**
  58001. * Creates a new Color4 with the current Color4 values multiplied by scale
  58002. * @param scale defines the scaling factor to apply
  58003. * @returns a new Color4 object
  58004. */
  58005. scale(scale: number): Color4;
  58006. /**
  58007. * Multiplies the current Color4 values by scale and stores the result in "result"
  58008. * @param scale defines the scaling factor to apply
  58009. * @param result defines the Color4 object where to store the result
  58010. * @returns the current unmodified Color4
  58011. */
  58012. scaleToRef(scale: number, result: Color4): Color4;
  58013. /**
  58014. * Scale the current Color4 values by a factor and add the result to a given Color4
  58015. * @param scale defines the scale factor
  58016. * @param result defines the Color4 object where to store the result
  58017. * @returns the unmodified current Color4
  58018. */
  58019. scaleAndAddToRef(scale: number, result: Color4): Color4;
  58020. /**
  58021. * Clamps the rgb values by the min and max values and stores the result into "result"
  58022. * @param min defines minimum clamping value (default is 0)
  58023. * @param max defines maximum clamping value (default is 1)
  58024. * @param result defines color to store the result into.
  58025. * @returns the cuurent Color4
  58026. */
  58027. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  58028. /**
  58029. * Multipy an Color4 value by another and return a new Color4 object
  58030. * @param color defines the Color4 value to multiply by
  58031. * @returns a new Color4 object
  58032. */
  58033. multiply(color: Color4): Color4;
  58034. /**
  58035. * Multipy a Color4 value by another and push the result in a reference value
  58036. * @param color defines the Color4 value to multiply by
  58037. * @param result defines the Color4 to fill the result in
  58038. * @returns the result Color4
  58039. */
  58040. multiplyToRef(color: Color4, result: Color4): Color4;
  58041. /**
  58042. * Creates a string with the Color4 current values
  58043. * @returns the string representation of the Color4 object
  58044. */
  58045. toString(): string;
  58046. /**
  58047. * Returns the string "Color4"
  58048. * @returns "Color4"
  58049. */
  58050. getClassName(): string;
  58051. /**
  58052. * Compute the Color4 hash code
  58053. * @returns an unique number that can be used to hash Color4 objects
  58054. */
  58055. getHashCode(): number;
  58056. /**
  58057. * Creates a new Color4 copied from the current one
  58058. * @returns a new Color4 object
  58059. */
  58060. clone(): Color4;
  58061. /**
  58062. * Copies the given Color4 values into the current one
  58063. * @param source defines the source Color4 object
  58064. * @returns the current updated Color4 object
  58065. */
  58066. copyFrom(source: Color4): Color4;
  58067. /**
  58068. * Copies the given float values into the current one
  58069. * @param r defines the red component to read from
  58070. * @param g defines the green component to read from
  58071. * @param b defines the blue component to read from
  58072. * @param a defines the alpha component to read from
  58073. * @returns the current updated Color4 object
  58074. */
  58075. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  58076. /**
  58077. * Copies the given float values into the current one
  58078. * @param r defines the red component to read from
  58079. * @param g defines the green component to read from
  58080. * @param b defines the blue component to read from
  58081. * @param a defines the alpha component to read from
  58082. * @returns the current updated Color4 object
  58083. */
  58084. set(r: number, g: number, b: number, a: number): Color4;
  58085. /**
  58086. * Compute the Color4 hexadecimal code as a string
  58087. * @returns a string containing the hexadecimal representation of the Color4 object
  58088. */
  58089. toHexString(): string;
  58090. /**
  58091. * Computes a new Color4 converted from the current one to linear space
  58092. * @returns a new Color4 object
  58093. */
  58094. toLinearSpace(): Color4;
  58095. /**
  58096. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  58097. * @param convertedColor defines the Color4 object where to store the linear space version
  58098. * @returns the unmodified Color4
  58099. */
  58100. toLinearSpaceToRef(convertedColor: Color4): Color4;
  58101. /**
  58102. * Computes a new Color4 converted from the current one to gamma space
  58103. * @returns a new Color4 object
  58104. */
  58105. toGammaSpace(): Color4;
  58106. /**
  58107. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  58108. * @param convertedColor defines the Color4 object where to store the gamma space version
  58109. * @returns the unmodified Color4
  58110. */
  58111. toGammaSpaceToRef(convertedColor: Color4): Color4;
  58112. /**
  58113. * Creates a new Color4 from the string containing valid hexadecimal values
  58114. * @param hex defines a string containing valid hexadecimal values
  58115. * @returns a new Color4 object
  58116. */
  58117. static FromHexString(hex: string): Color4;
  58118. /**
  58119. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58120. * @param left defines the start value
  58121. * @param right defines the end value
  58122. * @param amount defines the gradient factor
  58123. * @returns a new Color4 object
  58124. */
  58125. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  58126. /**
  58127. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58128. * @param left defines the start value
  58129. * @param right defines the end value
  58130. * @param amount defines the gradient factor
  58131. * @param result defines the Color4 object where to store data
  58132. */
  58133. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  58134. /**
  58135. * Creates a new Color4 from a Color3 and an alpha value
  58136. * @param color3 defines the source Color3 to read from
  58137. * @param alpha defines the alpha component (1.0 by default)
  58138. * @returns a new Color4 object
  58139. */
  58140. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  58141. /**
  58142. * Creates a new Color4 from the starting index element of the given array
  58143. * @param array defines the source array to read from
  58144. * @param offset defines the offset in the source array
  58145. * @returns a new Color4 object
  58146. */
  58147. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  58148. /**
  58149. * Creates a new Color3 from integer values (< 256)
  58150. * @param r defines the red component to read from (value between 0 and 255)
  58151. * @param g defines the green component to read from (value between 0 and 255)
  58152. * @param b defines the blue component to read from (value between 0 and 255)
  58153. * @param a defines the alpha component to read from (value between 0 and 255)
  58154. * @returns a new Color3 object
  58155. */
  58156. static FromInts(r: number, g: number, b: number, a: number): Color4;
  58157. /**
  58158. * Check the content of a given array and convert it to an array containing RGBA data
  58159. * If the original array was already containing count * 4 values then it is returned directly
  58160. * @param colors defines the array to check
  58161. * @param count defines the number of RGBA data to expect
  58162. * @returns an array containing count * 4 values (RGBA)
  58163. */
  58164. static CheckColors4(colors: number[], count: number): number[];
  58165. }
  58166. /**
  58167. * Class representing a vector containing 2 coordinates
  58168. */
  58169. export class Vector2 {
  58170. /** defines the first coordinate */
  58171. x: number;
  58172. /** defines the second coordinate */
  58173. y: number;
  58174. /**
  58175. * Creates a new Vector2 from the given x and y coordinates
  58176. * @param x defines the first coordinate
  58177. * @param y defines the second coordinate
  58178. */
  58179. constructor(
  58180. /** defines the first coordinate */
  58181. x?: number,
  58182. /** defines the second coordinate */
  58183. y?: number);
  58184. /**
  58185. * Gets a string with the Vector2 coordinates
  58186. * @returns a string with the Vector2 coordinates
  58187. */
  58188. toString(): string;
  58189. /**
  58190. * Gets class name
  58191. * @returns the string "Vector2"
  58192. */
  58193. getClassName(): string;
  58194. /**
  58195. * Gets current vector hash code
  58196. * @returns the Vector2 hash code as a number
  58197. */
  58198. getHashCode(): number;
  58199. /**
  58200. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  58201. * @param array defines the source array
  58202. * @param index defines the offset in source array
  58203. * @returns the current Vector2
  58204. */
  58205. toArray(array: FloatArray, index?: number): Vector2;
  58206. /**
  58207. * Copy the current vector to an array
  58208. * @returns a new array with 2 elements: the Vector2 coordinates.
  58209. */
  58210. asArray(): number[];
  58211. /**
  58212. * Sets the Vector2 coordinates with the given Vector2 coordinates
  58213. * @param source defines the source Vector2
  58214. * @returns the current updated Vector2
  58215. */
  58216. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  58217. /**
  58218. * Sets the Vector2 coordinates with the given floats
  58219. * @param x defines the first coordinate
  58220. * @param y defines the second coordinate
  58221. * @returns the current updated Vector2
  58222. */
  58223. copyFromFloats(x: number, y: number): Vector2;
  58224. /**
  58225. * Sets the Vector2 coordinates with the given floats
  58226. * @param x defines the first coordinate
  58227. * @param y defines the second coordinate
  58228. * @returns the current updated Vector2
  58229. */
  58230. set(x: number, y: number): Vector2;
  58231. /**
  58232. * Add another vector with the current one
  58233. * @param otherVector defines the other vector
  58234. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  58235. */
  58236. add(otherVector: DeepImmutable<Vector2>): Vector2;
  58237. /**
  58238. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  58239. * @param otherVector defines the other vector
  58240. * @param result defines the target vector
  58241. * @returns the unmodified current Vector2
  58242. */
  58243. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58244. /**
  58245. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  58246. * @param otherVector defines the other vector
  58247. * @returns the current updated Vector2
  58248. */
  58249. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58250. /**
  58251. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  58252. * @param otherVector defines the other vector
  58253. * @returns a new Vector2
  58254. */
  58255. addVector3(otherVector: Vector3): Vector2;
  58256. /**
  58257. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  58258. * @param otherVector defines the other vector
  58259. * @returns a new Vector2
  58260. */
  58261. subtract(otherVector: Vector2): Vector2;
  58262. /**
  58263. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  58264. * @param otherVector defines the other vector
  58265. * @param result defines the target vector
  58266. * @returns the unmodified current Vector2
  58267. */
  58268. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58269. /**
  58270. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  58271. * @param otherVector defines the other vector
  58272. * @returns the current updated Vector2
  58273. */
  58274. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58275. /**
  58276. * Multiplies in place the current Vector2 coordinates by the given ones
  58277. * @param otherVector defines the other vector
  58278. * @returns the current updated Vector2
  58279. */
  58280. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58281. /**
  58282. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  58283. * @param otherVector defines the other vector
  58284. * @returns a new Vector2
  58285. */
  58286. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  58287. /**
  58288. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  58289. * @param otherVector defines the other vector
  58290. * @param result defines the target vector
  58291. * @returns the unmodified current Vector2
  58292. */
  58293. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58294. /**
  58295. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  58296. * @param x defines the first coordinate
  58297. * @param y defines the second coordinate
  58298. * @returns a new Vector2
  58299. */
  58300. multiplyByFloats(x: number, y: number): Vector2;
  58301. /**
  58302. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  58303. * @param otherVector defines the other vector
  58304. * @returns a new Vector2
  58305. */
  58306. divide(otherVector: Vector2): Vector2;
  58307. /**
  58308. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  58309. * @param otherVector defines the other vector
  58310. * @param result defines the target vector
  58311. * @returns the unmodified current Vector2
  58312. */
  58313. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58314. /**
  58315. * Divides the current Vector2 coordinates by the given ones
  58316. * @param otherVector defines the other vector
  58317. * @returns the current updated Vector2
  58318. */
  58319. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58320. /**
  58321. * Gets a new Vector2 with current Vector2 negated coordinates
  58322. * @returns a new Vector2
  58323. */
  58324. negate(): Vector2;
  58325. /**
  58326. * Multiply the Vector2 coordinates by scale
  58327. * @param scale defines the scaling factor
  58328. * @returns the current updated Vector2
  58329. */
  58330. scaleInPlace(scale: number): Vector2;
  58331. /**
  58332. * Returns a new Vector2 scaled by "scale" from the current Vector2
  58333. * @param scale defines the scaling factor
  58334. * @returns a new Vector2
  58335. */
  58336. scale(scale: number): Vector2;
  58337. /**
  58338. * Scale the current Vector2 values by a factor to a given Vector2
  58339. * @param scale defines the scale factor
  58340. * @param result defines the Vector2 object where to store the result
  58341. * @returns the unmodified current Vector2
  58342. */
  58343. scaleToRef(scale: number, result: Vector2): Vector2;
  58344. /**
  58345. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  58346. * @param scale defines the scale factor
  58347. * @param result defines the Vector2 object where to store the result
  58348. * @returns the unmodified current Vector2
  58349. */
  58350. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  58351. /**
  58352. * Gets a boolean if two vectors are equals
  58353. * @param otherVector defines the other vector
  58354. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  58355. */
  58356. equals(otherVector: DeepImmutable<Vector2>): boolean;
  58357. /**
  58358. * Gets a boolean if two vectors are equals (using an epsilon value)
  58359. * @param otherVector defines the other vector
  58360. * @param epsilon defines the minimal distance to consider equality
  58361. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  58362. */
  58363. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  58364. /**
  58365. * Gets a new Vector2 from current Vector2 floored values
  58366. * @returns a new Vector2
  58367. */
  58368. floor(): Vector2;
  58369. /**
  58370. * Gets a new Vector2 from current Vector2 floored values
  58371. * @returns a new Vector2
  58372. */
  58373. fract(): Vector2;
  58374. /**
  58375. * Gets the length of the vector
  58376. * @returns the vector length (float)
  58377. */
  58378. length(): number;
  58379. /**
  58380. * Gets the vector squared length
  58381. * @returns the vector squared length (float)
  58382. */
  58383. lengthSquared(): number;
  58384. /**
  58385. * Normalize the vector
  58386. * @returns the current updated Vector2
  58387. */
  58388. normalize(): Vector2;
  58389. /**
  58390. * Gets a new Vector2 copied from the Vector2
  58391. * @returns a new Vector2
  58392. */
  58393. clone(): Vector2;
  58394. /**
  58395. * Gets a new Vector2(0, 0)
  58396. * @returns a new Vector2
  58397. */
  58398. static Zero(): Vector2;
  58399. /**
  58400. * Gets a new Vector2(1, 1)
  58401. * @returns a new Vector2
  58402. */
  58403. static One(): Vector2;
  58404. /**
  58405. * Gets a new Vector2 set from the given index element of the given array
  58406. * @param array defines the data source
  58407. * @param offset defines the offset in the data source
  58408. * @returns a new Vector2
  58409. */
  58410. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  58411. /**
  58412. * Sets "result" from the given index element of the given array
  58413. * @param array defines the data source
  58414. * @param offset defines the offset in the data source
  58415. * @param result defines the target vector
  58416. */
  58417. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  58418. /**
  58419. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  58420. * @param value1 defines 1st point of control
  58421. * @param value2 defines 2nd point of control
  58422. * @param value3 defines 3rd point of control
  58423. * @param value4 defines 4th point of control
  58424. * @param amount defines the interpolation factor
  58425. * @returns a new Vector2
  58426. */
  58427. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  58428. /**
  58429. * 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".
  58430. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  58431. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  58432. * @param value defines the value to clamp
  58433. * @param min defines the lower limit
  58434. * @param max defines the upper limit
  58435. * @returns a new Vector2
  58436. */
  58437. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  58438. /**
  58439. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  58440. * @param value1 defines the 1st control point
  58441. * @param tangent1 defines the outgoing tangent
  58442. * @param value2 defines the 2nd control point
  58443. * @param tangent2 defines the incoming tangent
  58444. * @param amount defines the interpolation factor
  58445. * @returns a new Vector2
  58446. */
  58447. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  58448. /**
  58449. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  58450. * @param start defines the start vector
  58451. * @param end defines the end vector
  58452. * @param amount defines the interpolation factor
  58453. * @returns a new Vector2
  58454. */
  58455. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  58456. /**
  58457. * Gets the dot product of the vector "left" and the vector "right"
  58458. * @param left defines first vector
  58459. * @param right defines second vector
  58460. * @returns the dot product (float)
  58461. */
  58462. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  58463. /**
  58464. * Returns a new Vector2 equal to the normalized given vector
  58465. * @param vector defines the vector to normalize
  58466. * @returns a new Vector2
  58467. */
  58468. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  58469. /**
  58470. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  58471. * @param left defines 1st vector
  58472. * @param right defines 2nd vector
  58473. * @returns a new Vector2
  58474. */
  58475. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58476. /**
  58477. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  58478. * @param left defines 1st vector
  58479. * @param right defines 2nd vector
  58480. * @returns a new Vector2
  58481. */
  58482. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58483. /**
  58484. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  58485. * @param vector defines the vector to transform
  58486. * @param transformation defines the matrix to apply
  58487. * @returns a new Vector2
  58488. */
  58489. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  58490. /**
  58491. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  58492. * @param vector defines the vector to transform
  58493. * @param transformation defines the matrix to apply
  58494. * @param result defines the target vector
  58495. */
  58496. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  58497. /**
  58498. * Determines if a given vector is included in a triangle
  58499. * @param p defines the vector to test
  58500. * @param p0 defines 1st triangle point
  58501. * @param p1 defines 2nd triangle point
  58502. * @param p2 defines 3rd triangle point
  58503. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  58504. */
  58505. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  58506. /**
  58507. * Gets the distance between the vectors "value1" and "value2"
  58508. * @param value1 defines first vector
  58509. * @param value2 defines second vector
  58510. * @returns the distance between vectors
  58511. */
  58512. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58513. /**
  58514. * Returns the squared distance between the vectors "value1" and "value2"
  58515. * @param value1 defines first vector
  58516. * @param value2 defines second vector
  58517. * @returns the squared distance between vectors
  58518. */
  58519. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58520. /**
  58521. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  58522. * @param value1 defines first vector
  58523. * @param value2 defines second vector
  58524. * @returns a new Vector2
  58525. */
  58526. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  58527. /**
  58528. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  58529. * @param p defines the middle point
  58530. * @param segA defines one point of the segment
  58531. * @param segB defines the other point of the segment
  58532. * @returns the shortest distance
  58533. */
  58534. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  58535. }
  58536. /**
  58537. * Classed used to store (x,y,z) vector representation
  58538. * A Vector3 is the main object used in 3D geometry
  58539. * It can represent etiher the coordinates of a point the space, either a direction
  58540. * Reminder: js uses a left handed forward facing system
  58541. */
  58542. export class Vector3 {
  58543. /**
  58544. * Defines the first coordinates (on X axis)
  58545. */
  58546. x: number;
  58547. /**
  58548. * Defines the second coordinates (on Y axis)
  58549. */
  58550. y: number;
  58551. /**
  58552. * Defines the third coordinates (on Z axis)
  58553. */
  58554. z: number;
  58555. private static _UpReadOnly;
  58556. /**
  58557. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  58558. * @param x defines the first coordinates (on X axis)
  58559. * @param y defines the second coordinates (on Y axis)
  58560. * @param z defines the third coordinates (on Z axis)
  58561. */
  58562. constructor(
  58563. /**
  58564. * Defines the first coordinates (on X axis)
  58565. */
  58566. x?: number,
  58567. /**
  58568. * Defines the second coordinates (on Y axis)
  58569. */
  58570. y?: number,
  58571. /**
  58572. * Defines the third coordinates (on Z axis)
  58573. */
  58574. z?: number);
  58575. /**
  58576. * Creates a string representation of the Vector3
  58577. * @returns a string with the Vector3 coordinates.
  58578. */
  58579. toString(): string;
  58580. /**
  58581. * Gets the class name
  58582. * @returns the string "Vector3"
  58583. */
  58584. getClassName(): string;
  58585. /**
  58586. * Creates the Vector3 hash code
  58587. * @returns a number which tends to be unique between Vector3 instances
  58588. */
  58589. getHashCode(): number;
  58590. /**
  58591. * Creates an array containing three elements : the coordinates of the Vector3
  58592. * @returns a new array of numbers
  58593. */
  58594. asArray(): number[];
  58595. /**
  58596. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  58597. * @param array defines the destination array
  58598. * @param index defines the offset in the destination array
  58599. * @returns the current Vector3
  58600. */
  58601. toArray(array: FloatArray, index?: number): Vector3;
  58602. /**
  58603. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  58604. * @returns a new Quaternion object, computed from the Vector3 coordinates
  58605. */
  58606. toQuaternion(): Quaternion;
  58607. /**
  58608. * Adds the given vector to the current Vector3
  58609. * @param otherVector defines the second operand
  58610. * @returns the current updated Vector3
  58611. */
  58612. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58613. /**
  58614. * Adds the given coordinates to the current Vector3
  58615. * @param x defines the x coordinate of the operand
  58616. * @param y defines the y coordinate of the operand
  58617. * @param z defines the z coordinate of the operand
  58618. * @returns the current updated Vector3
  58619. */
  58620. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58621. /**
  58622. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  58623. * @param otherVector defines the second operand
  58624. * @returns the resulting Vector3
  58625. */
  58626. add(otherVector: DeepImmutable<Vector3>): Vector3;
  58627. /**
  58628. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  58629. * @param otherVector defines the second operand
  58630. * @param result defines the Vector3 object where to store the result
  58631. * @returns the current Vector3
  58632. */
  58633. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58634. /**
  58635. * Subtract the given vector from the current Vector3
  58636. * @param otherVector defines the second operand
  58637. * @returns the current updated Vector3
  58638. */
  58639. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58640. /**
  58641. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  58642. * @param otherVector defines the second operand
  58643. * @returns the resulting Vector3
  58644. */
  58645. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  58646. /**
  58647. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  58648. * @param otherVector defines the second operand
  58649. * @param result defines the Vector3 object where to store the result
  58650. * @returns the current Vector3
  58651. */
  58652. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58653. /**
  58654. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  58655. * @param x defines the x coordinate of the operand
  58656. * @param y defines the y coordinate of the operand
  58657. * @param z defines the z coordinate of the operand
  58658. * @returns the resulting Vector3
  58659. */
  58660. subtractFromFloats(x: number, y: number, z: number): Vector3;
  58661. /**
  58662. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  58663. * @param x defines the x coordinate of the operand
  58664. * @param y defines the y coordinate of the operand
  58665. * @param z defines the z coordinate of the operand
  58666. * @param result defines the Vector3 object where to store the result
  58667. * @returns the current Vector3
  58668. */
  58669. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  58670. /**
  58671. * Gets a new Vector3 set with the current Vector3 negated coordinates
  58672. * @returns a new Vector3
  58673. */
  58674. negate(): Vector3;
  58675. /**
  58676. * Multiplies the Vector3 coordinates by the float "scale"
  58677. * @param scale defines the multiplier factor
  58678. * @returns the current updated Vector3
  58679. */
  58680. scaleInPlace(scale: number): Vector3;
  58681. /**
  58682. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  58683. * @param scale defines the multiplier factor
  58684. * @returns a new Vector3
  58685. */
  58686. scale(scale: number): Vector3;
  58687. /**
  58688. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  58689. * @param scale defines the multiplier factor
  58690. * @param result defines the Vector3 object where to store the result
  58691. * @returns the current Vector3
  58692. */
  58693. scaleToRef(scale: number, result: Vector3): Vector3;
  58694. /**
  58695. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  58696. * @param scale defines the scale factor
  58697. * @param result defines the Vector3 object where to store the result
  58698. * @returns the unmodified current Vector3
  58699. */
  58700. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  58701. /**
  58702. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  58703. * @param otherVector defines the second operand
  58704. * @returns true if both vectors are equals
  58705. */
  58706. equals(otherVector: DeepImmutable<Vector3>): boolean;
  58707. /**
  58708. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  58709. * @param otherVector defines the second operand
  58710. * @param epsilon defines the minimal distance to define values as equals
  58711. * @returns true if both vectors are distant less than epsilon
  58712. */
  58713. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  58714. /**
  58715. * Returns true if the current Vector3 coordinates equals the given floats
  58716. * @param x defines the x coordinate of the operand
  58717. * @param y defines the y coordinate of the operand
  58718. * @param z defines the z coordinate of the operand
  58719. * @returns true if both vectors are equals
  58720. */
  58721. equalsToFloats(x: number, y: number, z: number): boolean;
  58722. /**
  58723. * Multiplies the current Vector3 coordinates by the given ones
  58724. * @param otherVector defines the second operand
  58725. * @returns the current updated Vector3
  58726. */
  58727. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58728. /**
  58729. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  58730. * @param otherVector defines the second operand
  58731. * @returns the new Vector3
  58732. */
  58733. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  58734. /**
  58735. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  58736. * @param otherVector defines the second operand
  58737. * @param result defines the Vector3 object where to store the result
  58738. * @returns the current Vector3
  58739. */
  58740. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58741. /**
  58742. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  58743. * @param x defines the x coordinate of the operand
  58744. * @param y defines the y coordinate of the operand
  58745. * @param z defines the z coordinate of the operand
  58746. * @returns the new Vector3
  58747. */
  58748. multiplyByFloats(x: number, y: number, z: number): Vector3;
  58749. /**
  58750. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  58751. * @param otherVector defines the second operand
  58752. * @returns the new Vector3
  58753. */
  58754. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  58755. /**
  58756. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  58757. * @param otherVector defines the second operand
  58758. * @param result defines the Vector3 object where to store the result
  58759. * @returns the current Vector3
  58760. */
  58761. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58762. /**
  58763. * Divides the current Vector3 coordinates by the given ones.
  58764. * @param otherVector defines the second operand
  58765. * @returns the current updated Vector3
  58766. */
  58767. divideInPlace(otherVector: Vector3): Vector3;
  58768. /**
  58769. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  58770. * @param other defines the second operand
  58771. * @returns the current updated Vector3
  58772. */
  58773. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  58774. /**
  58775. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  58776. * @param other defines the second operand
  58777. * @returns the current updated Vector3
  58778. */
  58779. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  58780. /**
  58781. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  58782. * @param x defines the x coordinate of the operand
  58783. * @param y defines the y coordinate of the operand
  58784. * @param z defines the z coordinate of the operand
  58785. * @returns the current updated Vector3
  58786. */
  58787. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58788. /**
  58789. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  58790. * @param x defines the x coordinate of the operand
  58791. * @param y defines the y coordinate of the operand
  58792. * @param z defines the z coordinate of the operand
  58793. * @returns the current updated Vector3
  58794. */
  58795. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58796. /**
  58797. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  58798. * Check if is non uniform within a certain amount of decimal places to account for this
  58799. * @param epsilon the amount the values can differ
  58800. * @returns if the the vector is non uniform to a certain number of decimal places
  58801. */
  58802. isNonUniformWithinEpsilon(epsilon: number): boolean;
  58803. /**
  58804. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  58805. */
  58806. readonly isNonUniform: boolean;
  58807. /**
  58808. * Gets a new Vector3 from current Vector3 floored values
  58809. * @returns a new Vector3
  58810. */
  58811. floor(): Vector3;
  58812. /**
  58813. * Gets a new Vector3 from current Vector3 floored values
  58814. * @returns a new Vector3
  58815. */
  58816. fract(): Vector3;
  58817. /**
  58818. * Gets the length of the Vector3
  58819. * @returns the length of the Vecto3
  58820. */
  58821. length(): number;
  58822. /**
  58823. * Gets the squared length of the Vector3
  58824. * @returns squared length of the Vector3
  58825. */
  58826. lengthSquared(): number;
  58827. /**
  58828. * Normalize the current Vector3.
  58829. * Please note that this is an in place operation.
  58830. * @returns the current updated Vector3
  58831. */
  58832. normalize(): Vector3;
  58833. /**
  58834. * Reorders the x y z properties of the vector in place
  58835. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  58836. * @returns the current updated vector
  58837. */
  58838. reorderInPlace(order: string): this;
  58839. /**
  58840. * Rotates the vector around 0,0,0 by a quaternion
  58841. * @param quaternion the rotation quaternion
  58842. * @param result vector to store the result
  58843. * @returns the resulting vector
  58844. */
  58845. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  58846. /**
  58847. * Rotates a vector around a given point
  58848. * @param quaternion the rotation quaternion
  58849. * @param point the point to rotate around
  58850. * @param result vector to store the result
  58851. * @returns the resulting vector
  58852. */
  58853. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  58854. /**
  58855. * Normalize the current Vector3 with the given input length.
  58856. * Please note that this is an in place operation.
  58857. * @param len the length of the vector
  58858. * @returns the current updated Vector3
  58859. */
  58860. normalizeFromLength(len: number): Vector3;
  58861. /**
  58862. * Normalize the current Vector3 to a new vector
  58863. * @returns the new Vector3
  58864. */
  58865. normalizeToNew(): Vector3;
  58866. /**
  58867. * Normalize the current Vector3 to the reference
  58868. * @param reference define the Vector3 to update
  58869. * @returns the updated Vector3
  58870. */
  58871. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  58872. /**
  58873. * Creates a new Vector3 copied from the current Vector3
  58874. * @returns the new Vector3
  58875. */
  58876. clone(): Vector3;
  58877. /**
  58878. * Copies the given vector coordinates to the current Vector3 ones
  58879. * @param source defines the source Vector3
  58880. * @returns the current updated Vector3
  58881. */
  58882. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  58883. /**
  58884. * Copies the given floats to the current Vector3 coordinates
  58885. * @param x defines the x coordinate of the operand
  58886. * @param y defines the y coordinate of the operand
  58887. * @param z defines the z coordinate of the operand
  58888. * @returns the current updated Vector3
  58889. */
  58890. copyFromFloats(x: number, y: number, z: number): Vector3;
  58891. /**
  58892. * Copies the given floats to the current Vector3 coordinates
  58893. * @param x defines the x coordinate of the operand
  58894. * @param y defines the y coordinate of the operand
  58895. * @param z defines the z coordinate of the operand
  58896. * @returns the current updated Vector3
  58897. */
  58898. set(x: number, y: number, z: number): Vector3;
  58899. /**
  58900. * Copies the given float to the current Vector3 coordinates
  58901. * @param v defines the x, y and z coordinates of the operand
  58902. * @returns the current updated Vector3
  58903. */
  58904. setAll(v: number): Vector3;
  58905. /**
  58906. * Get the clip factor between two vectors
  58907. * @param vector0 defines the first operand
  58908. * @param vector1 defines the second operand
  58909. * @param axis defines the axis to use
  58910. * @param size defines the size along the axis
  58911. * @returns the clip factor
  58912. */
  58913. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  58914. /**
  58915. * Get angle between two vectors
  58916. * @param vector0 angle between vector0 and vector1
  58917. * @param vector1 angle between vector0 and vector1
  58918. * @param normal direction of the normal
  58919. * @return the angle between vector0 and vector1
  58920. */
  58921. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  58922. /**
  58923. * Returns a new Vector3 set from the index "offset" of the given array
  58924. * @param array defines the source array
  58925. * @param offset defines the offset in the source array
  58926. * @returns the new Vector3
  58927. */
  58928. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  58929. /**
  58930. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  58931. * This function is deprecated. Use FromArray instead
  58932. * @param array defines the source array
  58933. * @param offset defines the offset in the source array
  58934. * @returns the new Vector3
  58935. */
  58936. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  58937. /**
  58938. * Sets the given vector "result" with the element values from the index "offset" of the given array
  58939. * @param array defines the source array
  58940. * @param offset defines the offset in the source array
  58941. * @param result defines the Vector3 where to store the result
  58942. */
  58943. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  58944. /**
  58945. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  58946. * This function is deprecated. Use FromArrayToRef instead.
  58947. * @param array defines the source array
  58948. * @param offset defines the offset in the source array
  58949. * @param result defines the Vector3 where to store the result
  58950. */
  58951. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  58952. /**
  58953. * Sets the given vector "result" with the given floats.
  58954. * @param x defines the x coordinate of the source
  58955. * @param y defines the y coordinate of the source
  58956. * @param z defines the z coordinate of the source
  58957. * @param result defines the Vector3 where to store the result
  58958. */
  58959. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  58960. /**
  58961. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  58962. * @returns a new empty Vector3
  58963. */
  58964. static Zero(): Vector3;
  58965. /**
  58966. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  58967. * @returns a new unit Vector3
  58968. */
  58969. static One(): Vector3;
  58970. /**
  58971. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  58972. * @returns a new up Vector3
  58973. */
  58974. static Up(): Vector3;
  58975. /**
  58976. * Gets a up Vector3 that must not be updated
  58977. */
  58978. static readonly UpReadOnly: DeepImmutable<Vector3>;
  58979. /**
  58980. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  58981. * @returns a new down Vector3
  58982. */
  58983. static Down(): Vector3;
  58984. /**
  58985. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  58986. * @returns a new forward Vector3
  58987. */
  58988. static Forward(): Vector3;
  58989. /**
  58990. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  58991. * @returns a new forward Vector3
  58992. */
  58993. static Backward(): Vector3;
  58994. /**
  58995. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  58996. * @returns a new right Vector3
  58997. */
  58998. static Right(): Vector3;
  58999. /**
  59000. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  59001. * @returns a new left Vector3
  59002. */
  59003. static Left(): Vector3;
  59004. /**
  59005. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  59006. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59007. * @param vector defines the Vector3 to transform
  59008. * @param transformation defines the transformation matrix
  59009. * @returns the transformed Vector3
  59010. */
  59011. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59012. /**
  59013. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  59014. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59015. * @param vector defines the Vector3 to transform
  59016. * @param transformation defines the transformation matrix
  59017. * @param result defines the Vector3 where to store the result
  59018. */
  59019. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59020. /**
  59021. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  59022. * This method computes tranformed coordinates only, not transformed direction vectors
  59023. * @param x define the x coordinate of the source vector
  59024. * @param y define the y coordinate of the source vector
  59025. * @param z define the z coordinate of the source vector
  59026. * @param transformation defines the transformation matrix
  59027. * @param result defines the Vector3 where to store the result
  59028. */
  59029. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59030. /**
  59031. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  59032. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59033. * @param vector defines the Vector3 to transform
  59034. * @param transformation defines the transformation matrix
  59035. * @returns the new Vector3
  59036. */
  59037. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59038. /**
  59039. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  59040. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59041. * @param vector defines the Vector3 to transform
  59042. * @param transformation defines the transformation matrix
  59043. * @param result defines the Vector3 where to store the result
  59044. */
  59045. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59046. /**
  59047. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  59048. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59049. * @param x define the x coordinate of the source vector
  59050. * @param y define the y coordinate of the source vector
  59051. * @param z define the z coordinate of the source vector
  59052. * @param transformation defines the transformation matrix
  59053. * @param result defines the Vector3 where to store the result
  59054. */
  59055. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59056. /**
  59057. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  59058. * @param value1 defines the first control point
  59059. * @param value2 defines the second control point
  59060. * @param value3 defines the third control point
  59061. * @param value4 defines the fourth control point
  59062. * @param amount defines the amount on the spline to use
  59063. * @returns the new Vector3
  59064. */
  59065. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  59066. /**
  59067. * 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"
  59068. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59069. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59070. * @param value defines the current value
  59071. * @param min defines the lower range value
  59072. * @param max defines the upper range value
  59073. * @returns the new Vector3
  59074. */
  59075. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  59076. /**
  59077. * 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"
  59078. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59079. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59080. * @param value defines the current value
  59081. * @param min defines the lower range value
  59082. * @param max defines the upper range value
  59083. * @param result defines the Vector3 where to store the result
  59084. */
  59085. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  59086. /**
  59087. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  59088. * @param value1 defines the first control point
  59089. * @param tangent1 defines the first tangent vector
  59090. * @param value2 defines the second control point
  59091. * @param tangent2 defines the second tangent vector
  59092. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  59093. * @returns the new Vector3
  59094. */
  59095. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  59096. /**
  59097. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  59098. * @param start defines the start value
  59099. * @param end defines the end value
  59100. * @param amount max defines amount between both (between 0 and 1)
  59101. * @returns the new Vector3
  59102. */
  59103. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  59104. /**
  59105. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  59106. * @param start defines the start value
  59107. * @param end defines the end value
  59108. * @param amount max defines amount between both (between 0 and 1)
  59109. * @param result defines the Vector3 where to store the result
  59110. */
  59111. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  59112. /**
  59113. * Returns the dot product (float) between the vectors "left" and "right"
  59114. * @param left defines the left operand
  59115. * @param right defines the right operand
  59116. * @returns the dot product
  59117. */
  59118. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  59119. /**
  59120. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  59121. * The cross product is then orthogonal to both "left" and "right"
  59122. * @param left defines the left operand
  59123. * @param right defines the right operand
  59124. * @returns the cross product
  59125. */
  59126. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59127. /**
  59128. * Sets the given vector "result" with the cross product of "left" and "right"
  59129. * The cross product is then orthogonal to both "left" and "right"
  59130. * @param left defines the left operand
  59131. * @param right defines the right operand
  59132. * @param result defines the Vector3 where to store the result
  59133. */
  59134. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  59135. /**
  59136. * Returns a new Vector3 as the normalization of the given vector
  59137. * @param vector defines the Vector3 to normalize
  59138. * @returns the new Vector3
  59139. */
  59140. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  59141. /**
  59142. * Sets the given vector "result" with the normalization of the given first vector
  59143. * @param vector defines the Vector3 to normalize
  59144. * @param result defines the Vector3 where to store the result
  59145. */
  59146. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  59147. /**
  59148. * Project a Vector3 onto screen space
  59149. * @param vector defines the Vector3 to project
  59150. * @param world defines the world matrix to use
  59151. * @param transform defines the transform (view x projection) matrix to use
  59152. * @param viewport defines the screen viewport to use
  59153. * @returns the new Vector3
  59154. */
  59155. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  59156. /** @hidden */
  59157. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  59158. /**
  59159. * Unproject from screen space to object space
  59160. * @param source defines the screen space Vector3 to use
  59161. * @param viewportWidth defines the current width of the viewport
  59162. * @param viewportHeight defines the current height of the viewport
  59163. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59164. * @param transform defines the transform (view x projection) matrix to use
  59165. * @returns the new Vector3
  59166. */
  59167. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  59168. /**
  59169. * Unproject from screen space to object space
  59170. * @param source defines the screen space Vector3 to use
  59171. * @param viewportWidth defines the current width of the viewport
  59172. * @param viewportHeight defines the current height of the viewport
  59173. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59174. * @param view defines the view matrix to use
  59175. * @param projection defines the projection matrix to use
  59176. * @returns the new Vector3
  59177. */
  59178. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  59179. /**
  59180. * Unproject from screen space to object space
  59181. * @param source defines the screen space Vector3 to use
  59182. * @param viewportWidth defines the current width of the viewport
  59183. * @param viewportHeight defines the current height of the viewport
  59184. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59185. * @param view defines the view matrix to use
  59186. * @param projection defines the projection matrix to use
  59187. * @param result defines the Vector3 where to store the result
  59188. */
  59189. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59190. /**
  59191. * Unproject from screen space to object space
  59192. * @param sourceX defines the screen space x coordinate to use
  59193. * @param sourceY defines the screen space y coordinate to use
  59194. * @param sourceZ defines the screen space z coordinate to use
  59195. * @param viewportWidth defines the current width of the viewport
  59196. * @param viewportHeight defines the current height of the viewport
  59197. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59198. * @param view defines the view matrix to use
  59199. * @param projection defines the projection matrix to use
  59200. * @param result defines the Vector3 where to store the result
  59201. */
  59202. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59203. /**
  59204. * Gets the minimal coordinate values between two Vector3
  59205. * @param left defines the first operand
  59206. * @param right defines the second operand
  59207. * @returns the new Vector3
  59208. */
  59209. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59210. /**
  59211. * Gets the maximal coordinate values between two Vector3
  59212. * @param left defines the first operand
  59213. * @param right defines the second operand
  59214. * @returns the new Vector3
  59215. */
  59216. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59217. /**
  59218. * Returns the distance between the vectors "value1" and "value2"
  59219. * @param value1 defines the first operand
  59220. * @param value2 defines the second operand
  59221. * @returns the distance
  59222. */
  59223. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59224. /**
  59225. * Returns the squared distance between the vectors "value1" and "value2"
  59226. * @param value1 defines the first operand
  59227. * @param value2 defines the second operand
  59228. * @returns the squared distance
  59229. */
  59230. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59231. /**
  59232. * Returns a new Vector3 located at the center between "value1" and "value2"
  59233. * @param value1 defines the first operand
  59234. * @param value2 defines the second operand
  59235. * @returns the new Vector3
  59236. */
  59237. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  59238. /**
  59239. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  59240. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  59241. * to something in order to rotate it from its local system to the given target system
  59242. * Note: axis1, axis2 and axis3 are normalized during this operation
  59243. * @param axis1 defines the first axis
  59244. * @param axis2 defines the second axis
  59245. * @param axis3 defines the third axis
  59246. * @returns a new Vector3
  59247. */
  59248. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  59249. /**
  59250. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  59251. * @param axis1 defines the first axis
  59252. * @param axis2 defines the second axis
  59253. * @param axis3 defines the third axis
  59254. * @param ref defines the Vector3 where to store the result
  59255. */
  59256. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  59257. }
  59258. /**
  59259. * Vector4 class created for EulerAngle class conversion to Quaternion
  59260. */
  59261. export class Vector4 {
  59262. /** x value of the vector */
  59263. x: number;
  59264. /** y value of the vector */
  59265. y: number;
  59266. /** z value of the vector */
  59267. z: number;
  59268. /** w value of the vector */
  59269. w: number;
  59270. /**
  59271. * Creates a Vector4 object from the given floats.
  59272. * @param x x value of the vector
  59273. * @param y y value of the vector
  59274. * @param z z value of the vector
  59275. * @param w w value of the vector
  59276. */
  59277. constructor(
  59278. /** x value of the vector */
  59279. x: number,
  59280. /** y value of the vector */
  59281. y: number,
  59282. /** z value of the vector */
  59283. z: number,
  59284. /** w value of the vector */
  59285. w: number);
  59286. /**
  59287. * Returns the string with the Vector4 coordinates.
  59288. * @returns a string containing all the vector values
  59289. */
  59290. toString(): string;
  59291. /**
  59292. * Returns the string "Vector4".
  59293. * @returns "Vector4"
  59294. */
  59295. getClassName(): string;
  59296. /**
  59297. * Returns the Vector4 hash code.
  59298. * @returns a unique hash code
  59299. */
  59300. getHashCode(): number;
  59301. /**
  59302. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  59303. * @returns the resulting array
  59304. */
  59305. asArray(): number[];
  59306. /**
  59307. * Populates the given array from the given index with the Vector4 coordinates.
  59308. * @param array array to populate
  59309. * @param index index of the array to start at (default: 0)
  59310. * @returns the Vector4.
  59311. */
  59312. toArray(array: FloatArray, index?: number): Vector4;
  59313. /**
  59314. * Adds the given vector to the current Vector4.
  59315. * @param otherVector the vector to add
  59316. * @returns the updated Vector4.
  59317. */
  59318. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59319. /**
  59320. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  59321. * @param otherVector the vector to add
  59322. * @returns the resulting vector
  59323. */
  59324. add(otherVector: DeepImmutable<Vector4>): Vector4;
  59325. /**
  59326. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  59327. * @param otherVector the vector to add
  59328. * @param result the vector to store the result
  59329. * @returns the current Vector4.
  59330. */
  59331. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59332. /**
  59333. * Subtract in place the given vector from the current Vector4.
  59334. * @param otherVector the vector to subtract
  59335. * @returns the updated Vector4.
  59336. */
  59337. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59338. /**
  59339. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  59340. * @param otherVector the vector to add
  59341. * @returns the new vector with the result
  59342. */
  59343. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  59344. /**
  59345. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  59346. * @param otherVector the vector to subtract
  59347. * @param result the vector to store the result
  59348. * @returns the current Vector4.
  59349. */
  59350. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59351. /**
  59352. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59353. */
  59354. /**
  59355. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59356. * @param x value to subtract
  59357. * @param y value to subtract
  59358. * @param z value to subtract
  59359. * @param w value to subtract
  59360. * @returns new vector containing the result
  59361. */
  59362. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59363. /**
  59364. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59365. * @param x value to subtract
  59366. * @param y value to subtract
  59367. * @param z value to subtract
  59368. * @param w value to subtract
  59369. * @param result the vector to store the result in
  59370. * @returns the current Vector4.
  59371. */
  59372. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  59373. /**
  59374. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  59375. * @returns a new vector with the negated values
  59376. */
  59377. negate(): Vector4;
  59378. /**
  59379. * Multiplies the current Vector4 coordinates by scale (float).
  59380. * @param scale the number to scale with
  59381. * @returns the updated Vector4.
  59382. */
  59383. scaleInPlace(scale: number): Vector4;
  59384. /**
  59385. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  59386. * @param scale the number to scale with
  59387. * @returns a new vector with the result
  59388. */
  59389. scale(scale: number): Vector4;
  59390. /**
  59391. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  59392. * @param scale the number to scale with
  59393. * @param result a vector to store the result in
  59394. * @returns the current Vector4.
  59395. */
  59396. scaleToRef(scale: number, result: Vector4): Vector4;
  59397. /**
  59398. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  59399. * @param scale defines the scale factor
  59400. * @param result defines the Vector4 object where to store the result
  59401. * @returns the unmodified current Vector4
  59402. */
  59403. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  59404. /**
  59405. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  59406. * @param otherVector the vector to compare against
  59407. * @returns true if they are equal
  59408. */
  59409. equals(otherVector: DeepImmutable<Vector4>): boolean;
  59410. /**
  59411. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  59412. * @param otherVector vector to compare against
  59413. * @param epsilon (Default: very small number)
  59414. * @returns true if they are equal
  59415. */
  59416. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  59417. /**
  59418. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  59419. * @param x x value to compare against
  59420. * @param y y value to compare against
  59421. * @param z z value to compare against
  59422. * @param w w value to compare against
  59423. * @returns true if equal
  59424. */
  59425. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  59426. /**
  59427. * Multiplies in place the current Vector4 by the given one.
  59428. * @param otherVector vector to multiple with
  59429. * @returns the updated Vector4.
  59430. */
  59431. multiplyInPlace(otherVector: Vector4): Vector4;
  59432. /**
  59433. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  59434. * @param otherVector vector to multiple with
  59435. * @returns resulting new vector
  59436. */
  59437. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  59438. /**
  59439. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  59440. * @param otherVector vector to multiple with
  59441. * @param result vector to store the result
  59442. * @returns the current Vector4.
  59443. */
  59444. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59445. /**
  59446. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  59447. * @param x x value multiply with
  59448. * @param y y value multiply with
  59449. * @param z z value multiply with
  59450. * @param w w value multiply with
  59451. * @returns resulting new vector
  59452. */
  59453. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  59454. /**
  59455. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  59456. * @param otherVector vector to devide with
  59457. * @returns resulting new vector
  59458. */
  59459. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  59460. /**
  59461. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  59462. * @param otherVector vector to devide with
  59463. * @param result vector to store the result
  59464. * @returns the current Vector4.
  59465. */
  59466. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59467. /**
  59468. * Divides the current Vector3 coordinates by the given ones.
  59469. * @param otherVector vector to devide with
  59470. * @returns the updated Vector3.
  59471. */
  59472. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59473. /**
  59474. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  59475. * @param other defines the second operand
  59476. * @returns the current updated Vector4
  59477. */
  59478. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59479. /**
  59480. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  59481. * @param other defines the second operand
  59482. * @returns the current updated Vector4
  59483. */
  59484. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59485. /**
  59486. * Gets a new Vector4 from current Vector4 floored values
  59487. * @returns a new Vector4
  59488. */
  59489. floor(): Vector4;
  59490. /**
  59491. * Gets a new Vector4 from current Vector3 floored values
  59492. * @returns a new Vector4
  59493. */
  59494. fract(): Vector4;
  59495. /**
  59496. * Returns the Vector4 length (float).
  59497. * @returns the length
  59498. */
  59499. length(): number;
  59500. /**
  59501. * Returns the Vector4 squared length (float).
  59502. * @returns the length squared
  59503. */
  59504. lengthSquared(): number;
  59505. /**
  59506. * Normalizes in place the Vector4.
  59507. * @returns the updated Vector4.
  59508. */
  59509. normalize(): Vector4;
  59510. /**
  59511. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  59512. * @returns this converted to a new vector3
  59513. */
  59514. toVector3(): Vector3;
  59515. /**
  59516. * Returns a new Vector4 copied from the current one.
  59517. * @returns the new cloned vector
  59518. */
  59519. clone(): Vector4;
  59520. /**
  59521. * Updates the current Vector4 with the given one coordinates.
  59522. * @param source the source vector to copy from
  59523. * @returns the updated Vector4.
  59524. */
  59525. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  59526. /**
  59527. * Updates the current Vector4 coordinates with the given floats.
  59528. * @param x float to copy from
  59529. * @param y float to copy from
  59530. * @param z float to copy from
  59531. * @param w float to copy from
  59532. * @returns the updated Vector4.
  59533. */
  59534. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59535. /**
  59536. * Updates the current Vector4 coordinates with the given floats.
  59537. * @param x float to set from
  59538. * @param y float to set from
  59539. * @param z float to set from
  59540. * @param w float to set from
  59541. * @returns the updated Vector4.
  59542. */
  59543. set(x: number, y: number, z: number, w: number): Vector4;
  59544. /**
  59545. * Copies the given float to the current Vector3 coordinates
  59546. * @param v defines the x, y, z and w coordinates of the operand
  59547. * @returns the current updated Vector3
  59548. */
  59549. setAll(v: number): Vector4;
  59550. /**
  59551. * Returns a new Vector4 set from the starting index of the given array.
  59552. * @param array the array to pull values from
  59553. * @param offset the offset into the array to start at
  59554. * @returns the new vector
  59555. */
  59556. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  59557. /**
  59558. * Updates the given vector "result" from the starting index of the given array.
  59559. * @param array the array to pull values from
  59560. * @param offset the offset into the array to start at
  59561. * @param result the vector to store the result in
  59562. */
  59563. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  59564. /**
  59565. * Updates the given vector "result" from the starting index of the given Float32Array.
  59566. * @param array the array to pull values from
  59567. * @param offset the offset into the array to start at
  59568. * @param result the vector to store the result in
  59569. */
  59570. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  59571. /**
  59572. * Updates the given vector "result" coordinates from the given floats.
  59573. * @param x float to set from
  59574. * @param y float to set from
  59575. * @param z float to set from
  59576. * @param w float to set from
  59577. * @param result the vector to the floats in
  59578. */
  59579. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  59580. /**
  59581. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  59582. * @returns the new vector
  59583. */
  59584. static Zero(): Vector4;
  59585. /**
  59586. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  59587. * @returns the new vector
  59588. */
  59589. static One(): Vector4;
  59590. /**
  59591. * Returns a new normalized Vector4 from the given one.
  59592. * @param vector the vector to normalize
  59593. * @returns the vector
  59594. */
  59595. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  59596. /**
  59597. * Updates the given vector "result" from the normalization of the given one.
  59598. * @param vector the vector to normalize
  59599. * @param result the vector to store the result in
  59600. */
  59601. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  59602. /**
  59603. * Returns a vector with the minimum values from the left and right vectors
  59604. * @param left left vector to minimize
  59605. * @param right right vector to minimize
  59606. * @returns a new vector with the minimum of the left and right vector values
  59607. */
  59608. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59609. /**
  59610. * Returns a vector with the maximum values from the left and right vectors
  59611. * @param left left vector to maximize
  59612. * @param right right vector to maximize
  59613. * @returns a new vector with the maximum of the left and right vector values
  59614. */
  59615. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59616. /**
  59617. * Returns the distance (float) between the vectors "value1" and "value2".
  59618. * @param value1 value to calulate the distance between
  59619. * @param value2 value to calulate the distance between
  59620. * @return the distance between the two vectors
  59621. */
  59622. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59623. /**
  59624. * Returns the squared distance (float) between the vectors "value1" and "value2".
  59625. * @param value1 value to calulate the distance between
  59626. * @param value2 value to calulate the distance between
  59627. * @return the distance between the two vectors squared
  59628. */
  59629. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59630. /**
  59631. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  59632. * @param value1 value to calulate the center between
  59633. * @param value2 value to calulate the center between
  59634. * @return the center between the two vectors
  59635. */
  59636. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  59637. /**
  59638. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  59639. * This methods computes transformed normalized direction vectors only.
  59640. * @param vector the vector to transform
  59641. * @param transformation the transformation matrix to apply
  59642. * @returns the new vector
  59643. */
  59644. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  59645. /**
  59646. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  59647. * This methods computes transformed normalized direction vectors only.
  59648. * @param vector the vector to transform
  59649. * @param transformation the transformation matrix to apply
  59650. * @param result the vector to store the result in
  59651. */
  59652. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59653. /**
  59654. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  59655. * This methods computes transformed normalized direction vectors only.
  59656. * @param x value to transform
  59657. * @param y value to transform
  59658. * @param z value to transform
  59659. * @param w value to transform
  59660. * @param transformation the transformation matrix to apply
  59661. * @param result the vector to store the results in
  59662. */
  59663. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59664. /**
  59665. * Creates a new Vector4 from a Vector3
  59666. * @param source defines the source data
  59667. * @param w defines the 4th component (default is 0)
  59668. * @returns a new Vector4
  59669. */
  59670. static FromVector3(source: Vector3, w?: number): Vector4;
  59671. }
  59672. /**
  59673. * Interface for the size containing width and height
  59674. */
  59675. export interface ISize {
  59676. /**
  59677. * Width
  59678. */
  59679. width: number;
  59680. /**
  59681. * Heighht
  59682. */
  59683. height: number;
  59684. }
  59685. /**
  59686. * Size containing widht and height
  59687. */
  59688. export class Size implements ISize {
  59689. /**
  59690. * Width
  59691. */
  59692. width: number;
  59693. /**
  59694. * Height
  59695. */
  59696. height: number;
  59697. /**
  59698. * Creates a Size object from the given width and height (floats).
  59699. * @param width width of the new size
  59700. * @param height height of the new size
  59701. */
  59702. constructor(width: number, height: number);
  59703. /**
  59704. * Returns a string with the Size width and height
  59705. * @returns a string with the Size width and height
  59706. */
  59707. toString(): string;
  59708. /**
  59709. * "Size"
  59710. * @returns the string "Size"
  59711. */
  59712. getClassName(): string;
  59713. /**
  59714. * Returns the Size hash code.
  59715. * @returns a hash code for a unique width and height
  59716. */
  59717. getHashCode(): number;
  59718. /**
  59719. * Updates the current size from the given one.
  59720. * @param src the given size
  59721. */
  59722. copyFrom(src: Size): void;
  59723. /**
  59724. * Updates in place the current Size from the given floats.
  59725. * @param width width of the new size
  59726. * @param height height of the new size
  59727. * @returns the updated Size.
  59728. */
  59729. copyFromFloats(width: number, height: number): Size;
  59730. /**
  59731. * Updates in place the current Size from the given floats.
  59732. * @param width width to set
  59733. * @param height height to set
  59734. * @returns the updated Size.
  59735. */
  59736. set(width: number, height: number): Size;
  59737. /**
  59738. * Multiplies the width and height by numbers
  59739. * @param w factor to multiple the width by
  59740. * @param h factor to multiple the height by
  59741. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  59742. */
  59743. multiplyByFloats(w: number, h: number): Size;
  59744. /**
  59745. * Clones the size
  59746. * @returns a new Size copied from the given one.
  59747. */
  59748. clone(): Size;
  59749. /**
  59750. * True if the current Size and the given one width and height are strictly equal.
  59751. * @param other the other size to compare against
  59752. * @returns True if the current Size and the given one width and height are strictly equal.
  59753. */
  59754. equals(other: Size): boolean;
  59755. /**
  59756. * The surface of the Size : width * height (float).
  59757. */
  59758. readonly surface: number;
  59759. /**
  59760. * Create a new size of zero
  59761. * @returns a new Size set to (0.0, 0.0)
  59762. */
  59763. static Zero(): Size;
  59764. /**
  59765. * Sums the width and height of two sizes
  59766. * @param otherSize size to add to this size
  59767. * @returns a new Size set as the addition result of the current Size and the given one.
  59768. */
  59769. add(otherSize: Size): Size;
  59770. /**
  59771. * Subtracts the width and height of two
  59772. * @param otherSize size to subtract to this size
  59773. * @returns a new Size set as the subtraction result of the given one from the current Size.
  59774. */
  59775. subtract(otherSize: Size): Size;
  59776. /**
  59777. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  59778. * @param start starting size to lerp between
  59779. * @param end end size to lerp between
  59780. * @param amount amount to lerp between the start and end values
  59781. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  59782. */
  59783. static Lerp(start: Size, end: Size, amount: number): Size;
  59784. }
  59785. /**
  59786. * Class used to store quaternion data
  59787. * @see https://en.wikipedia.org/wiki/Quaternion
  59788. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  59789. */
  59790. export class Quaternion {
  59791. /** defines the first component (0 by default) */
  59792. x: number;
  59793. /** defines the second component (0 by default) */
  59794. y: number;
  59795. /** defines the third component (0 by default) */
  59796. z: number;
  59797. /** defines the fourth component (1.0 by default) */
  59798. w: number;
  59799. /**
  59800. * Creates a new Quaternion from the given floats
  59801. * @param x defines the first component (0 by default)
  59802. * @param y defines the second component (0 by default)
  59803. * @param z defines the third component (0 by default)
  59804. * @param w defines the fourth component (1.0 by default)
  59805. */
  59806. constructor(
  59807. /** defines the first component (0 by default) */
  59808. x?: number,
  59809. /** defines the second component (0 by default) */
  59810. y?: number,
  59811. /** defines the third component (0 by default) */
  59812. z?: number,
  59813. /** defines the fourth component (1.0 by default) */
  59814. w?: number);
  59815. /**
  59816. * Gets a string representation for the current quaternion
  59817. * @returns a string with the Quaternion coordinates
  59818. */
  59819. toString(): string;
  59820. /**
  59821. * Gets the class name of the quaternion
  59822. * @returns the string "Quaternion"
  59823. */
  59824. getClassName(): string;
  59825. /**
  59826. * Gets a hash code for this quaternion
  59827. * @returns the quaternion hash code
  59828. */
  59829. getHashCode(): number;
  59830. /**
  59831. * Copy the quaternion to an array
  59832. * @returns a new array populated with 4 elements from the quaternion coordinates
  59833. */
  59834. asArray(): number[];
  59835. /**
  59836. * Check if two quaternions are equals
  59837. * @param otherQuaternion defines the second operand
  59838. * @return true if the current quaternion and the given one coordinates are strictly equals
  59839. */
  59840. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  59841. /**
  59842. * Clone the current quaternion
  59843. * @returns a new quaternion copied from the current one
  59844. */
  59845. clone(): Quaternion;
  59846. /**
  59847. * Copy a quaternion to the current one
  59848. * @param other defines the other quaternion
  59849. * @returns the updated current quaternion
  59850. */
  59851. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  59852. /**
  59853. * Updates the current quaternion with the given float coordinates
  59854. * @param x defines the x coordinate
  59855. * @param y defines the y coordinate
  59856. * @param z defines the z coordinate
  59857. * @param w defines the w coordinate
  59858. * @returns the updated current quaternion
  59859. */
  59860. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  59861. /**
  59862. * Updates the current quaternion from the given float coordinates
  59863. * @param x defines the x coordinate
  59864. * @param y defines the y coordinate
  59865. * @param z defines the z coordinate
  59866. * @param w defines the w coordinate
  59867. * @returns the updated current quaternion
  59868. */
  59869. set(x: number, y: number, z: number, w: number): Quaternion;
  59870. /**
  59871. * Adds two quaternions
  59872. * @param other defines the second operand
  59873. * @returns a new quaternion as the addition result of the given one and the current quaternion
  59874. */
  59875. add(other: DeepImmutable<Quaternion>): Quaternion;
  59876. /**
  59877. * Add a quaternion to the current one
  59878. * @param other defines the quaternion to add
  59879. * @returns the current quaternion
  59880. */
  59881. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  59882. /**
  59883. * Subtract two quaternions
  59884. * @param other defines the second operand
  59885. * @returns a new quaternion as the subtraction result of the given one from the current one
  59886. */
  59887. subtract(other: Quaternion): Quaternion;
  59888. /**
  59889. * Multiplies the current quaternion by a scale factor
  59890. * @param value defines the scale factor
  59891. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  59892. */
  59893. scale(value: number): Quaternion;
  59894. /**
  59895. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  59896. * @param scale defines the scale factor
  59897. * @param result defines the Quaternion object where to store the result
  59898. * @returns the unmodified current quaternion
  59899. */
  59900. scaleToRef(scale: number, result: Quaternion): Quaternion;
  59901. /**
  59902. * Multiplies in place the current quaternion by a scale factor
  59903. * @param value defines the scale factor
  59904. * @returns the current modified quaternion
  59905. */
  59906. scaleInPlace(value: number): Quaternion;
  59907. /**
  59908. * Scale the current quaternion values by a factor and add the result to a given quaternion
  59909. * @param scale defines the scale factor
  59910. * @param result defines the Quaternion object where to store the result
  59911. * @returns the unmodified current quaternion
  59912. */
  59913. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  59914. /**
  59915. * Multiplies two quaternions
  59916. * @param q1 defines the second operand
  59917. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  59918. */
  59919. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  59920. /**
  59921. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  59922. * @param q1 defines the second operand
  59923. * @param result defines the target quaternion
  59924. * @returns the current quaternion
  59925. */
  59926. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  59927. /**
  59928. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  59929. * @param q1 defines the second operand
  59930. * @returns the currentupdated quaternion
  59931. */
  59932. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  59933. /**
  59934. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  59935. * @param ref defines the target quaternion
  59936. * @returns the current quaternion
  59937. */
  59938. conjugateToRef(ref: Quaternion): Quaternion;
  59939. /**
  59940. * Conjugates in place (1-q) the current quaternion
  59941. * @returns the current updated quaternion
  59942. */
  59943. conjugateInPlace(): Quaternion;
  59944. /**
  59945. * Conjugates in place (1-q) the current quaternion
  59946. * @returns a new quaternion
  59947. */
  59948. conjugate(): Quaternion;
  59949. /**
  59950. * Gets length of current quaternion
  59951. * @returns the quaternion length (float)
  59952. */
  59953. length(): number;
  59954. /**
  59955. * Normalize in place the current quaternion
  59956. * @returns the current updated quaternion
  59957. */
  59958. normalize(): Quaternion;
  59959. /**
  59960. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  59961. * @param order is a reserved parameter and is ignore for now
  59962. * @returns a new Vector3 containing the Euler angles
  59963. */
  59964. toEulerAngles(order?: string): Vector3;
  59965. /**
  59966. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  59967. * @param result defines the vector which will be filled with the Euler angles
  59968. * @param order is a reserved parameter and is ignore for now
  59969. * @returns the current unchanged quaternion
  59970. */
  59971. toEulerAnglesToRef(result: Vector3): Quaternion;
  59972. /**
  59973. * Updates the given rotation matrix with the current quaternion values
  59974. * @param result defines the target matrix
  59975. * @returns the current unchanged quaternion
  59976. */
  59977. toRotationMatrix(result: Matrix): Quaternion;
  59978. /**
  59979. * Updates the current quaternion from the given rotation matrix values
  59980. * @param matrix defines the source matrix
  59981. * @returns the current updated quaternion
  59982. */
  59983. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59984. /**
  59985. * Creates a new quaternion from a rotation matrix
  59986. * @param matrix defines the source matrix
  59987. * @returns a new quaternion created from the given rotation matrix values
  59988. */
  59989. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59990. /**
  59991. * Updates the given quaternion with the given rotation matrix values
  59992. * @param matrix defines the source matrix
  59993. * @param result defines the target quaternion
  59994. */
  59995. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  59996. /**
  59997. * Returns the dot product (float) between the quaternions "left" and "right"
  59998. * @param left defines the left operand
  59999. * @param right defines the right operand
  60000. * @returns the dot product
  60001. */
  60002. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  60003. /**
  60004. * Checks if the two quaternions are close to each other
  60005. * @param quat0 defines the first quaternion to check
  60006. * @param quat1 defines the second quaternion to check
  60007. * @returns true if the two quaternions are close to each other
  60008. */
  60009. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  60010. /**
  60011. * Creates an empty quaternion
  60012. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  60013. */
  60014. static Zero(): Quaternion;
  60015. /**
  60016. * Inverse a given quaternion
  60017. * @param q defines the source quaternion
  60018. * @returns a new quaternion as the inverted current quaternion
  60019. */
  60020. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  60021. /**
  60022. * Inverse a given quaternion
  60023. * @param q defines the source quaternion
  60024. * @param result the quaternion the result will be stored in
  60025. * @returns the result quaternion
  60026. */
  60027. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  60028. /**
  60029. * Creates an identity quaternion
  60030. * @returns the identity quaternion
  60031. */
  60032. static Identity(): Quaternion;
  60033. /**
  60034. * Gets a boolean indicating if the given quaternion is identity
  60035. * @param quaternion defines the quaternion to check
  60036. * @returns true if the quaternion is identity
  60037. */
  60038. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  60039. /**
  60040. * Creates a quaternion from a rotation around an axis
  60041. * @param axis defines the axis to use
  60042. * @param angle defines the angle to use
  60043. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  60044. */
  60045. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  60046. /**
  60047. * Creates a rotation around an axis and stores it into the given quaternion
  60048. * @param axis defines the axis to use
  60049. * @param angle defines the angle to use
  60050. * @param result defines the target quaternion
  60051. * @returns the target quaternion
  60052. */
  60053. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  60054. /**
  60055. * Creates a new quaternion from data stored into an array
  60056. * @param array defines the data source
  60057. * @param offset defines the offset in the source array where the data starts
  60058. * @returns a new quaternion
  60059. */
  60060. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  60061. /**
  60062. * Create a quaternion from Euler rotation angles
  60063. * @param x Pitch
  60064. * @param y Yaw
  60065. * @param z Roll
  60066. * @returns the new Quaternion
  60067. */
  60068. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  60069. /**
  60070. * Updates a quaternion from Euler rotation angles
  60071. * @param x Pitch
  60072. * @param y Yaw
  60073. * @param z Roll
  60074. * @param result the quaternion to store the result
  60075. * @returns the updated quaternion
  60076. */
  60077. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  60078. /**
  60079. * Create a quaternion from Euler rotation vector
  60080. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60081. * @returns the new Quaternion
  60082. */
  60083. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  60084. /**
  60085. * Updates a quaternion from Euler rotation vector
  60086. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60087. * @param result the quaternion to store the result
  60088. * @returns the updated quaternion
  60089. */
  60090. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  60091. /**
  60092. * Creates a new quaternion from the given Euler float angles (y, x, z)
  60093. * @param yaw defines the rotation around Y axis
  60094. * @param pitch defines the rotation around X axis
  60095. * @param roll defines the rotation around Z axis
  60096. * @returns the new quaternion
  60097. */
  60098. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  60099. /**
  60100. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  60101. * @param yaw defines the rotation around Y axis
  60102. * @param pitch defines the rotation around X axis
  60103. * @param roll defines the rotation around Z axis
  60104. * @param result defines the target quaternion
  60105. */
  60106. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  60107. /**
  60108. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  60109. * @param alpha defines the rotation around first axis
  60110. * @param beta defines the rotation around second axis
  60111. * @param gamma defines the rotation around third axis
  60112. * @returns the new quaternion
  60113. */
  60114. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  60115. /**
  60116. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  60117. * @param alpha defines the rotation around first axis
  60118. * @param beta defines the rotation around second axis
  60119. * @param gamma defines the rotation around third axis
  60120. * @param result defines the target quaternion
  60121. */
  60122. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  60123. /**
  60124. * 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)
  60125. * @param axis1 defines the first axis
  60126. * @param axis2 defines the second axis
  60127. * @param axis3 defines the third axis
  60128. * @returns the new quaternion
  60129. */
  60130. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  60131. /**
  60132. * 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
  60133. * @param axis1 defines the first axis
  60134. * @param axis2 defines the second axis
  60135. * @param axis3 defines the third axis
  60136. * @param ref defines the target quaternion
  60137. */
  60138. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  60139. /**
  60140. * Interpolates between two quaternions
  60141. * @param left defines first quaternion
  60142. * @param right defines second quaternion
  60143. * @param amount defines the gradient to use
  60144. * @returns the new interpolated quaternion
  60145. */
  60146. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60147. /**
  60148. * Interpolates between two quaternions and stores it into a target quaternion
  60149. * @param left defines first quaternion
  60150. * @param right defines second quaternion
  60151. * @param amount defines the gradient to use
  60152. * @param result defines the target quaternion
  60153. */
  60154. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  60155. /**
  60156. * Interpolate between two quaternions using Hermite interpolation
  60157. * @param value1 defines first quaternion
  60158. * @param tangent1 defines the incoming tangent
  60159. * @param value2 defines second quaternion
  60160. * @param tangent2 defines the outgoing tangent
  60161. * @param amount defines the target quaternion
  60162. * @returns the new interpolated quaternion
  60163. */
  60164. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60165. }
  60166. /**
  60167. * Class used to store matrix data (4x4)
  60168. */
  60169. export class Matrix {
  60170. private static _updateFlagSeed;
  60171. private static _identityReadOnly;
  60172. private _isIdentity;
  60173. private _isIdentityDirty;
  60174. private _isIdentity3x2;
  60175. private _isIdentity3x2Dirty;
  60176. /**
  60177. * Gets the update flag of the matrix which is an unique number for the matrix.
  60178. * It will be incremented every time the matrix data change.
  60179. * You can use it to speed the comparison between two versions of the same matrix.
  60180. */
  60181. updateFlag: number;
  60182. private readonly _m;
  60183. /**
  60184. * Gets the internal data of the matrix
  60185. */
  60186. readonly m: DeepImmutable<Float32Array>;
  60187. /** @hidden */
  60188. _markAsUpdated(): void;
  60189. /** @hidden */
  60190. private _updateIdentityStatus;
  60191. /**
  60192. * Creates an empty matrix (filled with zeros)
  60193. */
  60194. constructor();
  60195. /**
  60196. * Check if the current matrix is identity
  60197. * @returns true is the matrix is the identity matrix
  60198. */
  60199. isIdentity(): boolean;
  60200. /**
  60201. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  60202. * @returns true is the matrix is the identity matrix
  60203. */
  60204. isIdentityAs3x2(): boolean;
  60205. /**
  60206. * Gets the determinant of the matrix
  60207. * @returns the matrix determinant
  60208. */
  60209. determinant(): number;
  60210. /**
  60211. * Returns the matrix as a Float32Array
  60212. * @returns the matrix underlying array
  60213. */
  60214. toArray(): DeepImmutable<Float32Array>;
  60215. /**
  60216. * Returns the matrix as a Float32Array
  60217. * @returns the matrix underlying array.
  60218. */
  60219. asArray(): DeepImmutable<Float32Array>;
  60220. /**
  60221. * Inverts the current matrix in place
  60222. * @returns the current inverted matrix
  60223. */
  60224. invert(): Matrix;
  60225. /**
  60226. * Sets all the matrix elements to zero
  60227. * @returns the current matrix
  60228. */
  60229. reset(): Matrix;
  60230. /**
  60231. * Adds the current matrix with a second one
  60232. * @param other defines the matrix to add
  60233. * @returns a new matrix as the addition of the current matrix and the given one
  60234. */
  60235. add(other: DeepImmutable<Matrix>): Matrix;
  60236. /**
  60237. * Sets the given matrix "result" to the addition of the current matrix and the given one
  60238. * @param other defines the matrix to add
  60239. * @param result defines the target matrix
  60240. * @returns the current matrix
  60241. */
  60242. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60243. /**
  60244. * Adds in place the given matrix to the current matrix
  60245. * @param other defines the second operand
  60246. * @returns the current updated matrix
  60247. */
  60248. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  60249. /**
  60250. * Sets the given matrix to the current inverted Matrix
  60251. * @param other defines the target matrix
  60252. * @returns the unmodified current matrix
  60253. */
  60254. invertToRef(other: Matrix): Matrix;
  60255. /**
  60256. * add a value at the specified position in the current Matrix
  60257. * @param index the index of the value within the matrix. between 0 and 15.
  60258. * @param value the value to be added
  60259. * @returns the current updated matrix
  60260. */
  60261. addAtIndex(index: number, value: number): Matrix;
  60262. /**
  60263. * mutiply the specified position in the current Matrix by a value
  60264. * @param index the index of the value within the matrix. between 0 and 15.
  60265. * @param value the value to be added
  60266. * @returns the current updated matrix
  60267. */
  60268. multiplyAtIndex(index: number, value: number): Matrix;
  60269. /**
  60270. * Inserts the translation vector (using 3 floats) in the current matrix
  60271. * @param x defines the 1st component of the translation
  60272. * @param y defines the 2nd component of the translation
  60273. * @param z defines the 3rd component of the translation
  60274. * @returns the current updated matrix
  60275. */
  60276. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  60277. /**
  60278. * Inserts the translation vector in the current matrix
  60279. * @param vector3 defines the translation to insert
  60280. * @returns the current updated matrix
  60281. */
  60282. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  60283. /**
  60284. * Gets the translation value of the current matrix
  60285. * @returns a new Vector3 as the extracted translation from the matrix
  60286. */
  60287. getTranslation(): Vector3;
  60288. /**
  60289. * Fill a Vector3 with the extracted translation from the matrix
  60290. * @param result defines the Vector3 where to store the translation
  60291. * @returns the current matrix
  60292. */
  60293. getTranslationToRef(result: Vector3): Matrix;
  60294. /**
  60295. * Remove rotation and scaling part from the matrix
  60296. * @returns the updated matrix
  60297. */
  60298. removeRotationAndScaling(): Matrix;
  60299. /**
  60300. * Multiply two matrices
  60301. * @param other defines the second operand
  60302. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  60303. */
  60304. multiply(other: DeepImmutable<Matrix>): Matrix;
  60305. /**
  60306. * Copy the current matrix from the given one
  60307. * @param other defines the source matrix
  60308. * @returns the current updated matrix
  60309. */
  60310. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  60311. /**
  60312. * Populates the given array from the starting index with the current matrix values
  60313. * @param array defines the target array
  60314. * @param offset defines the offset in the target array where to start storing values
  60315. * @returns the current matrix
  60316. */
  60317. copyToArray(array: Float32Array, offset?: number): Matrix;
  60318. /**
  60319. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  60320. * @param other defines the second operand
  60321. * @param result defines the matrix where to store the multiplication
  60322. * @returns the current matrix
  60323. */
  60324. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60325. /**
  60326. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  60327. * @param other defines the second operand
  60328. * @param result defines the array where to store the multiplication
  60329. * @param offset defines the offset in the target array where to start storing values
  60330. * @returns the current matrix
  60331. */
  60332. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  60333. /**
  60334. * Check equality between this matrix and a second one
  60335. * @param value defines the second matrix to compare
  60336. * @returns true is the current matrix and the given one values are strictly equal
  60337. */
  60338. equals(value: DeepImmutable<Matrix>): boolean;
  60339. /**
  60340. * Clone the current matrix
  60341. * @returns a new matrix from the current matrix
  60342. */
  60343. clone(): Matrix;
  60344. /**
  60345. * Returns the name of the current matrix class
  60346. * @returns the string "Matrix"
  60347. */
  60348. getClassName(): string;
  60349. /**
  60350. * Gets the hash code of the current matrix
  60351. * @returns the hash code
  60352. */
  60353. getHashCode(): number;
  60354. /**
  60355. * Decomposes the current Matrix into a translation, rotation and scaling components
  60356. * @param scale defines the scale vector3 given as a reference to update
  60357. * @param rotation defines the rotation quaternion given as a reference to update
  60358. * @param translation defines the translation vector3 given as a reference to update
  60359. * @returns true if operation was successful
  60360. */
  60361. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  60362. /**
  60363. * Gets specific row of the matrix
  60364. * @param index defines the number of the row to get
  60365. * @returns the index-th row of the current matrix as a new Vector4
  60366. */
  60367. getRow(index: number): Nullable<Vector4>;
  60368. /**
  60369. * Sets the index-th row of the current matrix to the vector4 values
  60370. * @param index defines the number of the row to set
  60371. * @param row defines the target vector4
  60372. * @returns the updated current matrix
  60373. */
  60374. setRow(index: number, row: Vector4): Matrix;
  60375. /**
  60376. * Compute the transpose of the matrix
  60377. * @returns the new transposed matrix
  60378. */
  60379. transpose(): Matrix;
  60380. /**
  60381. * Compute the transpose of the matrix and store it in a given matrix
  60382. * @param result defines the target matrix
  60383. * @returns the current matrix
  60384. */
  60385. transposeToRef(result: Matrix): Matrix;
  60386. /**
  60387. * Sets the index-th row of the current matrix with the given 4 x float values
  60388. * @param index defines the row index
  60389. * @param x defines the x component to set
  60390. * @param y defines the y component to set
  60391. * @param z defines the z component to set
  60392. * @param w defines the w component to set
  60393. * @returns the updated current matrix
  60394. */
  60395. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  60396. /**
  60397. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  60398. * @param scale defines the scale factor
  60399. * @returns a new matrix
  60400. */
  60401. scale(scale: number): Matrix;
  60402. /**
  60403. * Scale the current matrix values by a factor to a given result matrix
  60404. * @param scale defines the scale factor
  60405. * @param result defines the matrix to store the result
  60406. * @returns the current matrix
  60407. */
  60408. scaleToRef(scale: number, result: Matrix): Matrix;
  60409. /**
  60410. * Scale the current matrix values by a factor and add the result to a given matrix
  60411. * @param scale defines the scale factor
  60412. * @param result defines the Matrix to store the result
  60413. * @returns the current matrix
  60414. */
  60415. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  60416. /**
  60417. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  60418. * @param ref matrix to store the result
  60419. */
  60420. toNormalMatrix(ref: Matrix): void;
  60421. /**
  60422. * Gets only rotation part of the current matrix
  60423. * @returns a new matrix sets to the extracted rotation matrix from the current one
  60424. */
  60425. getRotationMatrix(): Matrix;
  60426. /**
  60427. * Extracts the rotation matrix from the current one and sets it as the given "result"
  60428. * @param result defines the target matrix to store data to
  60429. * @returns the current matrix
  60430. */
  60431. getRotationMatrixToRef(result: Matrix): Matrix;
  60432. /**
  60433. * Toggles model matrix from being right handed to left handed in place and vice versa
  60434. */
  60435. toggleModelMatrixHandInPlace(): void;
  60436. /**
  60437. * Toggles projection matrix from being right handed to left handed in place and vice versa
  60438. */
  60439. toggleProjectionMatrixHandInPlace(): void;
  60440. /**
  60441. * Creates a matrix from an array
  60442. * @param array defines the source array
  60443. * @param offset defines an offset in the source array
  60444. * @returns a new Matrix set from the starting index of the given array
  60445. */
  60446. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  60447. /**
  60448. * Copy the content of an array into a given matrix
  60449. * @param array defines the source array
  60450. * @param offset defines an offset in the source array
  60451. * @param result defines the target matrix
  60452. */
  60453. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  60454. /**
  60455. * Stores an array into a matrix after having multiplied each component by a given factor
  60456. * @param array defines the source array
  60457. * @param offset defines the offset in the source array
  60458. * @param scale defines the scaling factor
  60459. * @param result defines the target matrix
  60460. */
  60461. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  60462. /**
  60463. * Gets an identity matrix that must not be updated
  60464. */
  60465. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  60466. /**
  60467. * Stores a list of values (16) inside a given matrix
  60468. * @param initialM11 defines 1st value of 1st row
  60469. * @param initialM12 defines 2nd value of 1st row
  60470. * @param initialM13 defines 3rd value of 1st row
  60471. * @param initialM14 defines 4th value of 1st row
  60472. * @param initialM21 defines 1st value of 2nd row
  60473. * @param initialM22 defines 2nd value of 2nd row
  60474. * @param initialM23 defines 3rd value of 2nd row
  60475. * @param initialM24 defines 4th value of 2nd row
  60476. * @param initialM31 defines 1st value of 3rd row
  60477. * @param initialM32 defines 2nd value of 3rd row
  60478. * @param initialM33 defines 3rd value of 3rd row
  60479. * @param initialM34 defines 4th value of 3rd row
  60480. * @param initialM41 defines 1st value of 4th row
  60481. * @param initialM42 defines 2nd value of 4th row
  60482. * @param initialM43 defines 3rd value of 4th row
  60483. * @param initialM44 defines 4th value of 4th row
  60484. * @param result defines the target matrix
  60485. */
  60486. 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;
  60487. /**
  60488. * Creates new matrix from a list of values (16)
  60489. * @param initialM11 defines 1st value of 1st row
  60490. * @param initialM12 defines 2nd value of 1st row
  60491. * @param initialM13 defines 3rd value of 1st row
  60492. * @param initialM14 defines 4th value of 1st row
  60493. * @param initialM21 defines 1st value of 2nd row
  60494. * @param initialM22 defines 2nd value of 2nd row
  60495. * @param initialM23 defines 3rd value of 2nd row
  60496. * @param initialM24 defines 4th value of 2nd row
  60497. * @param initialM31 defines 1st value of 3rd row
  60498. * @param initialM32 defines 2nd value of 3rd row
  60499. * @param initialM33 defines 3rd value of 3rd row
  60500. * @param initialM34 defines 4th value of 3rd row
  60501. * @param initialM41 defines 1st value of 4th row
  60502. * @param initialM42 defines 2nd value of 4th row
  60503. * @param initialM43 defines 3rd value of 4th row
  60504. * @param initialM44 defines 4th value of 4th row
  60505. * @returns the new matrix
  60506. */
  60507. 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;
  60508. /**
  60509. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60510. * @param scale defines the scale vector3
  60511. * @param rotation defines the rotation quaternion
  60512. * @param translation defines the translation vector3
  60513. * @returns a new matrix
  60514. */
  60515. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  60516. /**
  60517. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60518. * @param scale defines the scale vector3
  60519. * @param rotation defines the rotation quaternion
  60520. * @param translation defines the translation vector3
  60521. * @param result defines the target matrix
  60522. */
  60523. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  60524. /**
  60525. * Creates a new identity matrix
  60526. * @returns a new identity matrix
  60527. */
  60528. static Identity(): Matrix;
  60529. /**
  60530. * Creates a new identity matrix and stores the result in a given matrix
  60531. * @param result defines the target matrix
  60532. */
  60533. static IdentityToRef(result: Matrix): void;
  60534. /**
  60535. * Creates a new zero matrix
  60536. * @returns a new zero matrix
  60537. */
  60538. static Zero(): Matrix;
  60539. /**
  60540. * Creates a new rotation matrix for "angle" radians around the X axis
  60541. * @param angle defines the angle (in radians) to use
  60542. * @return the new matrix
  60543. */
  60544. static RotationX(angle: number): Matrix;
  60545. /**
  60546. * Creates a new matrix as the invert of a given matrix
  60547. * @param source defines the source matrix
  60548. * @returns the new matrix
  60549. */
  60550. static Invert(source: DeepImmutable<Matrix>): Matrix;
  60551. /**
  60552. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  60553. * @param angle defines the angle (in radians) to use
  60554. * @param result defines the target matrix
  60555. */
  60556. static RotationXToRef(angle: number, result: Matrix): void;
  60557. /**
  60558. * Creates a new rotation matrix for "angle" radians around the Y axis
  60559. * @param angle defines the angle (in radians) to use
  60560. * @return the new matrix
  60561. */
  60562. static RotationY(angle: number): Matrix;
  60563. /**
  60564. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  60565. * @param angle defines the angle (in radians) to use
  60566. * @param result defines the target matrix
  60567. */
  60568. static RotationYToRef(angle: number, result: Matrix): void;
  60569. /**
  60570. * Creates a new rotation matrix for "angle" radians around the Z axis
  60571. * @param angle defines the angle (in radians) to use
  60572. * @return the new matrix
  60573. */
  60574. static RotationZ(angle: number): Matrix;
  60575. /**
  60576. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  60577. * @param angle defines the angle (in radians) to use
  60578. * @param result defines the target matrix
  60579. */
  60580. static RotationZToRef(angle: number, result: Matrix): void;
  60581. /**
  60582. * Creates a new rotation matrix for "angle" radians around the given axis
  60583. * @param axis defines the axis to use
  60584. * @param angle defines the angle (in radians) to use
  60585. * @return the new matrix
  60586. */
  60587. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  60588. /**
  60589. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  60590. * @param axis defines the axis to use
  60591. * @param angle defines the angle (in radians) to use
  60592. * @param result defines the target matrix
  60593. */
  60594. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  60595. /**
  60596. * Creates a rotation matrix
  60597. * @param yaw defines the yaw angle in radians (Y axis)
  60598. * @param pitch defines the pitch angle in radians (X axis)
  60599. * @param roll defines the roll angle in radians (X axis)
  60600. * @returns the new rotation matrix
  60601. */
  60602. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  60603. /**
  60604. * Creates a rotation matrix and stores it in a given matrix
  60605. * @param yaw defines the yaw angle in radians (Y axis)
  60606. * @param pitch defines the pitch angle in radians (X axis)
  60607. * @param roll defines the roll angle in radians (X axis)
  60608. * @param result defines the target matrix
  60609. */
  60610. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  60611. /**
  60612. * Creates a scaling matrix
  60613. * @param x defines the scale factor on X axis
  60614. * @param y defines the scale factor on Y axis
  60615. * @param z defines the scale factor on Z axis
  60616. * @returns the new matrix
  60617. */
  60618. static Scaling(x: number, y: number, z: number): Matrix;
  60619. /**
  60620. * Creates a scaling matrix and stores it in a given matrix
  60621. * @param x defines the scale factor on X axis
  60622. * @param y defines the scale factor on Y axis
  60623. * @param z defines the scale factor on Z axis
  60624. * @param result defines the target matrix
  60625. */
  60626. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  60627. /**
  60628. * Creates a translation matrix
  60629. * @param x defines the translation on X axis
  60630. * @param y defines the translation on Y axis
  60631. * @param z defines the translationon Z axis
  60632. * @returns the new matrix
  60633. */
  60634. static Translation(x: number, y: number, z: number): Matrix;
  60635. /**
  60636. * Creates a translation matrix and stores it in a given matrix
  60637. * @param x defines the translation on X axis
  60638. * @param y defines the translation on Y axis
  60639. * @param z defines the translationon Z axis
  60640. * @param result defines the target matrix
  60641. */
  60642. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  60643. /**
  60644. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60645. * @param startValue defines the start value
  60646. * @param endValue defines the end value
  60647. * @param gradient defines the gradient factor
  60648. * @returns the new matrix
  60649. */
  60650. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60651. /**
  60652. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60653. * @param startValue defines the start value
  60654. * @param endValue defines the end value
  60655. * @param gradient defines the gradient factor
  60656. * @param result defines the Matrix object where to store data
  60657. */
  60658. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60659. /**
  60660. * Builds a new matrix whose values are computed by:
  60661. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60662. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60663. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60664. * @param startValue defines the first matrix
  60665. * @param endValue defines the second matrix
  60666. * @param gradient defines the gradient between the two matrices
  60667. * @returns the new matrix
  60668. */
  60669. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60670. /**
  60671. * Update a matrix to values which are computed by:
  60672. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60673. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60674. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60675. * @param startValue defines the first matrix
  60676. * @param endValue defines the second matrix
  60677. * @param gradient defines the gradient between the two matrices
  60678. * @param result defines the target matrix
  60679. */
  60680. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60681. /**
  60682. * 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"
  60683. * This function works in left handed mode
  60684. * @param eye defines the final position of the entity
  60685. * @param target defines where the entity should look at
  60686. * @param up defines the up vector for the entity
  60687. * @returns the new matrix
  60688. */
  60689. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60690. /**
  60691. * 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".
  60692. * This function works in left handed mode
  60693. * @param eye defines the final position of the entity
  60694. * @param target defines where the entity should look at
  60695. * @param up defines the up vector for the entity
  60696. * @param result defines the target matrix
  60697. */
  60698. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60699. /**
  60700. * 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"
  60701. * This function works in right handed mode
  60702. * @param eye defines the final position of the entity
  60703. * @param target defines where the entity should look at
  60704. * @param up defines the up vector for the entity
  60705. * @returns the new matrix
  60706. */
  60707. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60708. /**
  60709. * 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".
  60710. * This function works in right handed mode
  60711. * @param eye defines the final position of the entity
  60712. * @param target defines where the entity should look at
  60713. * @param up defines the up vector for the entity
  60714. * @param result defines the target matrix
  60715. */
  60716. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60717. /**
  60718. * Create a left-handed orthographic projection matrix
  60719. * @param width defines the viewport width
  60720. * @param height defines the viewport height
  60721. * @param znear defines the near clip plane
  60722. * @param zfar defines the far clip plane
  60723. * @returns a new matrix as a left-handed orthographic projection matrix
  60724. */
  60725. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  60726. /**
  60727. * Store a left-handed orthographic projection to a given matrix
  60728. * @param width defines the viewport width
  60729. * @param height defines the viewport height
  60730. * @param znear defines the near clip plane
  60731. * @param zfar defines the far clip plane
  60732. * @param result defines the target matrix
  60733. */
  60734. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  60735. /**
  60736. * Create a left-handed orthographic projection matrix
  60737. * @param left defines the viewport left coordinate
  60738. * @param right defines the viewport right coordinate
  60739. * @param bottom defines the viewport bottom coordinate
  60740. * @param top defines the viewport top coordinate
  60741. * @param znear defines the near clip plane
  60742. * @param zfar defines the far clip plane
  60743. * @returns a new matrix as a left-handed orthographic projection matrix
  60744. */
  60745. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  60746. /**
  60747. * Stores a left-handed orthographic projection into a given matrix
  60748. * @param left defines the viewport left coordinate
  60749. * @param right defines the viewport right coordinate
  60750. * @param bottom defines the viewport bottom coordinate
  60751. * @param top defines the viewport top coordinate
  60752. * @param znear defines the near clip plane
  60753. * @param zfar defines the far clip plane
  60754. * @param result defines the target matrix
  60755. */
  60756. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  60757. /**
  60758. * Creates a right-handed orthographic projection matrix
  60759. * @param left defines the viewport left coordinate
  60760. * @param right defines the viewport right coordinate
  60761. * @param bottom defines the viewport bottom coordinate
  60762. * @param top defines the viewport top coordinate
  60763. * @param znear defines the near clip plane
  60764. * @param zfar defines the far clip plane
  60765. * @returns a new matrix as a right-handed orthographic projection matrix
  60766. */
  60767. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  60768. /**
  60769. * Stores a right-handed orthographic projection into a given matrix
  60770. * @param left defines the viewport left coordinate
  60771. * @param right defines the viewport right coordinate
  60772. * @param bottom defines the viewport bottom coordinate
  60773. * @param top defines the viewport top coordinate
  60774. * @param znear defines the near clip plane
  60775. * @param zfar defines the far clip plane
  60776. * @param result defines the target matrix
  60777. */
  60778. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  60779. /**
  60780. * Creates a left-handed perspective projection matrix
  60781. * @param width defines the viewport width
  60782. * @param height defines the viewport height
  60783. * @param znear defines the near clip plane
  60784. * @param zfar defines the far clip plane
  60785. * @returns a new matrix as a left-handed perspective projection matrix
  60786. */
  60787. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  60788. /**
  60789. * Creates a left-handed perspective projection matrix
  60790. * @param fov defines the horizontal field of view
  60791. * @param aspect defines the aspect ratio
  60792. * @param znear defines the near clip plane
  60793. * @param zfar defines the far clip plane
  60794. * @returns a new matrix as a left-handed perspective projection matrix
  60795. */
  60796. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  60797. /**
  60798. * Stores a left-handed perspective projection into a given matrix
  60799. * @param fov defines the horizontal field of view
  60800. * @param aspect defines the aspect ratio
  60801. * @param znear defines the near clip plane
  60802. * @param zfar defines the far clip plane
  60803. * @param result defines the target matrix
  60804. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  60805. */
  60806. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  60807. /**
  60808. * Creates a right-handed perspective projection matrix
  60809. * @param fov defines the horizontal field of view
  60810. * @param aspect defines the aspect ratio
  60811. * @param znear defines the near clip plane
  60812. * @param zfar defines the far clip plane
  60813. * @returns a new matrix as a right-handed perspective projection matrix
  60814. */
  60815. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  60816. /**
  60817. * Stores a right-handed perspective projection into a given matrix
  60818. * @param fov defines the horizontal field of view
  60819. * @param aspect defines the aspect ratio
  60820. * @param znear defines the near clip plane
  60821. * @param zfar defines the far clip plane
  60822. * @param result defines the target matrix
  60823. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  60824. */
  60825. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  60826. /**
  60827. * Stores a perspective projection for WebVR info a given matrix
  60828. * @param fov defines the field of view
  60829. * @param znear defines the near clip plane
  60830. * @param zfar defines the far clip plane
  60831. * @param result defines the target matrix
  60832. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  60833. */
  60834. static PerspectiveFovWebVRToRef(fov: {
  60835. upDegrees: number;
  60836. downDegrees: number;
  60837. leftDegrees: number;
  60838. rightDegrees: number;
  60839. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  60840. /**
  60841. * Computes a complete transformation matrix
  60842. * @param viewport defines the viewport to use
  60843. * @param world defines the world matrix
  60844. * @param view defines the view matrix
  60845. * @param projection defines the projection matrix
  60846. * @param zmin defines the near clip plane
  60847. * @param zmax defines the far clip plane
  60848. * @returns the transformation matrix
  60849. */
  60850. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  60851. /**
  60852. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  60853. * @param matrix defines the matrix to use
  60854. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  60855. */
  60856. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  60857. /**
  60858. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  60859. * @param matrix defines the matrix to use
  60860. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  60861. */
  60862. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  60863. /**
  60864. * Compute the transpose of a given matrix
  60865. * @param matrix defines the matrix to transpose
  60866. * @returns the new matrix
  60867. */
  60868. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  60869. /**
  60870. * Compute the transpose of a matrix and store it in a target matrix
  60871. * @param matrix defines the matrix to transpose
  60872. * @param result defines the target matrix
  60873. */
  60874. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  60875. /**
  60876. * Computes a reflection matrix from a plane
  60877. * @param plane defines the reflection plane
  60878. * @returns a new matrix
  60879. */
  60880. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  60881. /**
  60882. * Computes a reflection matrix from a plane
  60883. * @param plane defines the reflection plane
  60884. * @param result defines the target matrix
  60885. */
  60886. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  60887. /**
  60888. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  60889. * @param xaxis defines the value of the 1st axis
  60890. * @param yaxis defines the value of the 2nd axis
  60891. * @param zaxis defines the value of the 3rd axis
  60892. * @param result defines the target matrix
  60893. */
  60894. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  60895. /**
  60896. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  60897. * @param quat defines the quaternion to use
  60898. * @param result defines the target matrix
  60899. */
  60900. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  60901. }
  60902. /**
  60903. * Represens a plane by the equation ax + by + cz + d = 0
  60904. */
  60905. export class Plane {
  60906. /**
  60907. * Normal of the plane (a,b,c)
  60908. */
  60909. normal: Vector3;
  60910. /**
  60911. * d component of the plane
  60912. */
  60913. d: number;
  60914. /**
  60915. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  60916. * @param a a component of the plane
  60917. * @param b b component of the plane
  60918. * @param c c component of the plane
  60919. * @param d d component of the plane
  60920. */
  60921. constructor(a: number, b: number, c: number, d: number);
  60922. /**
  60923. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  60924. */
  60925. asArray(): number[];
  60926. /**
  60927. * @returns a new plane copied from the current Plane.
  60928. */
  60929. clone(): Plane;
  60930. /**
  60931. * @returns the string "Plane".
  60932. */
  60933. getClassName(): string;
  60934. /**
  60935. * @returns the Plane hash code.
  60936. */
  60937. getHashCode(): number;
  60938. /**
  60939. * Normalize the current Plane in place.
  60940. * @returns the updated Plane.
  60941. */
  60942. normalize(): Plane;
  60943. /**
  60944. * Applies a transformation the plane and returns the result
  60945. * @param transformation the transformation matrix to be applied to the plane
  60946. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  60947. */
  60948. transform(transformation: DeepImmutable<Matrix>): Plane;
  60949. /**
  60950. * Calcualtte the dot product between the point and the plane normal
  60951. * @param point point to calculate the dot product with
  60952. * @returns the dot product (float) of the point coordinates and the plane normal.
  60953. */
  60954. dotCoordinate(point: DeepImmutable<Vector3>): number;
  60955. /**
  60956. * Updates the current Plane from the plane defined by the three given points.
  60957. * @param point1 one of the points used to contruct the plane
  60958. * @param point2 one of the points used to contruct the plane
  60959. * @param point3 one of the points used to contruct the plane
  60960. * @returns the updated Plane.
  60961. */
  60962. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  60963. /**
  60964. * Checks if the plane is facing a given direction
  60965. * @param direction the direction to check if the plane is facing
  60966. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  60967. * @returns True is the vector "direction" is the same side than the plane normal.
  60968. */
  60969. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  60970. /**
  60971. * Calculates the distance to a point
  60972. * @param point point to calculate distance to
  60973. * @returns the signed distance (float) from the given point to the Plane.
  60974. */
  60975. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  60976. /**
  60977. * Creates a plane from an array
  60978. * @param array the array to create a plane from
  60979. * @returns a new Plane from the given array.
  60980. */
  60981. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  60982. /**
  60983. * Creates a plane from three points
  60984. * @param point1 point used to create the plane
  60985. * @param point2 point used to create the plane
  60986. * @param point3 point used to create the plane
  60987. * @returns a new Plane defined by the three given points.
  60988. */
  60989. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  60990. /**
  60991. * Creates a plane from an origin point and a normal
  60992. * @param origin origin of the plane to be constructed
  60993. * @param normal normal of the plane to be constructed
  60994. * @returns a new Plane the normal vector to this plane at the given origin point.
  60995. * Note : the vector "normal" is updated because normalized.
  60996. */
  60997. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  60998. /**
  60999. * Calculates the distance from a plane and a point
  61000. * @param origin origin of the plane to be constructed
  61001. * @param normal normal of the plane to be constructed
  61002. * @param point point to calculate distance to
  61003. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  61004. */
  61005. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  61006. }
  61007. /**
  61008. * Class used to represent a viewport on screen
  61009. */
  61010. export class Viewport {
  61011. /** viewport left coordinate */
  61012. x: number;
  61013. /** viewport top coordinate */
  61014. y: number;
  61015. /**viewport width */
  61016. width: number;
  61017. /** viewport height */
  61018. height: number;
  61019. /**
  61020. * Creates a Viewport object located at (x, y) and sized (width, height)
  61021. * @param x defines viewport left coordinate
  61022. * @param y defines viewport top coordinate
  61023. * @param width defines the viewport width
  61024. * @param height defines the viewport height
  61025. */
  61026. constructor(
  61027. /** viewport left coordinate */
  61028. x: number,
  61029. /** viewport top coordinate */
  61030. y: number,
  61031. /**viewport width */
  61032. width: number,
  61033. /** viewport height */
  61034. height: number);
  61035. /**
  61036. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  61037. * @param renderWidth defines the rendering width
  61038. * @param renderHeight defines the rendering height
  61039. * @returns a new Viewport
  61040. */
  61041. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  61042. /**
  61043. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  61044. * @param renderWidth defines the rendering width
  61045. * @param renderHeight defines the rendering height
  61046. * @param ref defines the target viewport
  61047. * @returns the current viewport
  61048. */
  61049. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  61050. /**
  61051. * Returns a new Viewport copied from the current one
  61052. * @returns a new Viewport
  61053. */
  61054. clone(): Viewport;
  61055. }
  61056. /**
  61057. * Reprasents a camera frustum
  61058. */
  61059. export class Frustum {
  61060. /**
  61061. * Gets the planes representing the frustum
  61062. * @param transform matrix to be applied to the returned planes
  61063. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  61064. */
  61065. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  61066. /**
  61067. * Gets the near frustum plane transformed by the transform matrix
  61068. * @param transform transformation matrix to be applied to the resulting frustum plane
  61069. * @param frustumPlane the resuling frustum plane
  61070. */
  61071. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61072. /**
  61073. * Gets the far frustum plane transformed by the transform matrix
  61074. * @param transform transformation matrix to be applied to the resulting frustum plane
  61075. * @param frustumPlane the resuling frustum plane
  61076. */
  61077. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61078. /**
  61079. * Gets the left frustum plane transformed by the transform matrix
  61080. * @param transform transformation matrix to be applied to the resulting frustum plane
  61081. * @param frustumPlane the resuling frustum plane
  61082. */
  61083. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61084. /**
  61085. * Gets the right frustum plane transformed by the transform matrix
  61086. * @param transform transformation matrix to be applied to the resulting frustum plane
  61087. * @param frustumPlane the resuling frustum plane
  61088. */
  61089. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61090. /**
  61091. * Gets the top frustum plane transformed by the transform matrix
  61092. * @param transform transformation matrix to be applied to the resulting frustum plane
  61093. * @param frustumPlane the resuling frustum plane
  61094. */
  61095. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61096. /**
  61097. * Gets the bottom frustum plane transformed by the transform matrix
  61098. * @param transform transformation matrix to be applied to the resulting frustum plane
  61099. * @param frustumPlane the resuling frustum plane
  61100. */
  61101. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61102. /**
  61103. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  61104. * @param transform transformation matrix to be applied to the resulting frustum planes
  61105. * @param frustumPlanes the resuling frustum planes
  61106. */
  61107. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  61108. }
  61109. /** Defines supported spaces */
  61110. export enum Space {
  61111. /** Local (object) space */
  61112. LOCAL = 0,
  61113. /** World space */
  61114. WORLD = 1,
  61115. /** Bone space */
  61116. BONE = 2
  61117. }
  61118. /** Defines the 3 main axes */
  61119. export class Axis {
  61120. /** X axis */
  61121. static X: Vector3;
  61122. /** Y axis */
  61123. static Y: Vector3;
  61124. /** Z axis */
  61125. static Z: Vector3;
  61126. }
  61127. /** Class used to represent a Bezier curve */
  61128. export class BezierCurve {
  61129. /**
  61130. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  61131. * @param t defines the time
  61132. * @param x1 defines the left coordinate on X axis
  61133. * @param y1 defines the left coordinate on Y axis
  61134. * @param x2 defines the right coordinate on X axis
  61135. * @param y2 defines the right coordinate on Y axis
  61136. * @returns the interpolated value
  61137. */
  61138. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  61139. }
  61140. /**
  61141. * Defines potential orientation for back face culling
  61142. */
  61143. export enum Orientation {
  61144. /**
  61145. * Clockwise
  61146. */
  61147. CW = 0,
  61148. /** Counter clockwise */
  61149. CCW = 1
  61150. }
  61151. /**
  61152. * Defines angle representation
  61153. */
  61154. export class Angle {
  61155. private _radians;
  61156. /**
  61157. * Creates an Angle object of "radians" radians (float).
  61158. * @param radians the angle in radians
  61159. */
  61160. constructor(radians: number);
  61161. /**
  61162. * Get value in degrees
  61163. * @returns the Angle value in degrees (float)
  61164. */
  61165. degrees(): number;
  61166. /**
  61167. * Get value in radians
  61168. * @returns the Angle value in radians (float)
  61169. */
  61170. radians(): number;
  61171. /**
  61172. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  61173. * @param a defines first vector
  61174. * @param b defines second vector
  61175. * @returns a new Angle
  61176. */
  61177. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  61178. /**
  61179. * Gets a new Angle object from the given float in radians
  61180. * @param radians defines the angle value in radians
  61181. * @returns a new Angle
  61182. */
  61183. static FromRadians(radians: number): Angle;
  61184. /**
  61185. * Gets a new Angle object from the given float in degrees
  61186. * @param degrees defines the angle value in degrees
  61187. * @returns a new Angle
  61188. */
  61189. static FromDegrees(degrees: number): Angle;
  61190. }
  61191. /**
  61192. * This represents an arc in a 2d space.
  61193. */
  61194. export class Arc2 {
  61195. /** Defines the start point of the arc */
  61196. startPoint: Vector2;
  61197. /** Defines the mid point of the arc */
  61198. midPoint: Vector2;
  61199. /** Defines the end point of the arc */
  61200. endPoint: Vector2;
  61201. /**
  61202. * Defines the center point of the arc.
  61203. */
  61204. centerPoint: Vector2;
  61205. /**
  61206. * Defines the radius of the arc.
  61207. */
  61208. radius: number;
  61209. /**
  61210. * Defines the angle of the arc (from mid point to end point).
  61211. */
  61212. angle: Angle;
  61213. /**
  61214. * Defines the start angle of the arc (from start point to middle point).
  61215. */
  61216. startAngle: Angle;
  61217. /**
  61218. * Defines the orientation of the arc (clock wise/counter clock wise).
  61219. */
  61220. orientation: Orientation;
  61221. /**
  61222. * Creates an Arc object from the three given points : start, middle and end.
  61223. * @param startPoint Defines the start point of the arc
  61224. * @param midPoint Defines the midlle point of the arc
  61225. * @param endPoint Defines the end point of the arc
  61226. */
  61227. constructor(
  61228. /** Defines the start point of the arc */
  61229. startPoint: Vector2,
  61230. /** Defines the mid point of the arc */
  61231. midPoint: Vector2,
  61232. /** Defines the end point of the arc */
  61233. endPoint: Vector2);
  61234. }
  61235. /**
  61236. * Represents a 2D path made up of multiple 2D points
  61237. */
  61238. export class Path2 {
  61239. private _points;
  61240. private _length;
  61241. /**
  61242. * If the path start and end point are the same
  61243. */
  61244. closed: boolean;
  61245. /**
  61246. * Creates a Path2 object from the starting 2D coordinates x and y.
  61247. * @param x the starting points x value
  61248. * @param y the starting points y value
  61249. */
  61250. constructor(x: number, y: number);
  61251. /**
  61252. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  61253. * @param x the added points x value
  61254. * @param y the added points y value
  61255. * @returns the updated Path2.
  61256. */
  61257. addLineTo(x: number, y: number): Path2;
  61258. /**
  61259. * 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.
  61260. * @param midX middle point x value
  61261. * @param midY middle point y value
  61262. * @param endX end point x value
  61263. * @param endY end point y value
  61264. * @param numberOfSegments (default: 36)
  61265. * @returns the updated Path2.
  61266. */
  61267. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  61268. /**
  61269. * Closes the Path2.
  61270. * @returns the Path2.
  61271. */
  61272. close(): Path2;
  61273. /**
  61274. * Gets the sum of the distance between each sequential point in the path
  61275. * @returns the Path2 total length (float).
  61276. */
  61277. length(): number;
  61278. /**
  61279. * Gets the points which construct the path
  61280. * @returns the Path2 internal array of points.
  61281. */
  61282. getPoints(): Vector2[];
  61283. /**
  61284. * Retreives the point at the distance aways from the starting point
  61285. * @param normalizedLengthPosition the length along the path to retreive the point from
  61286. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  61287. */
  61288. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  61289. /**
  61290. * Creates a new path starting from an x and y position
  61291. * @param x starting x value
  61292. * @param y starting y value
  61293. * @returns a new Path2 starting at the coordinates (x, y).
  61294. */
  61295. static StartingAt(x: number, y: number): Path2;
  61296. }
  61297. /**
  61298. * Represents a 3D path made up of multiple 3D points
  61299. */
  61300. export class Path3D {
  61301. /**
  61302. * an array of Vector3, the curve axis of the Path3D
  61303. */
  61304. path: Vector3[];
  61305. private _curve;
  61306. private _distances;
  61307. private _tangents;
  61308. private _normals;
  61309. private _binormals;
  61310. private _raw;
  61311. /**
  61312. * new Path3D(path, normal, raw)
  61313. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  61314. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  61315. * @param path an array of Vector3, the curve axis of the Path3D
  61316. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  61317. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  61318. */
  61319. constructor(
  61320. /**
  61321. * an array of Vector3, the curve axis of the Path3D
  61322. */
  61323. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  61324. /**
  61325. * Returns the Path3D array of successive Vector3 designing its curve.
  61326. * @returns the Path3D array of successive Vector3 designing its curve.
  61327. */
  61328. getCurve(): Vector3[];
  61329. /**
  61330. * Returns an array populated with tangent vectors on each Path3D curve point.
  61331. * @returns an array populated with tangent vectors on each Path3D curve point.
  61332. */
  61333. getTangents(): Vector3[];
  61334. /**
  61335. * Returns an array populated with normal vectors on each Path3D curve point.
  61336. * @returns an array populated with normal vectors on each Path3D curve point.
  61337. */
  61338. getNormals(): Vector3[];
  61339. /**
  61340. * Returns an array populated with binormal vectors on each Path3D curve point.
  61341. * @returns an array populated with binormal vectors on each Path3D curve point.
  61342. */
  61343. getBinormals(): Vector3[];
  61344. /**
  61345. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  61346. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  61347. */
  61348. getDistances(): number[];
  61349. /**
  61350. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  61351. * @param path path which all values are copied into the curves points
  61352. * @param firstNormal which should be projected onto the curve
  61353. * @returns the same object updated.
  61354. */
  61355. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  61356. private _compute;
  61357. private _getFirstNonNullVector;
  61358. private _getLastNonNullVector;
  61359. private _normalVector;
  61360. }
  61361. /**
  61362. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61363. * A Curve3 is designed from a series of successive Vector3.
  61364. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  61365. */
  61366. export class Curve3 {
  61367. private _points;
  61368. private _length;
  61369. /**
  61370. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  61371. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  61372. * @param v1 (Vector3) the control point
  61373. * @param v2 (Vector3) the end point of the Quadratic Bezier
  61374. * @param nbPoints (integer) the wanted number of points in the curve
  61375. * @returns the created Curve3
  61376. */
  61377. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61378. /**
  61379. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  61380. * @param v0 (Vector3) the origin point of the Cubic Bezier
  61381. * @param v1 (Vector3) the first control point
  61382. * @param v2 (Vector3) the second control point
  61383. * @param v3 (Vector3) the end point of the Cubic Bezier
  61384. * @param nbPoints (integer) the wanted number of points in the curve
  61385. * @returns the created Curve3
  61386. */
  61387. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61388. /**
  61389. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  61390. * @param p1 (Vector3) the origin point of the Hermite Spline
  61391. * @param t1 (Vector3) the tangent vector at the origin point
  61392. * @param p2 (Vector3) the end point of the Hermite Spline
  61393. * @param t2 (Vector3) the tangent vector at the end point
  61394. * @param nbPoints (integer) the wanted number of points in the curve
  61395. * @returns the created Curve3
  61396. */
  61397. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61398. /**
  61399. * Returns a Curve3 object along a CatmullRom Spline curve :
  61400. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  61401. * @param nbPoints (integer) the wanted number of points between each curve control points
  61402. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  61403. * @returns the created Curve3
  61404. */
  61405. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  61406. /**
  61407. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61408. * A Curve3 is designed from a series of successive Vector3.
  61409. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  61410. * @param points points which make up the curve
  61411. */
  61412. constructor(points: Vector3[]);
  61413. /**
  61414. * @returns the Curve3 stored array of successive Vector3
  61415. */
  61416. getPoints(): Vector3[];
  61417. /**
  61418. * @returns the computed length (float) of the curve.
  61419. */
  61420. length(): number;
  61421. /**
  61422. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  61423. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  61424. * curveA and curveB keep unchanged.
  61425. * @param curve the curve to continue from this curve
  61426. * @returns the newly constructed curve
  61427. */
  61428. continue(curve: DeepImmutable<Curve3>): Curve3;
  61429. private _computeLength;
  61430. }
  61431. /**
  61432. * Contains position and normal vectors for a vertex
  61433. */
  61434. export class PositionNormalVertex {
  61435. /** the position of the vertex (defaut: 0,0,0) */
  61436. position: Vector3;
  61437. /** the normal of the vertex (defaut: 0,1,0) */
  61438. normal: Vector3;
  61439. /**
  61440. * Creates a PositionNormalVertex
  61441. * @param position the position of the vertex (defaut: 0,0,0)
  61442. * @param normal the normal of the vertex (defaut: 0,1,0)
  61443. */
  61444. constructor(
  61445. /** the position of the vertex (defaut: 0,0,0) */
  61446. position?: Vector3,
  61447. /** the normal of the vertex (defaut: 0,1,0) */
  61448. normal?: Vector3);
  61449. /**
  61450. * Clones the PositionNormalVertex
  61451. * @returns the cloned PositionNormalVertex
  61452. */
  61453. clone(): PositionNormalVertex;
  61454. }
  61455. /**
  61456. * Contains position, normal and uv vectors for a vertex
  61457. */
  61458. export class PositionNormalTextureVertex {
  61459. /** the position of the vertex (defaut: 0,0,0) */
  61460. position: Vector3;
  61461. /** the normal of the vertex (defaut: 0,1,0) */
  61462. normal: Vector3;
  61463. /** the uv of the vertex (default: 0,0) */
  61464. uv: Vector2;
  61465. /**
  61466. * Creates a PositionNormalTextureVertex
  61467. * @param position the position of the vertex (defaut: 0,0,0)
  61468. * @param normal the normal of the vertex (defaut: 0,1,0)
  61469. * @param uv the uv of the vertex (default: 0,0)
  61470. */
  61471. constructor(
  61472. /** the position of the vertex (defaut: 0,0,0) */
  61473. position?: Vector3,
  61474. /** the normal of the vertex (defaut: 0,1,0) */
  61475. normal?: Vector3,
  61476. /** the uv of the vertex (default: 0,0) */
  61477. uv?: Vector2);
  61478. /**
  61479. * Clones the PositionNormalTextureVertex
  61480. * @returns the cloned PositionNormalTextureVertex
  61481. */
  61482. clone(): PositionNormalTextureVertex;
  61483. }
  61484. /**
  61485. * @hidden
  61486. */
  61487. export class Tmp {
  61488. static Color3: Color3[];
  61489. static Color4: Color4[];
  61490. static Vector2: Vector2[];
  61491. static Vector3: Vector3[];
  61492. static Vector4: Vector4[];
  61493. static Quaternion: Quaternion[];
  61494. static Matrix: Matrix[];
  61495. }
  61496. }
  61497. declare module BABYLON {
  61498. /**
  61499. * Class used to enable access to offline support
  61500. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61501. */
  61502. export interface IOfflineProvider {
  61503. /**
  61504. * Gets a boolean indicating if scene must be saved in the database
  61505. */
  61506. enableSceneOffline: boolean;
  61507. /**
  61508. * Gets a boolean indicating if textures must be saved in the database
  61509. */
  61510. enableTexturesOffline: boolean;
  61511. /**
  61512. * Open the offline support and make it available
  61513. * @param successCallback defines the callback to call on success
  61514. * @param errorCallback defines the callback to call on error
  61515. */
  61516. open(successCallback: () => void, errorCallback: () => void): void;
  61517. /**
  61518. * Loads an image from the offline support
  61519. * @param url defines the url to load from
  61520. * @param image defines the target DOM image
  61521. */
  61522. loadImage(url: string, image: HTMLImageElement): void;
  61523. /**
  61524. * Loads a file from offline support
  61525. * @param url defines the URL to load from
  61526. * @param sceneLoaded defines a callback to call on success
  61527. * @param progressCallBack defines a callback to call when progress changed
  61528. * @param errorCallback defines a callback to call on error
  61529. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61530. */
  61531. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61532. }
  61533. }
  61534. declare module BABYLON {
  61535. /**
  61536. * A class serves as a medium between the observable and its observers
  61537. */
  61538. export class EventState {
  61539. /**
  61540. * Create a new EventState
  61541. * @param mask defines the mask associated with this state
  61542. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61543. * @param target defines the original target of the state
  61544. * @param currentTarget defines the current target of the state
  61545. */
  61546. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  61547. /**
  61548. * Initialize the current event state
  61549. * @param mask defines the mask associated with this state
  61550. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61551. * @param target defines the original target of the state
  61552. * @param currentTarget defines the current target of the state
  61553. * @returns the current event state
  61554. */
  61555. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  61556. /**
  61557. * An Observer can set this property to true to prevent subsequent observers of being notified
  61558. */
  61559. skipNextObservers: boolean;
  61560. /**
  61561. * Get the mask value that were used to trigger the event corresponding to this EventState object
  61562. */
  61563. mask: number;
  61564. /**
  61565. * The object that originally notified the event
  61566. */
  61567. target?: any;
  61568. /**
  61569. * The current object in the bubbling phase
  61570. */
  61571. currentTarget?: any;
  61572. /**
  61573. * This will be populated with the return value of the last function that was executed.
  61574. * If it is the first function in the callback chain it will be the event data.
  61575. */
  61576. lastReturnValue?: any;
  61577. }
  61578. /**
  61579. * Represent an Observer registered to a given Observable object.
  61580. */
  61581. export class Observer<T> {
  61582. /**
  61583. * Defines the callback to call when the observer is notified
  61584. */
  61585. callback: (eventData: T, eventState: EventState) => void;
  61586. /**
  61587. * Defines the mask of the observer (used to filter notifications)
  61588. */
  61589. mask: number;
  61590. /**
  61591. * Defines the current scope used to restore the JS context
  61592. */
  61593. scope: any;
  61594. /** @hidden */
  61595. _willBeUnregistered: boolean;
  61596. /**
  61597. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  61598. */
  61599. unregisterOnNextCall: boolean;
  61600. /**
  61601. * Creates a new observer
  61602. * @param callback defines the callback to call when the observer is notified
  61603. * @param mask defines the mask of the observer (used to filter notifications)
  61604. * @param scope defines the current scope used to restore the JS context
  61605. */
  61606. constructor(
  61607. /**
  61608. * Defines the callback to call when the observer is notified
  61609. */
  61610. callback: (eventData: T, eventState: EventState) => void,
  61611. /**
  61612. * Defines the mask of the observer (used to filter notifications)
  61613. */
  61614. mask: number,
  61615. /**
  61616. * Defines the current scope used to restore the JS context
  61617. */
  61618. scope?: any);
  61619. }
  61620. /**
  61621. * Represent a list of observers registered to multiple Observables object.
  61622. */
  61623. export class MultiObserver<T> {
  61624. private _observers;
  61625. private _observables;
  61626. /**
  61627. * Release associated resources
  61628. */
  61629. dispose(): void;
  61630. /**
  61631. * Raise a callback when one of the observable will notify
  61632. * @param observables defines a list of observables to watch
  61633. * @param callback defines the callback to call on notification
  61634. * @param mask defines the mask used to filter notifications
  61635. * @param scope defines the current scope used to restore the JS context
  61636. * @returns the new MultiObserver
  61637. */
  61638. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  61639. }
  61640. /**
  61641. * The Observable class is a simple implementation of the Observable pattern.
  61642. *
  61643. * 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.
  61644. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  61645. * 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).
  61646. * 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.
  61647. */
  61648. export class Observable<T> {
  61649. private _observers;
  61650. private _eventState;
  61651. private _onObserverAdded;
  61652. /**
  61653. * Creates a new observable
  61654. * @param onObserverAdded defines a callback to call when a new observer is added
  61655. */
  61656. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  61657. /**
  61658. * Create a new Observer with the specified callback
  61659. * @param callback the callback that will be executed for that Observer
  61660. * @param mask the mask used to filter observers
  61661. * @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.
  61662. * @param scope optional scope for the callback to be called from
  61663. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  61664. * @returns the new observer created for the callback
  61665. */
  61666. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  61667. /**
  61668. * Create a new Observer with the specified callback and unregisters after the next notification
  61669. * @param callback the callback that will be executed for that Observer
  61670. * @returns the new observer created for the callback
  61671. */
  61672. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  61673. /**
  61674. * Remove an Observer from the Observable object
  61675. * @param observer the instance of the Observer to remove
  61676. * @returns false if it doesn't belong to this Observable
  61677. */
  61678. remove(observer: Nullable<Observer<T>>): boolean;
  61679. /**
  61680. * Remove a callback from the Observable object
  61681. * @param callback the callback to remove
  61682. * @param scope optional scope. If used only the callbacks with this scope will be removed
  61683. * @returns false if it doesn't belong to this Observable
  61684. */
  61685. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  61686. private _deferUnregister;
  61687. private _remove;
  61688. /**
  61689. * Notify all Observers by calling their respective callback with the given data
  61690. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  61691. * @param eventData defines the data to send to all observers
  61692. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  61693. * @param target defines the original target of the state
  61694. * @param currentTarget defines the current target of the state
  61695. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  61696. */
  61697. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  61698. /**
  61699. * Calling this will execute each callback, expecting it to be a promise or return a value.
  61700. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  61701. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  61702. * and it is crucial that all callbacks will be executed.
  61703. * The order of the callbacks is kept, callbacks are not executed parallel.
  61704. *
  61705. * @param eventData The data to be sent to each callback
  61706. * @param mask is used to filter observers defaults to -1
  61707. * @param target defines the callback target (see EventState)
  61708. * @param currentTarget defines he current object in the bubbling phase
  61709. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  61710. */
  61711. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  61712. /**
  61713. * Notify a specific observer
  61714. * @param observer defines the observer to notify
  61715. * @param eventData defines the data to be sent to each callback
  61716. * @param mask is used to filter observers defaults to -1
  61717. */
  61718. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  61719. /**
  61720. * Gets a boolean indicating if the observable has at least one observer
  61721. * @returns true is the Observable has at least one Observer registered
  61722. */
  61723. hasObservers(): boolean;
  61724. /**
  61725. * Clear the list of observers
  61726. */
  61727. clear(): void;
  61728. /**
  61729. * Clone the current observable
  61730. * @returns a new observable
  61731. */
  61732. clone(): Observable<T>;
  61733. /**
  61734. * Does this observable handles observer registered with a given mask
  61735. * @param mask defines the mask to be tested
  61736. * @return whether or not one observer registered with the given mask is handeled
  61737. **/
  61738. hasSpecificMask(mask?: number): boolean;
  61739. }
  61740. }
  61741. declare module BABYLON {
  61742. /**
  61743. * Class used to help managing file picking and drag'n'drop
  61744. * File Storage
  61745. */
  61746. export class FilesInputStore {
  61747. /**
  61748. * List of files ready to be loaded
  61749. */
  61750. static FilesToLoad: {
  61751. [key: string]: File;
  61752. };
  61753. }
  61754. }
  61755. declare module BABYLON {
  61756. /** Defines the cross module used constants to avoid circular dependncies */
  61757. export class Constants {
  61758. /** Defines that alpha blending is disabled */
  61759. static readonly ALPHA_DISABLE: number;
  61760. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  61761. static readonly ALPHA_ADD: number;
  61762. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  61763. static readonly ALPHA_COMBINE: number;
  61764. /** Defines that alpha blending to DEST - SRC * DEST */
  61765. static readonly ALPHA_SUBTRACT: number;
  61766. /** Defines that alpha blending to SRC * DEST */
  61767. static readonly ALPHA_MULTIPLY: number;
  61768. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  61769. static readonly ALPHA_MAXIMIZED: number;
  61770. /** Defines that alpha blending to SRC + DEST */
  61771. static readonly ALPHA_ONEONE: number;
  61772. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  61773. static readonly ALPHA_PREMULTIPLIED: number;
  61774. /**
  61775. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  61776. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  61777. */
  61778. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  61779. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  61780. static readonly ALPHA_INTERPOLATE: number;
  61781. /**
  61782. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  61783. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  61784. */
  61785. static readonly ALPHA_SCREENMODE: number;
  61786. /** Defines that the ressource is not delayed*/
  61787. static readonly DELAYLOADSTATE_NONE: number;
  61788. /** Defines that the ressource was successfully delay loaded */
  61789. static readonly DELAYLOADSTATE_LOADED: number;
  61790. /** Defines that the ressource is currently delay loading */
  61791. static readonly DELAYLOADSTATE_LOADING: number;
  61792. /** Defines that the ressource is delayed and has not started loading */
  61793. static readonly DELAYLOADSTATE_NOTLOADED: number;
  61794. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  61795. static readonly NEVER: number;
  61796. /** 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 */
  61797. static readonly ALWAYS: number;
  61798. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  61799. static readonly LESS: number;
  61800. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  61801. static readonly EQUAL: number;
  61802. /** 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 */
  61803. static readonly LEQUAL: number;
  61804. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  61805. static readonly GREATER: number;
  61806. /** 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 */
  61807. static readonly GEQUAL: number;
  61808. /** 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 */
  61809. static readonly NOTEQUAL: number;
  61810. /** Passed to stencilOperation to specify that stencil value must be kept */
  61811. static readonly KEEP: number;
  61812. /** Passed to stencilOperation to specify that stencil value must be replaced */
  61813. static readonly REPLACE: number;
  61814. /** Passed to stencilOperation to specify that stencil value must be incremented */
  61815. static readonly INCR: number;
  61816. /** Passed to stencilOperation to specify that stencil value must be decremented */
  61817. static readonly DECR: number;
  61818. /** Passed to stencilOperation to specify that stencil value must be inverted */
  61819. static readonly INVERT: number;
  61820. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  61821. static readonly INCR_WRAP: number;
  61822. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  61823. static readonly DECR_WRAP: number;
  61824. /** Texture is not repeating outside of 0..1 UVs */
  61825. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  61826. /** Texture is repeating outside of 0..1 UVs */
  61827. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  61828. /** Texture is repeating and mirrored */
  61829. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  61830. /** ALPHA */
  61831. static readonly TEXTUREFORMAT_ALPHA: number;
  61832. /** LUMINANCE */
  61833. static readonly TEXTUREFORMAT_LUMINANCE: number;
  61834. /** LUMINANCE_ALPHA */
  61835. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  61836. /** RGB */
  61837. static readonly TEXTUREFORMAT_RGB: number;
  61838. /** RGBA */
  61839. static readonly TEXTUREFORMAT_RGBA: number;
  61840. /** RED */
  61841. static readonly TEXTUREFORMAT_RED: number;
  61842. /** RED (2nd reference) */
  61843. static readonly TEXTUREFORMAT_R: number;
  61844. /** RG */
  61845. static readonly TEXTUREFORMAT_RG: number;
  61846. /** RED_INTEGER */
  61847. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  61848. /** RED_INTEGER (2nd reference) */
  61849. static readonly TEXTUREFORMAT_R_INTEGER: number;
  61850. /** RG_INTEGER */
  61851. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  61852. /** RGB_INTEGER */
  61853. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  61854. /** RGBA_INTEGER */
  61855. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  61856. /** UNSIGNED_BYTE */
  61857. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  61858. /** UNSIGNED_BYTE (2nd reference) */
  61859. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  61860. /** FLOAT */
  61861. static readonly TEXTURETYPE_FLOAT: number;
  61862. /** HALF_FLOAT */
  61863. static readonly TEXTURETYPE_HALF_FLOAT: number;
  61864. /** BYTE */
  61865. static readonly TEXTURETYPE_BYTE: number;
  61866. /** SHORT */
  61867. static readonly TEXTURETYPE_SHORT: number;
  61868. /** UNSIGNED_SHORT */
  61869. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  61870. /** INT */
  61871. static readonly TEXTURETYPE_INT: number;
  61872. /** UNSIGNED_INT */
  61873. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  61874. /** UNSIGNED_SHORT_4_4_4_4 */
  61875. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  61876. /** UNSIGNED_SHORT_5_5_5_1 */
  61877. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  61878. /** UNSIGNED_SHORT_5_6_5 */
  61879. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  61880. /** UNSIGNED_INT_2_10_10_10_REV */
  61881. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  61882. /** UNSIGNED_INT_24_8 */
  61883. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  61884. /** UNSIGNED_INT_10F_11F_11F_REV */
  61885. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  61886. /** UNSIGNED_INT_5_9_9_9_REV */
  61887. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  61888. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  61889. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61890. /** nearest is mag = nearest and min = nearest and mip = linear */
  61891. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  61892. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61893. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  61894. /** Trilinear is mag = linear and min = linear and mip = linear */
  61895. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  61896. /** nearest is mag = nearest and min = nearest and mip = linear */
  61897. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  61898. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61899. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  61900. /** Trilinear is mag = linear and min = linear and mip = linear */
  61901. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  61902. /** mag = nearest and min = nearest and mip = nearest */
  61903. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  61904. /** mag = nearest and min = linear and mip = nearest */
  61905. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  61906. /** mag = nearest and min = linear and mip = linear */
  61907. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  61908. /** mag = nearest and min = linear and mip = none */
  61909. static readonly TEXTURE_NEAREST_LINEAR: number;
  61910. /** mag = nearest and min = nearest and mip = none */
  61911. static readonly TEXTURE_NEAREST_NEAREST: number;
  61912. /** mag = linear and min = nearest and mip = nearest */
  61913. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  61914. /** mag = linear and min = nearest and mip = linear */
  61915. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  61916. /** mag = linear and min = linear and mip = none */
  61917. static readonly TEXTURE_LINEAR_LINEAR: number;
  61918. /** mag = linear and min = nearest and mip = none */
  61919. static readonly TEXTURE_LINEAR_NEAREST: number;
  61920. /** Explicit coordinates mode */
  61921. static readonly TEXTURE_EXPLICIT_MODE: number;
  61922. /** Spherical coordinates mode */
  61923. static readonly TEXTURE_SPHERICAL_MODE: number;
  61924. /** Planar coordinates mode */
  61925. static readonly TEXTURE_PLANAR_MODE: number;
  61926. /** Cubic coordinates mode */
  61927. static readonly TEXTURE_CUBIC_MODE: number;
  61928. /** Projection coordinates mode */
  61929. static readonly TEXTURE_PROJECTION_MODE: number;
  61930. /** Skybox coordinates mode */
  61931. static readonly TEXTURE_SKYBOX_MODE: number;
  61932. /** Inverse Cubic coordinates mode */
  61933. static readonly TEXTURE_INVCUBIC_MODE: number;
  61934. /** Equirectangular coordinates mode */
  61935. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  61936. /** Equirectangular Fixed coordinates mode */
  61937. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  61938. /** Equirectangular Fixed Mirrored coordinates mode */
  61939. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  61940. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  61941. static readonly SCALEMODE_FLOOR: number;
  61942. /** Defines that texture rescaling will look for the nearest power of 2 size */
  61943. static readonly SCALEMODE_NEAREST: number;
  61944. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  61945. static readonly SCALEMODE_CEILING: number;
  61946. /**
  61947. * The dirty texture flag value
  61948. */
  61949. static readonly MATERIAL_TextureDirtyFlag: number;
  61950. /**
  61951. * The dirty light flag value
  61952. */
  61953. static readonly MATERIAL_LightDirtyFlag: number;
  61954. /**
  61955. * The dirty fresnel flag value
  61956. */
  61957. static readonly MATERIAL_FresnelDirtyFlag: number;
  61958. /**
  61959. * The dirty attribute flag value
  61960. */
  61961. static readonly MATERIAL_AttributesDirtyFlag: number;
  61962. /**
  61963. * The dirty misc flag value
  61964. */
  61965. static readonly MATERIAL_MiscDirtyFlag: number;
  61966. /**
  61967. * The all dirty flag value
  61968. */
  61969. static readonly MATERIAL_AllDirtyFlag: number;
  61970. /**
  61971. * Returns the triangle fill mode
  61972. */
  61973. static readonly MATERIAL_TriangleFillMode: number;
  61974. /**
  61975. * Returns the wireframe mode
  61976. */
  61977. static readonly MATERIAL_WireFrameFillMode: number;
  61978. /**
  61979. * Returns the point fill mode
  61980. */
  61981. static readonly MATERIAL_PointFillMode: number;
  61982. /**
  61983. * Returns the point list draw mode
  61984. */
  61985. static readonly MATERIAL_PointListDrawMode: number;
  61986. /**
  61987. * Returns the line list draw mode
  61988. */
  61989. static readonly MATERIAL_LineListDrawMode: number;
  61990. /**
  61991. * Returns the line loop draw mode
  61992. */
  61993. static readonly MATERIAL_LineLoopDrawMode: number;
  61994. /**
  61995. * Returns the line strip draw mode
  61996. */
  61997. static readonly MATERIAL_LineStripDrawMode: number;
  61998. /**
  61999. * Returns the triangle strip draw mode
  62000. */
  62001. static readonly MATERIAL_TriangleStripDrawMode: number;
  62002. /**
  62003. * Returns the triangle fan draw mode
  62004. */
  62005. static readonly MATERIAL_TriangleFanDrawMode: number;
  62006. /**
  62007. * Stores the clock-wise side orientation
  62008. */
  62009. static readonly MATERIAL_ClockWiseSideOrientation: number;
  62010. /**
  62011. * Stores the counter clock-wise side orientation
  62012. */
  62013. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  62014. /**
  62015. * Nothing
  62016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62017. */
  62018. static readonly ACTION_NothingTrigger: number;
  62019. /**
  62020. * On pick
  62021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62022. */
  62023. static readonly ACTION_OnPickTrigger: number;
  62024. /**
  62025. * On left pick
  62026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62027. */
  62028. static readonly ACTION_OnLeftPickTrigger: number;
  62029. /**
  62030. * On right pick
  62031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62032. */
  62033. static readonly ACTION_OnRightPickTrigger: number;
  62034. /**
  62035. * On center pick
  62036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62037. */
  62038. static readonly ACTION_OnCenterPickTrigger: number;
  62039. /**
  62040. * On pick down
  62041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62042. */
  62043. static readonly ACTION_OnPickDownTrigger: number;
  62044. /**
  62045. * On double pick
  62046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62047. */
  62048. static readonly ACTION_OnDoublePickTrigger: number;
  62049. /**
  62050. * On pick up
  62051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62052. */
  62053. static readonly ACTION_OnPickUpTrigger: number;
  62054. /**
  62055. * On pick out.
  62056. * This trigger will only be raised if you also declared a OnPickDown
  62057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62058. */
  62059. static readonly ACTION_OnPickOutTrigger: number;
  62060. /**
  62061. * On long press
  62062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62063. */
  62064. static readonly ACTION_OnLongPressTrigger: number;
  62065. /**
  62066. * On pointer over
  62067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62068. */
  62069. static readonly ACTION_OnPointerOverTrigger: number;
  62070. /**
  62071. * On pointer out
  62072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62073. */
  62074. static readonly ACTION_OnPointerOutTrigger: number;
  62075. /**
  62076. * On every frame
  62077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62078. */
  62079. static readonly ACTION_OnEveryFrameTrigger: number;
  62080. /**
  62081. * On intersection enter
  62082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62083. */
  62084. static readonly ACTION_OnIntersectionEnterTrigger: number;
  62085. /**
  62086. * On intersection exit
  62087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62088. */
  62089. static readonly ACTION_OnIntersectionExitTrigger: number;
  62090. /**
  62091. * On key down
  62092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62093. */
  62094. static readonly ACTION_OnKeyDownTrigger: number;
  62095. /**
  62096. * On key up
  62097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62098. */
  62099. static readonly ACTION_OnKeyUpTrigger: number;
  62100. /**
  62101. * Billboard mode will only apply to Y axis
  62102. */
  62103. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  62104. /**
  62105. * Billboard mode will apply to all axes
  62106. */
  62107. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  62108. /**
  62109. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  62110. */
  62111. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  62112. /**
  62113. * Gets or sets base Assets URL
  62114. */
  62115. static readonly PARTICLES_BaseAssetsUrl: string;
  62116. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  62117. * Test order :
  62118. * Is the bounding sphere outside the frustum ?
  62119. * If not, are the bounding box vertices outside the frustum ?
  62120. * It not, then the cullable object is in the frustum.
  62121. */
  62122. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  62123. /** Culling strategy : Bounding Sphere Only.
  62124. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  62125. * It's also less accurate than the standard because some not visible objects can still be selected.
  62126. * Test : is the bounding sphere outside the frustum ?
  62127. * If not, then the cullable object is in the frustum.
  62128. */
  62129. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  62130. /** Culling strategy : Optimistic Inclusion.
  62131. * This in an inclusion test first, then the standard exclusion test.
  62132. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  62133. * 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.
  62134. * Anyway, it's as accurate as the standard strategy.
  62135. * Test :
  62136. * Is the cullable object bounding sphere center in the frustum ?
  62137. * If not, apply the default culling strategy.
  62138. */
  62139. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  62140. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  62141. * This in an inclusion test first, then the bounding sphere only exclusion test.
  62142. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  62143. * 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.
  62144. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  62145. * Test :
  62146. * Is the cullable object bounding sphere center in the frustum ?
  62147. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  62148. */
  62149. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  62150. /**
  62151. * No logging while loading
  62152. */
  62153. static readonly SCENELOADER_NO_LOGGING: number;
  62154. /**
  62155. * Minimal logging while loading
  62156. */
  62157. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  62158. /**
  62159. * Summary logging while loading
  62160. */
  62161. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  62162. /**
  62163. * Detailled logging while loading
  62164. */
  62165. static readonly SCENELOADER_DETAILED_LOGGING: number;
  62166. }
  62167. }
  62168. declare module BABYLON {
  62169. /**
  62170. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  62171. * Babylon.js
  62172. */
  62173. export class DomManagement {
  62174. /**
  62175. * Checks if the window object exists
  62176. * @returns true if the window object exists
  62177. */
  62178. static IsWindowObjectExist(): boolean;
  62179. /**
  62180. * Extracts text content from a DOM element hierarchy
  62181. * @param element defines the root element
  62182. * @returns a string
  62183. */
  62184. static GetDOMTextContent(element: HTMLElement): string;
  62185. }
  62186. }
  62187. declare module BABYLON {
  62188. /**
  62189. * Logger used througouht the application to allow configuration of
  62190. * the log level required for the messages.
  62191. */
  62192. export class Logger {
  62193. /**
  62194. * No log
  62195. */
  62196. static readonly NoneLogLevel: number;
  62197. /**
  62198. * Only message logs
  62199. */
  62200. static readonly MessageLogLevel: number;
  62201. /**
  62202. * Only warning logs
  62203. */
  62204. static readonly WarningLogLevel: number;
  62205. /**
  62206. * Only error logs
  62207. */
  62208. static readonly ErrorLogLevel: number;
  62209. /**
  62210. * All logs
  62211. */
  62212. static readonly AllLogLevel: number;
  62213. private static _LogCache;
  62214. /**
  62215. * Gets a value indicating the number of loading errors
  62216. * @ignorenaming
  62217. */
  62218. static errorsCount: number;
  62219. /**
  62220. * Callback called when a new log is added
  62221. */
  62222. static OnNewCacheEntry: (entry: string) => void;
  62223. private static _AddLogEntry;
  62224. private static _FormatMessage;
  62225. private static _LogDisabled;
  62226. private static _LogEnabled;
  62227. private static _WarnDisabled;
  62228. private static _WarnEnabled;
  62229. private static _ErrorDisabled;
  62230. private static _ErrorEnabled;
  62231. /**
  62232. * Log a message to the console
  62233. */
  62234. static Log: (message: string) => void;
  62235. /**
  62236. * Write a warning message to the console
  62237. */
  62238. static Warn: (message: string) => void;
  62239. /**
  62240. * Write an error message to the console
  62241. */
  62242. static Error: (message: string) => void;
  62243. /**
  62244. * Gets current log cache (list of logs)
  62245. */
  62246. static readonly LogCache: string;
  62247. /**
  62248. * Clears the log cache
  62249. */
  62250. static ClearLogCache(): void;
  62251. /**
  62252. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  62253. */
  62254. static LogLevels: number;
  62255. }
  62256. }
  62257. declare module BABYLON {
  62258. /** @hidden */
  62259. export class _TypeStore {
  62260. /** @hidden */
  62261. static RegisteredTypes: {
  62262. [key: string]: Object;
  62263. };
  62264. /** @hidden */
  62265. static GetClass(fqdn: string): any;
  62266. }
  62267. }
  62268. declare module BABYLON {
  62269. /**
  62270. * Class containing a set of static utilities functions for deep copy.
  62271. */
  62272. export class DeepCopier {
  62273. /**
  62274. * Tries to copy an object by duplicating every property
  62275. * @param source defines the source object
  62276. * @param destination defines the target object
  62277. * @param doNotCopyList defines a list of properties to avoid
  62278. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  62279. */
  62280. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  62281. }
  62282. }
  62283. declare module BABYLON {
  62284. /**
  62285. * Class containing a set of static utilities functions for precision date
  62286. */
  62287. export class PrecisionDate {
  62288. /**
  62289. * Gets either window.performance.now() if supported or Date.now() else
  62290. */
  62291. static readonly Now: number;
  62292. }
  62293. }
  62294. declare module BABYLON {
  62295. /** @hidden */
  62296. export class _DevTools {
  62297. static WarnImport(name: string): string;
  62298. }
  62299. }
  62300. declare module BABYLON {
  62301. /**
  62302. * Class used to evalaute queries containing `and` and `or` operators
  62303. */
  62304. export class AndOrNotEvaluator {
  62305. /**
  62306. * Evaluate a query
  62307. * @param query defines the query to evaluate
  62308. * @param evaluateCallback defines the callback used to filter result
  62309. * @returns true if the query matches
  62310. */
  62311. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  62312. private static _HandleParenthesisContent;
  62313. private static _SimplifyNegation;
  62314. }
  62315. }
  62316. declare module BABYLON {
  62317. /**
  62318. * Class used to store custom tags
  62319. */
  62320. export class Tags {
  62321. /**
  62322. * Adds support for tags on the given object
  62323. * @param obj defines the object to use
  62324. */
  62325. static EnableFor(obj: any): void;
  62326. /**
  62327. * Removes tags support
  62328. * @param obj defines the object to use
  62329. */
  62330. static DisableFor(obj: any): void;
  62331. /**
  62332. * Gets a boolean indicating if the given object has tags
  62333. * @param obj defines the object to use
  62334. * @returns a boolean
  62335. */
  62336. static HasTags(obj: any): boolean;
  62337. /**
  62338. * Gets the tags available on a given object
  62339. * @param obj defines the object to use
  62340. * @param asString defines if the tags must be returned as a string instead of an array of strings
  62341. * @returns the tags
  62342. */
  62343. static GetTags(obj: any, asString?: boolean): any;
  62344. /**
  62345. * Adds tags to an object
  62346. * @param obj defines the object to use
  62347. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  62348. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  62349. */
  62350. static AddTagsTo(obj: any, tagsString: string): void;
  62351. /**
  62352. * @hidden
  62353. */
  62354. static _AddTagTo(obj: any, tag: string): void;
  62355. /**
  62356. * Removes specific tags from a specific object
  62357. * @param obj defines the object to use
  62358. * @param tagsString defines the tags to remove
  62359. */
  62360. static RemoveTagsFrom(obj: any, tagsString: string): void;
  62361. /**
  62362. * @hidden
  62363. */
  62364. static _RemoveTagFrom(obj: any, tag: string): void;
  62365. /**
  62366. * Defines if tags hosted on an object match a given query
  62367. * @param obj defines the object to use
  62368. * @param tagsQuery defines the tag query
  62369. * @returns a boolean
  62370. */
  62371. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  62372. }
  62373. }
  62374. declare module BABYLON {
  62375. /**
  62376. * Manages the defines for the Material
  62377. */
  62378. export class MaterialDefines {
  62379. private _keys;
  62380. private _isDirty;
  62381. /** @hidden */
  62382. _renderId: number;
  62383. /** @hidden */
  62384. _areLightsDirty: boolean;
  62385. /** @hidden */
  62386. _areAttributesDirty: boolean;
  62387. /** @hidden */
  62388. _areTexturesDirty: boolean;
  62389. /** @hidden */
  62390. _areFresnelDirty: boolean;
  62391. /** @hidden */
  62392. _areMiscDirty: boolean;
  62393. /** @hidden */
  62394. _areImageProcessingDirty: boolean;
  62395. /** @hidden */
  62396. _normals: boolean;
  62397. /** @hidden */
  62398. _uvs: boolean;
  62399. /** @hidden */
  62400. _needNormals: boolean;
  62401. /** @hidden */
  62402. _needUVs: boolean;
  62403. /**
  62404. * Specifies if the material needs to be re-calculated
  62405. */
  62406. readonly isDirty: boolean;
  62407. /**
  62408. * Marks the material to indicate that it has been re-calculated
  62409. */
  62410. markAsProcessed(): void;
  62411. /**
  62412. * Marks the material to indicate that it needs to be re-calculated
  62413. */
  62414. markAsUnprocessed(): void;
  62415. /**
  62416. * Marks the material to indicate all of its defines need to be re-calculated
  62417. */
  62418. markAllAsDirty(): void;
  62419. /**
  62420. * Marks the material to indicate that image processing needs to be re-calculated
  62421. */
  62422. markAsImageProcessingDirty(): void;
  62423. /**
  62424. * Marks the material to indicate the lights need to be re-calculated
  62425. */
  62426. markAsLightDirty(): void;
  62427. /**
  62428. * Marks the attribute state as changed
  62429. */
  62430. markAsAttributesDirty(): void;
  62431. /**
  62432. * Marks the texture state as changed
  62433. */
  62434. markAsTexturesDirty(): void;
  62435. /**
  62436. * Marks the fresnel state as changed
  62437. */
  62438. markAsFresnelDirty(): void;
  62439. /**
  62440. * Marks the misc state as changed
  62441. */
  62442. markAsMiscDirty(): void;
  62443. /**
  62444. * Rebuilds the material defines
  62445. */
  62446. rebuild(): void;
  62447. /**
  62448. * Specifies if two material defines are equal
  62449. * @param other - A material define instance to compare to
  62450. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  62451. */
  62452. isEqual(other: MaterialDefines): boolean;
  62453. /**
  62454. * Clones this instance's defines to another instance
  62455. * @param other - material defines to clone values to
  62456. */
  62457. cloneTo(other: MaterialDefines): void;
  62458. /**
  62459. * Resets the material define values
  62460. */
  62461. reset(): void;
  62462. /**
  62463. * Converts the material define values to a string
  62464. * @returns - String of material define information
  62465. */
  62466. toString(): string;
  62467. }
  62468. }
  62469. declare module BABYLON {
  62470. /**
  62471. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  62472. */
  62473. export class PerformanceMonitor {
  62474. private _enabled;
  62475. private _rollingFrameTime;
  62476. private _lastFrameTimeMs;
  62477. /**
  62478. * constructor
  62479. * @param frameSampleSize The number of samples required to saturate the sliding window
  62480. */
  62481. constructor(frameSampleSize?: number);
  62482. /**
  62483. * Samples current frame
  62484. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  62485. */
  62486. sampleFrame(timeMs?: number): void;
  62487. /**
  62488. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62489. */
  62490. readonly averageFrameTime: number;
  62491. /**
  62492. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62493. */
  62494. readonly averageFrameTimeVariance: number;
  62495. /**
  62496. * Returns the frame time of the most recent frame
  62497. */
  62498. readonly instantaneousFrameTime: number;
  62499. /**
  62500. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  62501. */
  62502. readonly averageFPS: number;
  62503. /**
  62504. * Returns the average framerate in frames per second using the most recent frame time
  62505. */
  62506. readonly instantaneousFPS: number;
  62507. /**
  62508. * Returns true if enough samples have been taken to completely fill the sliding window
  62509. */
  62510. readonly isSaturated: boolean;
  62511. /**
  62512. * Enables contributions to the sliding window sample set
  62513. */
  62514. enable(): void;
  62515. /**
  62516. * Disables contributions to the sliding window sample set
  62517. * Samples will not be interpolated over the disabled period
  62518. */
  62519. disable(): void;
  62520. /**
  62521. * Returns true if sampling is enabled
  62522. */
  62523. readonly isEnabled: boolean;
  62524. /**
  62525. * Resets performance monitor
  62526. */
  62527. reset(): void;
  62528. }
  62529. /**
  62530. * RollingAverage
  62531. *
  62532. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  62533. */
  62534. export class RollingAverage {
  62535. /**
  62536. * Current average
  62537. */
  62538. average: number;
  62539. /**
  62540. * Current variance
  62541. */
  62542. variance: number;
  62543. protected _samples: Array<number>;
  62544. protected _sampleCount: number;
  62545. protected _pos: number;
  62546. protected _m2: number;
  62547. /**
  62548. * constructor
  62549. * @param length The number of samples required to saturate the sliding window
  62550. */
  62551. constructor(length: number);
  62552. /**
  62553. * Adds a sample to the sample set
  62554. * @param v The sample value
  62555. */
  62556. add(v: number): void;
  62557. /**
  62558. * Returns previously added values or null if outside of history or outside the sliding window domain
  62559. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  62560. * @return Value previously recorded with add() or null if outside of range
  62561. */
  62562. history(i: number): number;
  62563. /**
  62564. * Returns true if enough samples have been taken to completely fill the sliding window
  62565. * @return true if sample-set saturated
  62566. */
  62567. isSaturated(): boolean;
  62568. /**
  62569. * Resets the rolling average (equivalent to 0 samples taken so far)
  62570. */
  62571. reset(): void;
  62572. /**
  62573. * Wraps a value around the sample range boundaries
  62574. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  62575. * @return Wrapped position in sample range
  62576. */
  62577. protected _wrapPosition(i: number): number;
  62578. }
  62579. }
  62580. declare module BABYLON {
  62581. /**
  62582. * This class implement a typical dictionary using a string as key and the generic type T as value.
  62583. * The underlying implementation relies on an associative array to ensure the best performances.
  62584. * The value can be anything including 'null' but except 'undefined'
  62585. */
  62586. export class StringDictionary<T> {
  62587. /**
  62588. * This will clear this dictionary and copy the content from the 'source' one.
  62589. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  62590. * @param source the dictionary to take the content from and copy to this dictionary
  62591. */
  62592. copyFrom(source: StringDictionary<T>): void;
  62593. /**
  62594. * Get a value based from its key
  62595. * @param key the given key to get the matching value from
  62596. * @return the value if found, otherwise undefined is returned
  62597. */
  62598. get(key: string): T | undefined;
  62599. /**
  62600. * Get a value from its key or add it if it doesn't exist.
  62601. * This method will ensure you that a given key/data will be present in the dictionary.
  62602. * @param key the given key to get the matching value from
  62603. * @param factory the factory that will create the value if the key is not present in the dictionary.
  62604. * The factory will only be invoked if there's no data for the given key.
  62605. * @return the value corresponding to the key.
  62606. */
  62607. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  62608. /**
  62609. * Get a value from its key if present in the dictionary otherwise add it
  62610. * @param key the key to get the value from
  62611. * @param val if there's no such key/value pair in the dictionary add it with this value
  62612. * @return the value corresponding to the key
  62613. */
  62614. getOrAdd(key: string, val: T): T;
  62615. /**
  62616. * Check if there's a given key in the dictionary
  62617. * @param key the key to check for
  62618. * @return true if the key is present, false otherwise
  62619. */
  62620. contains(key: string): boolean;
  62621. /**
  62622. * Add a new key and its corresponding value
  62623. * @param key the key to add
  62624. * @param value the value corresponding to the key
  62625. * @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
  62626. */
  62627. add(key: string, value: T): boolean;
  62628. /**
  62629. * Update a specific value associated to a key
  62630. * @param key defines the key to use
  62631. * @param value defines the value to store
  62632. * @returns true if the value was updated (or false if the key was not found)
  62633. */
  62634. set(key: string, value: T): boolean;
  62635. /**
  62636. * Get the element of the given key and remove it from the dictionary
  62637. * @param key defines the key to search
  62638. * @returns the value associated with the key or null if not found
  62639. */
  62640. getAndRemove(key: string): Nullable<T>;
  62641. /**
  62642. * Remove a key/value from the dictionary.
  62643. * @param key the key to remove
  62644. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  62645. */
  62646. remove(key: string): boolean;
  62647. /**
  62648. * Clear the whole content of the dictionary
  62649. */
  62650. clear(): void;
  62651. /**
  62652. * Gets the current count
  62653. */
  62654. readonly count: number;
  62655. /**
  62656. * Execute a callback on each key/val of the dictionary.
  62657. * Note that you can remove any element in this dictionary in the callback implementation
  62658. * @param callback the callback to execute on a given key/value pair
  62659. */
  62660. forEach(callback: (key: string, val: T) => void): void;
  62661. /**
  62662. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  62663. * If the callback returns null or undefined the method will iterate to the next key/value pair
  62664. * Note that you can remove any element in this dictionary in the callback implementation
  62665. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  62666. * @returns the first item
  62667. */
  62668. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  62669. private _count;
  62670. private _data;
  62671. }
  62672. }
  62673. declare module BABYLON {
  62674. /**
  62675. * Helper class that provides a small promise polyfill
  62676. */
  62677. export class PromisePolyfill {
  62678. /**
  62679. * Static function used to check if the polyfill is required
  62680. * If this is the case then the function will inject the polyfill to window.Promise
  62681. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  62682. */
  62683. static Apply(force?: boolean): void;
  62684. }
  62685. }
  62686. declare module BABYLON {
  62687. /**
  62688. * Class used to store data that will be store in GPU memory
  62689. */
  62690. export class Buffer {
  62691. private _engine;
  62692. private _buffer;
  62693. /** @hidden */
  62694. _data: Nullable<DataArray>;
  62695. private _updatable;
  62696. private _instanced;
  62697. /**
  62698. * Gets the byte stride.
  62699. */
  62700. readonly byteStride: number;
  62701. /**
  62702. * Constructor
  62703. * @param engine the engine
  62704. * @param data the data to use for this buffer
  62705. * @param updatable whether the data is updatable
  62706. * @param stride the stride (optional)
  62707. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62708. * @param instanced whether the buffer is instanced (optional)
  62709. * @param useBytes set to true if the stride in in bytes (optional)
  62710. */
  62711. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  62712. /**
  62713. * Create a new VertexBuffer based on the current buffer
  62714. * @param kind defines the vertex buffer kind (position, normal, etc.)
  62715. * @param offset defines offset in the buffer (0 by default)
  62716. * @param size defines the size in floats of attributes (position is 3 for instance)
  62717. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  62718. * @param instanced defines if the vertex buffer contains indexed data
  62719. * @param useBytes defines if the offset and stride are in bytes
  62720. * @returns the new vertex buffer
  62721. */
  62722. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  62723. /**
  62724. * Gets a boolean indicating if the Buffer is updatable?
  62725. * @returns true if the buffer is updatable
  62726. */
  62727. isUpdatable(): boolean;
  62728. /**
  62729. * Gets current buffer's data
  62730. * @returns a DataArray or null
  62731. */
  62732. getData(): Nullable<DataArray>;
  62733. /**
  62734. * Gets underlying native buffer
  62735. * @returns underlying native buffer
  62736. */
  62737. getBuffer(): Nullable<WebGLBuffer>;
  62738. /**
  62739. * Gets the stride in float32 units (i.e. byte stride / 4).
  62740. * May not be an integer if the byte stride is not divisible by 4.
  62741. * DEPRECATED. Use byteStride instead.
  62742. * @returns the stride in float32 units
  62743. */
  62744. getStrideSize(): number;
  62745. /**
  62746. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62747. * @param data defines the data to store
  62748. */
  62749. create(data?: Nullable<DataArray>): void;
  62750. /** @hidden */
  62751. _rebuild(): void;
  62752. /**
  62753. * Update current buffer data
  62754. * @param data defines the data to store
  62755. */
  62756. update(data: DataArray): void;
  62757. /**
  62758. * Updates the data directly.
  62759. * @param data the new data
  62760. * @param offset the new offset
  62761. * @param vertexCount the vertex count (optional)
  62762. * @param useBytes set to true if the offset is in bytes
  62763. */
  62764. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  62765. /**
  62766. * Release all resources
  62767. */
  62768. dispose(): void;
  62769. }
  62770. /**
  62771. * Specialized buffer used to store vertex data
  62772. */
  62773. export class VertexBuffer {
  62774. /** @hidden */
  62775. _buffer: Buffer;
  62776. private _kind;
  62777. private _size;
  62778. private _ownsBuffer;
  62779. private _instanced;
  62780. private _instanceDivisor;
  62781. /**
  62782. * The byte type.
  62783. */
  62784. static readonly BYTE: number;
  62785. /**
  62786. * The unsigned byte type.
  62787. */
  62788. static readonly UNSIGNED_BYTE: number;
  62789. /**
  62790. * The short type.
  62791. */
  62792. static readonly SHORT: number;
  62793. /**
  62794. * The unsigned short type.
  62795. */
  62796. static readonly UNSIGNED_SHORT: number;
  62797. /**
  62798. * The integer type.
  62799. */
  62800. static readonly INT: number;
  62801. /**
  62802. * The unsigned integer type.
  62803. */
  62804. static readonly UNSIGNED_INT: number;
  62805. /**
  62806. * The float type.
  62807. */
  62808. static readonly FLOAT: number;
  62809. /**
  62810. * Gets or sets the instance divisor when in instanced mode
  62811. */
  62812. instanceDivisor: number;
  62813. /**
  62814. * Gets the byte stride.
  62815. */
  62816. readonly byteStride: number;
  62817. /**
  62818. * Gets the byte offset.
  62819. */
  62820. readonly byteOffset: number;
  62821. /**
  62822. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  62823. */
  62824. readonly normalized: boolean;
  62825. /**
  62826. * Gets the data type of each component in the array.
  62827. */
  62828. readonly type: number;
  62829. /**
  62830. * Constructor
  62831. * @param engine the engine
  62832. * @param data the data to use for this vertex buffer
  62833. * @param kind the vertex buffer kind
  62834. * @param updatable whether the data is updatable
  62835. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62836. * @param stride the stride (optional)
  62837. * @param instanced whether the buffer is instanced (optional)
  62838. * @param offset the offset of the data (optional)
  62839. * @param size the number of components (optional)
  62840. * @param type the type of the component (optional)
  62841. * @param normalized whether the data contains normalized data (optional)
  62842. * @param useBytes set to true if stride and offset are in bytes (optional)
  62843. */
  62844. 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);
  62845. /** @hidden */
  62846. _rebuild(): void;
  62847. /**
  62848. * Returns the kind of the VertexBuffer (string)
  62849. * @returns a string
  62850. */
  62851. getKind(): string;
  62852. /**
  62853. * Gets a boolean indicating if the VertexBuffer is updatable?
  62854. * @returns true if the buffer is updatable
  62855. */
  62856. isUpdatable(): boolean;
  62857. /**
  62858. * Gets current buffer's data
  62859. * @returns a DataArray or null
  62860. */
  62861. getData(): Nullable<DataArray>;
  62862. /**
  62863. * Gets underlying native buffer
  62864. * @returns underlying native buffer
  62865. */
  62866. getBuffer(): Nullable<WebGLBuffer>;
  62867. /**
  62868. * Gets the stride in float32 units (i.e. byte stride / 4).
  62869. * May not be an integer if the byte stride is not divisible by 4.
  62870. * DEPRECATED. Use byteStride instead.
  62871. * @returns the stride in float32 units
  62872. */
  62873. getStrideSize(): number;
  62874. /**
  62875. * Returns the offset as a multiple of the type byte length.
  62876. * DEPRECATED. Use byteOffset instead.
  62877. * @returns the offset in bytes
  62878. */
  62879. getOffset(): number;
  62880. /**
  62881. * Returns the number of components per vertex attribute (integer)
  62882. * @returns the size in float
  62883. */
  62884. getSize(): number;
  62885. /**
  62886. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  62887. * @returns true if this buffer is instanced
  62888. */
  62889. getIsInstanced(): boolean;
  62890. /**
  62891. * Returns the instancing divisor, zero for non-instanced (integer).
  62892. * @returns a number
  62893. */
  62894. getInstanceDivisor(): number;
  62895. /**
  62896. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62897. * @param data defines the data to store
  62898. */
  62899. create(data?: DataArray): void;
  62900. /**
  62901. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  62902. * This function will create a new buffer if the current one is not updatable
  62903. * @param data defines the data to store
  62904. */
  62905. update(data: DataArray): void;
  62906. /**
  62907. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  62908. * Returns the directly updated WebGLBuffer.
  62909. * @param data the new data
  62910. * @param offset the new offset
  62911. * @param useBytes set to true if the offset is in bytes
  62912. */
  62913. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  62914. /**
  62915. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  62916. */
  62917. dispose(): void;
  62918. /**
  62919. * Enumerates each value of this vertex buffer as numbers.
  62920. * @param count the number of values to enumerate
  62921. * @param callback the callback function called for each value
  62922. */
  62923. forEach(count: number, callback: (value: number, index: number) => void): void;
  62924. /**
  62925. * Positions
  62926. */
  62927. static readonly PositionKind: string;
  62928. /**
  62929. * Normals
  62930. */
  62931. static readonly NormalKind: string;
  62932. /**
  62933. * Tangents
  62934. */
  62935. static readonly TangentKind: string;
  62936. /**
  62937. * Texture coordinates
  62938. */
  62939. static readonly UVKind: string;
  62940. /**
  62941. * Texture coordinates 2
  62942. */
  62943. static readonly UV2Kind: string;
  62944. /**
  62945. * Texture coordinates 3
  62946. */
  62947. static readonly UV3Kind: string;
  62948. /**
  62949. * Texture coordinates 4
  62950. */
  62951. static readonly UV4Kind: string;
  62952. /**
  62953. * Texture coordinates 5
  62954. */
  62955. static readonly UV5Kind: string;
  62956. /**
  62957. * Texture coordinates 6
  62958. */
  62959. static readonly UV6Kind: string;
  62960. /**
  62961. * Colors
  62962. */
  62963. static readonly ColorKind: string;
  62964. /**
  62965. * Matrix indices (for bones)
  62966. */
  62967. static readonly MatricesIndicesKind: string;
  62968. /**
  62969. * Matrix weights (for bones)
  62970. */
  62971. static readonly MatricesWeightsKind: string;
  62972. /**
  62973. * Additional matrix indices (for bones)
  62974. */
  62975. static readonly MatricesIndicesExtraKind: string;
  62976. /**
  62977. * Additional matrix weights (for bones)
  62978. */
  62979. static readonly MatricesWeightsExtraKind: string;
  62980. /**
  62981. * Deduces the stride given a kind.
  62982. * @param kind The kind string to deduce
  62983. * @returns The deduced stride
  62984. */
  62985. static DeduceStride(kind: string): number;
  62986. /**
  62987. * Gets the byte length of the given type.
  62988. * @param type the type
  62989. * @returns the number of bytes
  62990. */
  62991. static GetTypeByteLength(type: number): number;
  62992. /**
  62993. * Enumerates each value of the given parameters as numbers.
  62994. * @param data the data to enumerate
  62995. * @param byteOffset the byte offset of the data
  62996. * @param byteStride the byte stride of the data
  62997. * @param componentCount the number of components per element
  62998. * @param componentType the type of the component
  62999. * @param count the total number of components
  63000. * @param normalized whether the data is normalized
  63001. * @param callback the callback function called for each value
  63002. */
  63003. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  63004. private static _GetFloatValue;
  63005. }
  63006. }
  63007. declare module BABYLON {
  63008. /**
  63009. * Class representing spherical polynomial coefficients to the 3rd degree
  63010. */
  63011. export class SphericalPolynomial {
  63012. /**
  63013. * The x coefficients of the spherical polynomial
  63014. */
  63015. x: Vector3;
  63016. /**
  63017. * The y coefficients of the spherical polynomial
  63018. */
  63019. y: Vector3;
  63020. /**
  63021. * The z coefficients of the spherical polynomial
  63022. */
  63023. z: Vector3;
  63024. /**
  63025. * The xx coefficients of the spherical polynomial
  63026. */
  63027. xx: Vector3;
  63028. /**
  63029. * The yy coefficients of the spherical polynomial
  63030. */
  63031. yy: Vector3;
  63032. /**
  63033. * The zz coefficients of the spherical polynomial
  63034. */
  63035. zz: Vector3;
  63036. /**
  63037. * The xy coefficients of the spherical polynomial
  63038. */
  63039. xy: Vector3;
  63040. /**
  63041. * The yz coefficients of the spherical polynomial
  63042. */
  63043. yz: Vector3;
  63044. /**
  63045. * The zx coefficients of the spherical polynomial
  63046. */
  63047. zx: Vector3;
  63048. /**
  63049. * Adds an ambient color to the spherical polynomial
  63050. * @param color the color to add
  63051. */
  63052. addAmbient(color: Color3): void;
  63053. /**
  63054. * Scales the spherical polynomial by the given amount
  63055. * @param scale the amount to scale
  63056. */
  63057. scale(scale: number): void;
  63058. /**
  63059. * Gets the spherical polynomial from harmonics
  63060. * @param harmonics the spherical harmonics
  63061. * @returns the spherical polynomial
  63062. */
  63063. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  63064. /**
  63065. * Constructs a spherical polynomial from an array.
  63066. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  63067. * @returns the spherical polynomial
  63068. */
  63069. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  63070. }
  63071. /**
  63072. * Class representing spherical harmonics coefficients to the 3rd degree
  63073. */
  63074. export class SphericalHarmonics {
  63075. /**
  63076. * The l0,0 coefficients of the spherical harmonics
  63077. */
  63078. l00: Vector3;
  63079. /**
  63080. * The l1,-1 coefficients of the spherical harmonics
  63081. */
  63082. l1_1: Vector3;
  63083. /**
  63084. * The l1,0 coefficients of the spherical harmonics
  63085. */
  63086. l10: Vector3;
  63087. /**
  63088. * The l1,1 coefficients of the spherical harmonics
  63089. */
  63090. l11: Vector3;
  63091. /**
  63092. * The l2,-2 coefficients of the spherical harmonics
  63093. */
  63094. l2_2: Vector3;
  63095. /**
  63096. * The l2,-1 coefficients of the spherical harmonics
  63097. */
  63098. l2_1: Vector3;
  63099. /**
  63100. * The l2,0 coefficients of the spherical harmonics
  63101. */
  63102. l20: Vector3;
  63103. /**
  63104. * The l2,1 coefficients of the spherical harmonics
  63105. */
  63106. l21: Vector3;
  63107. /**
  63108. * The l2,2 coefficients of the spherical harmonics
  63109. */
  63110. lL22: Vector3;
  63111. /**
  63112. * Adds a light to the spherical harmonics
  63113. * @param direction the direction of the light
  63114. * @param color the color of the light
  63115. * @param deltaSolidAngle the delta solid angle of the light
  63116. */
  63117. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  63118. /**
  63119. * Scales the spherical harmonics by the given amount
  63120. * @param scale the amount to scale
  63121. */
  63122. scale(scale: number): void;
  63123. /**
  63124. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  63125. *
  63126. * ```
  63127. * E_lm = A_l * L_lm
  63128. * ```
  63129. *
  63130. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  63131. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  63132. * the scaling factors are given in equation 9.
  63133. */
  63134. convertIncidentRadianceToIrradiance(): void;
  63135. /**
  63136. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  63137. *
  63138. * ```
  63139. * L = (1/pi) * E * rho
  63140. * ```
  63141. *
  63142. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  63143. */
  63144. convertIrradianceToLambertianRadiance(): void;
  63145. /**
  63146. * Gets the spherical harmonics from polynomial
  63147. * @param polynomial the spherical polynomial
  63148. * @returns the spherical harmonics
  63149. */
  63150. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  63151. /**
  63152. * Constructs a spherical harmonics from an array.
  63153. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  63154. * @returns the spherical harmonics
  63155. */
  63156. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  63157. }
  63158. }
  63159. declare module BABYLON {
  63160. /**
  63161. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  63162. */
  63163. export interface CubeMapInfo {
  63164. /**
  63165. * The pixel array for the front face.
  63166. * This is stored in format, left to right, up to down format.
  63167. */
  63168. front: Nullable<ArrayBufferView>;
  63169. /**
  63170. * The pixel array for the back face.
  63171. * This is stored in format, left to right, up to down format.
  63172. */
  63173. back: Nullable<ArrayBufferView>;
  63174. /**
  63175. * The pixel array for the left face.
  63176. * This is stored in format, left to right, up to down format.
  63177. */
  63178. left: Nullable<ArrayBufferView>;
  63179. /**
  63180. * The pixel array for the right face.
  63181. * This is stored in format, left to right, up to down format.
  63182. */
  63183. right: Nullable<ArrayBufferView>;
  63184. /**
  63185. * The pixel array for the up face.
  63186. * This is stored in format, left to right, up to down format.
  63187. */
  63188. up: Nullable<ArrayBufferView>;
  63189. /**
  63190. * The pixel array for the down face.
  63191. * This is stored in format, left to right, up to down format.
  63192. */
  63193. down: Nullable<ArrayBufferView>;
  63194. /**
  63195. * The size of the cubemap stored.
  63196. *
  63197. * Each faces will be size * size pixels.
  63198. */
  63199. size: number;
  63200. /**
  63201. * The format of the texture.
  63202. *
  63203. * RGBA, RGB.
  63204. */
  63205. format: number;
  63206. /**
  63207. * The type of the texture data.
  63208. *
  63209. * UNSIGNED_INT, FLOAT.
  63210. */
  63211. type: number;
  63212. /**
  63213. * Specifies whether the texture is in gamma space.
  63214. */
  63215. gammaSpace: boolean;
  63216. }
  63217. /**
  63218. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  63219. */
  63220. export class PanoramaToCubeMapTools {
  63221. private static FACE_FRONT;
  63222. private static FACE_BACK;
  63223. private static FACE_RIGHT;
  63224. private static FACE_LEFT;
  63225. private static FACE_DOWN;
  63226. private static FACE_UP;
  63227. /**
  63228. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  63229. *
  63230. * @param float32Array The source data.
  63231. * @param inputWidth The width of the input panorama.
  63232. * @param inputHeight The height of the input panorama.
  63233. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  63234. * @return The cubemap data
  63235. */
  63236. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  63237. private static CreateCubemapTexture;
  63238. private static CalcProjectionSpherical;
  63239. }
  63240. }
  63241. declare module BABYLON {
  63242. /**
  63243. * Helper class dealing with the extraction of spherical polynomial dataArray
  63244. * from a cube map.
  63245. */
  63246. export class CubeMapToSphericalPolynomialTools {
  63247. private static FileFaces;
  63248. /**
  63249. * Converts a texture to the according Spherical Polynomial data.
  63250. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63251. *
  63252. * @param texture The texture to extract the information from.
  63253. * @return The Spherical Polynomial data.
  63254. */
  63255. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  63256. /**
  63257. * Converts a cubemap to the according Spherical Polynomial data.
  63258. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63259. *
  63260. * @param cubeInfo The Cube map to extract the information from.
  63261. * @return The Spherical Polynomial data.
  63262. */
  63263. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  63264. }
  63265. }
  63266. declare module BABYLON {
  63267. /**
  63268. * The engine store class is responsible to hold all the instances of Engine and Scene created
  63269. * during the life time of the application.
  63270. */
  63271. export class EngineStore {
  63272. /** Gets the list of created engines */
  63273. static Instances: Engine[];
  63274. /**
  63275. * Gets the latest created engine
  63276. */
  63277. static readonly LastCreatedEngine: Nullable<Engine>;
  63278. /**
  63279. * Gets the latest created scene
  63280. */
  63281. static readonly LastCreatedScene: Nullable<Scene>;
  63282. }
  63283. }
  63284. declare module BABYLON {
  63285. /**
  63286. * Define options used to create a render target texture
  63287. */
  63288. export class RenderTargetCreationOptions {
  63289. /**
  63290. * Specifies is mipmaps must be generated
  63291. */
  63292. generateMipMaps?: boolean;
  63293. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  63294. generateDepthBuffer?: boolean;
  63295. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  63296. generateStencilBuffer?: boolean;
  63297. /** Defines texture type (int by default) */
  63298. type?: number;
  63299. /** Defines sampling mode (trilinear by default) */
  63300. samplingMode?: number;
  63301. /** Defines format (RGBA by default) */
  63302. format?: number;
  63303. }
  63304. }
  63305. declare module BABYLON {
  63306. /**
  63307. * @hidden
  63308. **/
  63309. export class _AlphaState {
  63310. private _isAlphaBlendDirty;
  63311. private _isBlendFunctionParametersDirty;
  63312. private _isBlendEquationParametersDirty;
  63313. private _isBlendConstantsDirty;
  63314. private _alphaBlend;
  63315. private _blendFunctionParameters;
  63316. private _blendEquationParameters;
  63317. private _blendConstants;
  63318. /**
  63319. * Initializes the state.
  63320. */
  63321. constructor();
  63322. readonly isDirty: boolean;
  63323. alphaBlend: boolean;
  63324. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  63325. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  63326. setAlphaEquationParameters(rgb: number, alpha: number): void;
  63327. reset(): void;
  63328. apply(gl: WebGLRenderingContext): void;
  63329. }
  63330. }
  63331. declare module BABYLON {
  63332. /**
  63333. * @hidden
  63334. **/
  63335. export class _DepthCullingState {
  63336. private _isDepthTestDirty;
  63337. private _isDepthMaskDirty;
  63338. private _isDepthFuncDirty;
  63339. private _isCullFaceDirty;
  63340. private _isCullDirty;
  63341. private _isZOffsetDirty;
  63342. private _isFrontFaceDirty;
  63343. private _depthTest;
  63344. private _depthMask;
  63345. private _depthFunc;
  63346. private _cull;
  63347. private _cullFace;
  63348. private _zOffset;
  63349. private _frontFace;
  63350. /**
  63351. * Initializes the state.
  63352. */
  63353. constructor();
  63354. readonly isDirty: boolean;
  63355. zOffset: number;
  63356. cullFace: Nullable<number>;
  63357. cull: Nullable<boolean>;
  63358. depthFunc: Nullable<number>;
  63359. depthMask: boolean;
  63360. depthTest: boolean;
  63361. frontFace: Nullable<number>;
  63362. reset(): void;
  63363. apply(gl: WebGLRenderingContext): void;
  63364. }
  63365. }
  63366. declare module BABYLON {
  63367. /**
  63368. * @hidden
  63369. **/
  63370. export class _StencilState {
  63371. /** 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 */
  63372. static readonly ALWAYS: number;
  63373. /** Passed to stencilOperation to specify that stencil value must be kept */
  63374. static readonly KEEP: number;
  63375. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63376. static readonly REPLACE: number;
  63377. private _isStencilTestDirty;
  63378. private _isStencilMaskDirty;
  63379. private _isStencilFuncDirty;
  63380. private _isStencilOpDirty;
  63381. private _stencilTest;
  63382. private _stencilMask;
  63383. private _stencilFunc;
  63384. private _stencilFuncRef;
  63385. private _stencilFuncMask;
  63386. private _stencilOpStencilFail;
  63387. private _stencilOpDepthFail;
  63388. private _stencilOpStencilDepthPass;
  63389. readonly isDirty: boolean;
  63390. stencilFunc: number;
  63391. stencilFuncRef: number;
  63392. stencilFuncMask: number;
  63393. stencilOpStencilFail: number;
  63394. stencilOpDepthFail: number;
  63395. stencilOpStencilDepthPass: number;
  63396. stencilMask: number;
  63397. stencilTest: boolean;
  63398. constructor();
  63399. reset(): void;
  63400. apply(gl: WebGLRenderingContext): void;
  63401. }
  63402. }
  63403. declare module BABYLON {
  63404. /**
  63405. * @hidden
  63406. **/
  63407. export class _TimeToken {
  63408. _startTimeQuery: Nullable<WebGLQuery>;
  63409. _endTimeQuery: Nullable<WebGLQuery>;
  63410. _timeElapsedQuery: Nullable<WebGLQuery>;
  63411. _timeElapsedQueryEnded: boolean;
  63412. }
  63413. }
  63414. declare module BABYLON {
  63415. /**
  63416. * Internal interface used to track InternalTexture already bound to the GL context
  63417. */
  63418. export interface IInternalTextureTracker {
  63419. /**
  63420. * Gets or set the previous tracker in the list
  63421. */
  63422. previous: Nullable<IInternalTextureTracker>;
  63423. /**
  63424. * Gets or set the next tracker in the list
  63425. */
  63426. next: Nullable<IInternalTextureTracker>;
  63427. }
  63428. /**
  63429. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  63430. */
  63431. export class DummyInternalTextureTracker {
  63432. /**
  63433. * Gets or set the previous tracker in the list
  63434. */
  63435. previous: Nullable<IInternalTextureTracker>;
  63436. /**
  63437. * Gets or set the next tracker in the list
  63438. */
  63439. next: Nullable<IInternalTextureTracker>;
  63440. }
  63441. }
  63442. declare module BABYLON {
  63443. /**
  63444. * Class used to store data associated with WebGL texture data for the engine
  63445. * This class should not be used directly
  63446. */
  63447. export class InternalTexture implements IInternalTextureTracker {
  63448. /** hidden */
  63449. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  63450. /**
  63451. * The source of the texture data is unknown
  63452. */
  63453. static DATASOURCE_UNKNOWN: number;
  63454. /**
  63455. * Texture data comes from an URL
  63456. */
  63457. static DATASOURCE_URL: number;
  63458. /**
  63459. * Texture data is only used for temporary storage
  63460. */
  63461. static DATASOURCE_TEMP: number;
  63462. /**
  63463. * Texture data comes from raw data (ArrayBuffer)
  63464. */
  63465. static DATASOURCE_RAW: number;
  63466. /**
  63467. * Texture content is dynamic (video or dynamic texture)
  63468. */
  63469. static DATASOURCE_DYNAMIC: number;
  63470. /**
  63471. * Texture content is generated by rendering to it
  63472. */
  63473. static DATASOURCE_RENDERTARGET: number;
  63474. /**
  63475. * Texture content is part of a multi render target process
  63476. */
  63477. static DATASOURCE_MULTIRENDERTARGET: number;
  63478. /**
  63479. * Texture data comes from a cube data file
  63480. */
  63481. static DATASOURCE_CUBE: number;
  63482. /**
  63483. * Texture data comes from a raw cube data
  63484. */
  63485. static DATASOURCE_CUBERAW: number;
  63486. /**
  63487. * Texture data come from a prefiltered cube data file
  63488. */
  63489. static DATASOURCE_CUBEPREFILTERED: number;
  63490. /**
  63491. * Texture content is raw 3D data
  63492. */
  63493. static DATASOURCE_RAW3D: number;
  63494. /**
  63495. * Texture content is a depth texture
  63496. */
  63497. static DATASOURCE_DEPTHTEXTURE: number;
  63498. /**
  63499. * Texture data comes from a raw cube data encoded with RGBD
  63500. */
  63501. static DATASOURCE_CUBERAW_RGBD: number;
  63502. /**
  63503. * Defines if the texture is ready
  63504. */
  63505. isReady: boolean;
  63506. /**
  63507. * Defines if the texture is a cube texture
  63508. */
  63509. isCube: boolean;
  63510. /**
  63511. * Defines if the texture contains 3D data
  63512. */
  63513. is3D: boolean;
  63514. /**
  63515. * Gets the URL used to load this texture
  63516. */
  63517. url: string;
  63518. /**
  63519. * Gets the sampling mode of the texture
  63520. */
  63521. samplingMode: number;
  63522. /**
  63523. * Gets a boolean indicating if the texture needs mipmaps generation
  63524. */
  63525. generateMipMaps: boolean;
  63526. /**
  63527. * Gets the number of samples used by the texture (WebGL2+ only)
  63528. */
  63529. samples: number;
  63530. /**
  63531. * Gets the type of the texture (int, float...)
  63532. */
  63533. type: number;
  63534. /**
  63535. * Gets the format of the texture (RGB, RGBA...)
  63536. */
  63537. format: number;
  63538. /**
  63539. * Observable called when the texture is loaded
  63540. */
  63541. onLoadedObservable: Observable<InternalTexture>;
  63542. /**
  63543. * Gets the width of the texture
  63544. */
  63545. width: number;
  63546. /**
  63547. * Gets the height of the texture
  63548. */
  63549. height: number;
  63550. /**
  63551. * Gets the depth of the texture
  63552. */
  63553. depth: number;
  63554. /**
  63555. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  63556. */
  63557. baseWidth: number;
  63558. /**
  63559. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  63560. */
  63561. baseHeight: number;
  63562. /**
  63563. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  63564. */
  63565. baseDepth: number;
  63566. /**
  63567. * Gets a boolean indicating if the texture is inverted on Y axis
  63568. */
  63569. invertY: boolean;
  63570. /**
  63571. * Gets or set the previous tracker in the list
  63572. */
  63573. previous: Nullable<IInternalTextureTracker>;
  63574. /**
  63575. * Gets or set the next tracker in the list
  63576. */
  63577. next: Nullable<IInternalTextureTracker>;
  63578. /** @hidden */
  63579. _invertVScale: boolean;
  63580. /** @hidden */
  63581. _initialSlot: number;
  63582. /** @hidden */
  63583. _designatedSlot: number;
  63584. /** @hidden */
  63585. _dataSource: number;
  63586. /** @hidden */
  63587. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  63588. /** @hidden */
  63589. _bufferView: Nullable<ArrayBufferView>;
  63590. /** @hidden */
  63591. _bufferViewArray: Nullable<ArrayBufferView[]>;
  63592. /** @hidden */
  63593. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  63594. /** @hidden */
  63595. _size: number;
  63596. /** @hidden */
  63597. _extension: string;
  63598. /** @hidden */
  63599. _files: Nullable<string[]>;
  63600. /** @hidden */
  63601. _workingCanvas: HTMLCanvasElement;
  63602. /** @hidden */
  63603. _workingContext: CanvasRenderingContext2D;
  63604. /** @hidden */
  63605. _framebuffer: Nullable<WebGLFramebuffer>;
  63606. /** @hidden */
  63607. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  63608. /** @hidden */
  63609. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  63610. /** @hidden */
  63611. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  63612. /** @hidden */
  63613. _attachments: Nullable<number[]>;
  63614. /** @hidden */
  63615. _cachedCoordinatesMode: Nullable<number>;
  63616. /** @hidden */
  63617. _cachedWrapU: Nullable<number>;
  63618. /** @hidden */
  63619. _cachedWrapV: Nullable<number>;
  63620. /** @hidden */
  63621. _cachedWrapR: Nullable<number>;
  63622. /** @hidden */
  63623. _cachedAnisotropicFilteringLevel: Nullable<number>;
  63624. /** @hidden */
  63625. _isDisabled: boolean;
  63626. /** @hidden */
  63627. _compression: Nullable<string>;
  63628. /** @hidden */
  63629. _generateStencilBuffer: boolean;
  63630. /** @hidden */
  63631. _generateDepthBuffer: boolean;
  63632. /** @hidden */
  63633. _comparisonFunction: number;
  63634. /** @hidden */
  63635. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  63636. /** @hidden */
  63637. _lodGenerationScale: number;
  63638. /** @hidden */
  63639. _lodGenerationOffset: number;
  63640. /** @hidden */
  63641. _lodTextureHigh: BaseTexture;
  63642. /** @hidden */
  63643. _lodTextureMid: BaseTexture;
  63644. /** @hidden */
  63645. _lodTextureLow: BaseTexture;
  63646. /** @hidden */
  63647. _isRGBD: boolean;
  63648. /** @hidden */
  63649. _webGLTexture: Nullable<WebGLTexture>;
  63650. /** @hidden */
  63651. _references: number;
  63652. private _engine;
  63653. /**
  63654. * Gets the Engine the texture belongs to.
  63655. * @returns The babylon engine
  63656. */
  63657. getEngine(): Engine;
  63658. /**
  63659. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  63660. */
  63661. readonly dataSource: number;
  63662. /**
  63663. * Creates a new InternalTexture
  63664. * @param engine defines the engine to use
  63665. * @param dataSource defines the type of data that will be used
  63666. * @param delayAllocation if the texture allocation should be delayed (default: false)
  63667. */
  63668. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  63669. /**
  63670. * Increments the number of references (ie. the number of Texture that point to it)
  63671. */
  63672. incrementReferences(): void;
  63673. /**
  63674. * Change the size of the texture (not the size of the content)
  63675. * @param width defines the new width
  63676. * @param height defines the new height
  63677. * @param depth defines the new depth (1 by default)
  63678. */
  63679. updateSize(width: int, height: int, depth?: int): void;
  63680. /** @hidden */
  63681. _rebuild(): void;
  63682. /** @hidden */
  63683. _swapAndDie(target: InternalTexture): void;
  63684. /**
  63685. * Dispose the current allocated resources
  63686. */
  63687. dispose(): void;
  63688. }
  63689. }
  63690. declare module BABYLON {
  63691. /**
  63692. * This represents the main contract an easing function should follow.
  63693. * Easing functions are used throughout the animation system.
  63694. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63695. */
  63696. export interface IEasingFunction {
  63697. /**
  63698. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63699. * of the easing function.
  63700. * The link below provides some of the most common examples of easing functions.
  63701. * @see https://easings.net/
  63702. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63703. * @returns the corresponding value on the curve defined by the easing function
  63704. */
  63705. ease(gradient: number): number;
  63706. }
  63707. /**
  63708. * Base class used for every default easing function.
  63709. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63710. */
  63711. export class EasingFunction implements IEasingFunction {
  63712. /**
  63713. * Interpolation follows the mathematical formula associated with the easing function.
  63714. */
  63715. static readonly EASINGMODE_EASEIN: number;
  63716. /**
  63717. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  63718. */
  63719. static readonly EASINGMODE_EASEOUT: number;
  63720. /**
  63721. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  63722. */
  63723. static readonly EASINGMODE_EASEINOUT: number;
  63724. private _easingMode;
  63725. /**
  63726. * Sets the easing mode of the current function.
  63727. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  63728. */
  63729. setEasingMode(easingMode: number): void;
  63730. /**
  63731. * Gets the current easing mode.
  63732. * @returns the easing mode
  63733. */
  63734. getEasingMode(): number;
  63735. /**
  63736. * @hidden
  63737. */
  63738. easeInCore(gradient: number): number;
  63739. /**
  63740. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63741. * of the easing function.
  63742. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63743. * @returns the corresponding value on the curve defined by the easing function
  63744. */
  63745. ease(gradient: number): number;
  63746. }
  63747. /**
  63748. * Easing function with a circle shape (see link below).
  63749. * @see https://easings.net/#easeInCirc
  63750. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63751. */
  63752. export class CircleEase extends EasingFunction implements IEasingFunction {
  63753. /** @hidden */
  63754. easeInCore(gradient: number): number;
  63755. }
  63756. /**
  63757. * Easing function with a ease back shape (see link below).
  63758. * @see https://easings.net/#easeInBack
  63759. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63760. */
  63761. export class BackEase extends EasingFunction implements IEasingFunction {
  63762. /** Defines the amplitude of the function */
  63763. amplitude: number;
  63764. /**
  63765. * Instantiates a back ease easing
  63766. * @see https://easings.net/#easeInBack
  63767. * @param amplitude Defines the amplitude of the function
  63768. */
  63769. constructor(
  63770. /** Defines the amplitude of the function */
  63771. amplitude?: number);
  63772. /** @hidden */
  63773. easeInCore(gradient: number): number;
  63774. }
  63775. /**
  63776. * Easing function with a bouncing shape (see link below).
  63777. * @see https://easings.net/#easeInBounce
  63778. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63779. */
  63780. export class BounceEase extends EasingFunction implements IEasingFunction {
  63781. /** Defines the number of bounces */
  63782. bounces: number;
  63783. /** Defines the amplitude of the bounce */
  63784. bounciness: number;
  63785. /**
  63786. * Instantiates a bounce easing
  63787. * @see https://easings.net/#easeInBounce
  63788. * @param bounces Defines the number of bounces
  63789. * @param bounciness Defines the amplitude of the bounce
  63790. */
  63791. constructor(
  63792. /** Defines the number of bounces */
  63793. bounces?: number,
  63794. /** Defines the amplitude of the bounce */
  63795. bounciness?: number);
  63796. /** @hidden */
  63797. easeInCore(gradient: number): number;
  63798. }
  63799. /**
  63800. * Easing function with a power of 3 shape (see link below).
  63801. * @see https://easings.net/#easeInCubic
  63802. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63803. */
  63804. export class CubicEase extends EasingFunction implements IEasingFunction {
  63805. /** @hidden */
  63806. easeInCore(gradient: number): number;
  63807. }
  63808. /**
  63809. * Easing function with an elastic shape (see link below).
  63810. * @see https://easings.net/#easeInElastic
  63811. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63812. */
  63813. export class ElasticEase extends EasingFunction implements IEasingFunction {
  63814. /** Defines the number of oscillations*/
  63815. oscillations: number;
  63816. /** Defines the amplitude of the oscillations*/
  63817. springiness: number;
  63818. /**
  63819. * Instantiates an elastic easing function
  63820. * @see https://easings.net/#easeInElastic
  63821. * @param oscillations Defines the number of oscillations
  63822. * @param springiness Defines the amplitude of the oscillations
  63823. */
  63824. constructor(
  63825. /** Defines the number of oscillations*/
  63826. oscillations?: number,
  63827. /** Defines the amplitude of the oscillations*/
  63828. springiness?: number);
  63829. /** @hidden */
  63830. easeInCore(gradient: number): number;
  63831. }
  63832. /**
  63833. * Easing function with an exponential shape (see link below).
  63834. * @see https://easings.net/#easeInExpo
  63835. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63836. */
  63837. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  63838. /** Defines the exponent of the function */
  63839. exponent: number;
  63840. /**
  63841. * Instantiates an exponential easing function
  63842. * @see https://easings.net/#easeInExpo
  63843. * @param exponent Defines the exponent of the function
  63844. */
  63845. constructor(
  63846. /** Defines the exponent of the function */
  63847. exponent?: number);
  63848. /** @hidden */
  63849. easeInCore(gradient: number): number;
  63850. }
  63851. /**
  63852. * Easing function with a power shape (see link below).
  63853. * @see https://easings.net/#easeInQuad
  63854. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63855. */
  63856. export class PowerEase extends EasingFunction implements IEasingFunction {
  63857. /** Defines the power of the function */
  63858. power: number;
  63859. /**
  63860. * Instantiates an power base easing function
  63861. * @see https://easings.net/#easeInQuad
  63862. * @param power Defines the power of the function
  63863. */
  63864. constructor(
  63865. /** Defines the power of the function */
  63866. power?: number);
  63867. /** @hidden */
  63868. easeInCore(gradient: number): number;
  63869. }
  63870. /**
  63871. * Easing function with a power of 2 shape (see link below).
  63872. * @see https://easings.net/#easeInQuad
  63873. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63874. */
  63875. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  63876. /** @hidden */
  63877. easeInCore(gradient: number): number;
  63878. }
  63879. /**
  63880. * Easing function with a power of 4 shape (see link below).
  63881. * @see https://easings.net/#easeInQuart
  63882. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63883. */
  63884. export class QuarticEase extends EasingFunction implements IEasingFunction {
  63885. /** @hidden */
  63886. easeInCore(gradient: number): number;
  63887. }
  63888. /**
  63889. * Easing function with a power of 5 shape (see link below).
  63890. * @see https://easings.net/#easeInQuint
  63891. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63892. */
  63893. export class QuinticEase extends EasingFunction implements IEasingFunction {
  63894. /** @hidden */
  63895. easeInCore(gradient: number): number;
  63896. }
  63897. /**
  63898. * Easing function with a sin shape (see link below).
  63899. * @see https://easings.net/#easeInSine
  63900. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63901. */
  63902. export class SineEase extends EasingFunction implements IEasingFunction {
  63903. /** @hidden */
  63904. easeInCore(gradient: number): number;
  63905. }
  63906. /**
  63907. * Easing function with a bezier shape (see link below).
  63908. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63909. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63910. */
  63911. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  63912. /** Defines the x component of the start tangent in the bezier curve */
  63913. x1: number;
  63914. /** Defines the y component of the start tangent in the bezier curve */
  63915. y1: number;
  63916. /** Defines the x component of the end tangent in the bezier curve */
  63917. x2: number;
  63918. /** Defines the y component of the end tangent in the bezier curve */
  63919. y2: number;
  63920. /**
  63921. * Instantiates a bezier function
  63922. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63923. * @param x1 Defines the x component of the start tangent in the bezier curve
  63924. * @param y1 Defines the y component of the start tangent in the bezier curve
  63925. * @param x2 Defines the x component of the end tangent in the bezier curve
  63926. * @param y2 Defines the y component of the end tangent in the bezier curve
  63927. */
  63928. constructor(
  63929. /** Defines the x component of the start tangent in the bezier curve */
  63930. x1?: number,
  63931. /** Defines the y component of the start tangent in the bezier curve */
  63932. y1?: number,
  63933. /** Defines the x component of the end tangent in the bezier curve */
  63934. x2?: number,
  63935. /** Defines the y component of the end tangent in the bezier curve */
  63936. y2?: number);
  63937. /** @hidden */
  63938. easeInCore(gradient: number): number;
  63939. }
  63940. }
  63941. declare module BABYLON {
  63942. /**
  63943. * Defines an interface which represents an animation key frame
  63944. */
  63945. export interface IAnimationKey {
  63946. /**
  63947. * Frame of the key frame
  63948. */
  63949. frame: number;
  63950. /**
  63951. * Value at the specifies key frame
  63952. */
  63953. value: any;
  63954. /**
  63955. * The input tangent for the cubic hermite spline
  63956. */
  63957. inTangent?: any;
  63958. /**
  63959. * The output tangent for the cubic hermite spline
  63960. */
  63961. outTangent?: any;
  63962. /**
  63963. * The animation interpolation type
  63964. */
  63965. interpolation?: AnimationKeyInterpolation;
  63966. }
  63967. /**
  63968. * Enum for the animation key frame interpolation type
  63969. */
  63970. export enum AnimationKeyInterpolation {
  63971. /**
  63972. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  63973. */
  63974. STEP = 1
  63975. }
  63976. }
  63977. declare module BABYLON {
  63978. /**
  63979. * Represents the range of an animation
  63980. */
  63981. export class AnimationRange {
  63982. /**The name of the animation range**/
  63983. name: string;
  63984. /**The starting frame of the animation */
  63985. from: number;
  63986. /**The ending frame of the animation*/
  63987. to: number;
  63988. /**
  63989. * Initializes the range of an animation
  63990. * @param name The name of the animation range
  63991. * @param from The starting frame of the animation
  63992. * @param to The ending frame of the animation
  63993. */
  63994. constructor(
  63995. /**The name of the animation range**/
  63996. name: string,
  63997. /**The starting frame of the animation */
  63998. from: number,
  63999. /**The ending frame of the animation*/
  64000. to: number);
  64001. /**
  64002. * Makes a copy of the animation range
  64003. * @returns A copy of the animation range
  64004. */
  64005. clone(): AnimationRange;
  64006. }
  64007. }
  64008. declare module BABYLON {
  64009. /**
  64010. * Composed of a frame, and an action function
  64011. */
  64012. export class AnimationEvent {
  64013. /** The frame for which the event is triggered **/
  64014. frame: number;
  64015. /** The event to perform when triggered **/
  64016. action: (currentFrame: number) => void;
  64017. /** Specifies if the event should be triggered only once**/
  64018. onlyOnce?: boolean | undefined;
  64019. /**
  64020. * Specifies if the animation event is done
  64021. */
  64022. isDone: boolean;
  64023. /**
  64024. * Initializes the animation event
  64025. * @param frame The frame for which the event is triggered
  64026. * @param action The event to perform when triggered
  64027. * @param onlyOnce Specifies if the event should be triggered only once
  64028. */
  64029. constructor(
  64030. /** The frame for which the event is triggered **/
  64031. frame: number,
  64032. /** The event to perform when triggered **/
  64033. action: (currentFrame: number) => void,
  64034. /** Specifies if the event should be triggered only once**/
  64035. onlyOnce?: boolean | undefined);
  64036. /** @hidden */
  64037. _clone(): AnimationEvent;
  64038. }
  64039. }
  64040. declare module BABYLON {
  64041. /**
  64042. * Interface used to define a behavior
  64043. */
  64044. export interface Behavior<T> {
  64045. /** gets or sets behavior's name */
  64046. name: string;
  64047. /**
  64048. * Function called when the behavior needs to be initialized (after attaching it to a target)
  64049. */
  64050. init(): void;
  64051. /**
  64052. * Called when the behavior is attached to a target
  64053. * @param target defines the target where the behavior is attached to
  64054. */
  64055. attach(target: T): void;
  64056. /**
  64057. * Called when the behavior is detached from its target
  64058. */
  64059. detach(): void;
  64060. }
  64061. /**
  64062. * Interface implemented by classes supporting behaviors
  64063. */
  64064. export interface IBehaviorAware<T> {
  64065. /**
  64066. * Attach a behavior
  64067. * @param behavior defines the behavior to attach
  64068. * @returns the current host
  64069. */
  64070. addBehavior(behavior: Behavior<T>): T;
  64071. /**
  64072. * Remove a behavior from the current object
  64073. * @param behavior defines the behavior to detach
  64074. * @returns the current host
  64075. */
  64076. removeBehavior(behavior: Behavior<T>): T;
  64077. /**
  64078. * Gets a behavior using its name to search
  64079. * @param name defines the name to search
  64080. * @returns the behavior or null if not found
  64081. */
  64082. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  64083. }
  64084. }
  64085. declare module BABYLON {
  64086. /**
  64087. * @hidden
  64088. */
  64089. export class IntersectionInfo {
  64090. bu: Nullable<number>;
  64091. bv: Nullable<number>;
  64092. distance: number;
  64093. faceId: number;
  64094. subMeshId: number;
  64095. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  64096. }
  64097. }
  64098. declare module BABYLON {
  64099. /**
  64100. * Class used to store bounding sphere information
  64101. */
  64102. export class BoundingSphere {
  64103. /**
  64104. * Gets the center of the bounding sphere in local space
  64105. */
  64106. readonly center: Vector3;
  64107. /**
  64108. * Radius of the bounding sphere in local space
  64109. */
  64110. radius: number;
  64111. /**
  64112. * Gets the center of the bounding sphere in world space
  64113. */
  64114. readonly centerWorld: Vector3;
  64115. /**
  64116. * Radius of the bounding sphere in world space
  64117. */
  64118. radiusWorld: number;
  64119. /**
  64120. * Gets the minimum vector in local space
  64121. */
  64122. readonly minimum: Vector3;
  64123. /**
  64124. * Gets the maximum vector in local space
  64125. */
  64126. readonly maximum: Vector3;
  64127. private _worldMatrix;
  64128. private static readonly TmpVector3;
  64129. /**
  64130. * Creates a new bounding sphere
  64131. * @param min defines the minimum vector (in local space)
  64132. * @param max defines the maximum vector (in local space)
  64133. * @param worldMatrix defines the new world matrix
  64134. */
  64135. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64136. /**
  64137. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  64138. * @param min defines the new minimum vector (in local space)
  64139. * @param max defines the new maximum vector (in local space)
  64140. * @param worldMatrix defines the new world matrix
  64141. */
  64142. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64143. /**
  64144. * Scale the current bounding sphere by applying a scale factor
  64145. * @param factor defines the scale factor to apply
  64146. * @returns the current bounding box
  64147. */
  64148. scale(factor: number): BoundingSphere;
  64149. /**
  64150. * Gets the world matrix of the bounding box
  64151. * @returns a matrix
  64152. */
  64153. getWorldMatrix(): DeepImmutable<Matrix>;
  64154. /** @hidden */
  64155. _update(worldMatrix: DeepImmutable<Matrix>): void;
  64156. /**
  64157. * Tests if the bounding sphere is intersecting the frustum planes
  64158. * @param frustumPlanes defines the frustum planes to test
  64159. * @returns true if there is an intersection
  64160. */
  64161. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64162. /**
  64163. * Tests if the bounding sphere center is in between the frustum planes.
  64164. * Used for optimistic fast inclusion.
  64165. * @param frustumPlanes defines the frustum planes to test
  64166. * @returns true if the sphere center is in between the frustum planes
  64167. */
  64168. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64169. /**
  64170. * Tests if a point is inside the bounding sphere
  64171. * @param point defines the point to test
  64172. * @returns true if the point is inside the bounding sphere
  64173. */
  64174. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64175. /**
  64176. * Checks if two sphere intersct
  64177. * @param sphere0 sphere 0
  64178. * @param sphere1 sphere 1
  64179. * @returns true if the speres intersect
  64180. */
  64181. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  64182. }
  64183. }
  64184. declare module BABYLON {
  64185. /**
  64186. * Class used to store bounding box information
  64187. */
  64188. export class BoundingBox implements ICullable {
  64189. /**
  64190. * Gets the 8 vectors representing the bounding box in local space
  64191. */
  64192. readonly vectors: Vector3[];
  64193. /**
  64194. * Gets the center of the bounding box in local space
  64195. */
  64196. readonly center: Vector3;
  64197. /**
  64198. * Gets the center of the bounding box in world space
  64199. */
  64200. readonly centerWorld: Vector3;
  64201. /**
  64202. * Gets the extend size in local space
  64203. */
  64204. readonly extendSize: Vector3;
  64205. /**
  64206. * Gets the extend size in world space
  64207. */
  64208. readonly extendSizeWorld: Vector3;
  64209. /**
  64210. * Gets the OBB (object bounding box) directions
  64211. */
  64212. readonly directions: Vector3[];
  64213. /**
  64214. * Gets the 8 vectors representing the bounding box in world space
  64215. */
  64216. readonly vectorsWorld: Vector3[];
  64217. /**
  64218. * Gets the minimum vector in world space
  64219. */
  64220. readonly minimumWorld: Vector3;
  64221. /**
  64222. * Gets the maximum vector in world space
  64223. */
  64224. readonly maximumWorld: Vector3;
  64225. /**
  64226. * Gets the minimum vector in local space
  64227. */
  64228. readonly minimum: Vector3;
  64229. /**
  64230. * Gets the maximum vector in local space
  64231. */
  64232. readonly maximum: Vector3;
  64233. private _worldMatrix;
  64234. private static readonly TmpVector3;
  64235. /**
  64236. * @hidden
  64237. */
  64238. _tag: number;
  64239. /**
  64240. * Creates a new bounding box
  64241. * @param min defines the minimum vector (in local space)
  64242. * @param max defines the maximum vector (in local space)
  64243. * @param worldMatrix defines the new world matrix
  64244. */
  64245. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64246. /**
  64247. * Recreates the entire bounding box from scratch as if we call the constructor in place
  64248. * @param min defines the new minimum vector (in local space)
  64249. * @param max defines the new maximum vector (in local space)
  64250. * @param worldMatrix defines the new world matrix
  64251. */
  64252. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64253. /**
  64254. * Scale the current bounding box by applying a scale factor
  64255. * @param factor defines the scale factor to apply
  64256. * @returns the current bounding box
  64257. */
  64258. scale(factor: number): BoundingBox;
  64259. /**
  64260. * Gets the world matrix of the bounding box
  64261. * @returns a matrix
  64262. */
  64263. getWorldMatrix(): DeepImmutable<Matrix>;
  64264. /** @hidden */
  64265. _update(world: DeepImmutable<Matrix>): void;
  64266. /**
  64267. * Tests if the bounding box is intersecting the frustum planes
  64268. * @param frustumPlanes defines the frustum planes to test
  64269. * @returns true if there is an intersection
  64270. */
  64271. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64272. /**
  64273. * Tests if the bounding box is entirely inside the frustum planes
  64274. * @param frustumPlanes defines the frustum planes to test
  64275. * @returns true if there is an inclusion
  64276. */
  64277. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64278. /**
  64279. * Tests if a point is inside the bounding box
  64280. * @param point defines the point to test
  64281. * @returns true if the point is inside the bounding box
  64282. */
  64283. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64284. /**
  64285. * Tests if the bounding box intersects with a bounding sphere
  64286. * @param sphere defines the sphere to test
  64287. * @returns true if there is an intersection
  64288. */
  64289. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  64290. /**
  64291. * Tests if the bounding box intersects with a box defined by a min and max vectors
  64292. * @param min defines the min vector to use
  64293. * @param max defines the max vector to use
  64294. * @returns true if there is an intersection
  64295. */
  64296. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  64297. /**
  64298. * Tests if two bounding boxes are intersections
  64299. * @param box0 defines the first box to test
  64300. * @param box1 defines the second box to test
  64301. * @returns true if there is an intersection
  64302. */
  64303. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  64304. /**
  64305. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  64306. * @param minPoint defines the minimum vector of the bounding box
  64307. * @param maxPoint defines the maximum vector of the bounding box
  64308. * @param sphereCenter defines the sphere center
  64309. * @param sphereRadius defines the sphere radius
  64310. * @returns true if there is an intersection
  64311. */
  64312. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  64313. /**
  64314. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  64315. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64316. * @param frustumPlanes defines the frustum planes to test
  64317. * @return true if there is an inclusion
  64318. */
  64319. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64320. /**
  64321. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  64322. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64323. * @param frustumPlanes defines the frustum planes to test
  64324. * @return true if there is an intersection
  64325. */
  64326. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64327. }
  64328. }
  64329. declare module BABYLON {
  64330. /** @hidden */
  64331. export class Collider {
  64332. /** Define if a collision was found */
  64333. collisionFound: boolean;
  64334. /**
  64335. * Define last intersection point in local space
  64336. */
  64337. intersectionPoint: Vector3;
  64338. /**
  64339. * Define last collided mesh
  64340. */
  64341. collidedMesh: Nullable<AbstractMesh>;
  64342. private _collisionPoint;
  64343. private _planeIntersectionPoint;
  64344. private _tempVector;
  64345. private _tempVector2;
  64346. private _tempVector3;
  64347. private _tempVector4;
  64348. private _edge;
  64349. private _baseToVertex;
  64350. private _destinationPoint;
  64351. private _slidePlaneNormal;
  64352. private _displacementVector;
  64353. /** @hidden */
  64354. _radius: Vector3;
  64355. /** @hidden */
  64356. _retry: number;
  64357. private _velocity;
  64358. private _basePoint;
  64359. private _epsilon;
  64360. /** @hidden */
  64361. _velocityWorldLength: number;
  64362. /** @hidden */
  64363. _basePointWorld: Vector3;
  64364. private _velocityWorld;
  64365. private _normalizedVelocity;
  64366. /** @hidden */
  64367. _initialVelocity: Vector3;
  64368. /** @hidden */
  64369. _initialPosition: Vector3;
  64370. private _nearestDistance;
  64371. private _collisionMask;
  64372. collisionMask: number;
  64373. /**
  64374. * Gets the plane normal used to compute the sliding response (in local space)
  64375. */
  64376. readonly slidePlaneNormal: Vector3;
  64377. /** @hidden */
  64378. _initialize(source: Vector3, dir: Vector3, e: number): void;
  64379. /** @hidden */
  64380. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  64381. /** @hidden */
  64382. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  64383. /** @hidden */
  64384. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  64385. /** @hidden */
  64386. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  64387. /** @hidden */
  64388. _getResponse(pos: Vector3, vel: Vector3): void;
  64389. }
  64390. }
  64391. declare module BABYLON {
  64392. /**
  64393. * Interface for cullable objects
  64394. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  64395. */
  64396. export interface ICullable {
  64397. /**
  64398. * Checks if the object or part of the object is in the frustum
  64399. * @param frustumPlanes Camera near/planes
  64400. * @returns true if the object is in frustum otherwise false
  64401. */
  64402. isInFrustum(frustumPlanes: Plane[]): boolean;
  64403. /**
  64404. * Checks if a cullable object (mesh...) is in the camera frustum
  64405. * Unlike isInFrustum this cheks the full bounding box
  64406. * @param frustumPlanes Camera near/planes
  64407. * @returns true if the object is in frustum otherwise false
  64408. */
  64409. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  64410. }
  64411. /**
  64412. * Info for a bounding data of a mesh
  64413. */
  64414. export class BoundingInfo implements ICullable {
  64415. /**
  64416. * Bounding box for the mesh
  64417. */
  64418. readonly boundingBox: BoundingBox;
  64419. /**
  64420. * Bounding sphere for the mesh
  64421. */
  64422. readonly boundingSphere: BoundingSphere;
  64423. private _isLocked;
  64424. private static readonly TmpVector3;
  64425. /**
  64426. * Constructs bounding info
  64427. * @param minimum min vector of the bounding box/sphere
  64428. * @param maximum max vector of the bounding box/sphere
  64429. * @param worldMatrix defines the new world matrix
  64430. */
  64431. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64432. /**
  64433. * Recreates the entire bounding info from scratch as if we call the constructor in place
  64434. * @param min defines the new minimum vector (in local space)
  64435. * @param max defines the new maximum vector (in local space)
  64436. * @param worldMatrix defines the new world matrix
  64437. */
  64438. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64439. /**
  64440. * min vector of the bounding box/sphere
  64441. */
  64442. readonly minimum: Vector3;
  64443. /**
  64444. * max vector of the bounding box/sphere
  64445. */
  64446. readonly maximum: Vector3;
  64447. /**
  64448. * If the info is locked and won't be updated to avoid perf overhead
  64449. */
  64450. isLocked: boolean;
  64451. /**
  64452. * Updates the bounding sphere and box
  64453. * @param world world matrix to be used to update
  64454. */
  64455. update(world: DeepImmutable<Matrix>): void;
  64456. /**
  64457. * Recreate the bounding info to be centered around a specific point given a specific extend.
  64458. * @param center New center of the bounding info
  64459. * @param extend New extend of the bounding info
  64460. * @returns the current bounding info
  64461. */
  64462. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  64463. /**
  64464. * Scale the current bounding info by applying a scale factor
  64465. * @param factor defines the scale factor to apply
  64466. * @returns the current bounding info
  64467. */
  64468. scale(factor: number): BoundingInfo;
  64469. /**
  64470. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  64471. * @param frustumPlanes defines the frustum to test
  64472. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  64473. * @returns true if the bounding info is in the frustum planes
  64474. */
  64475. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  64476. /**
  64477. * Gets the world distance between the min and max points of the bounding box
  64478. */
  64479. readonly diagonalLength: number;
  64480. /**
  64481. * Checks if a cullable object (mesh...) is in the camera frustum
  64482. * Unlike isInFrustum this cheks the full bounding box
  64483. * @param frustumPlanes Camera near/planes
  64484. * @returns true if the object is in frustum otherwise false
  64485. */
  64486. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64487. /** @hidden */
  64488. _checkCollision(collider: Collider): boolean;
  64489. /**
  64490. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  64491. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64492. * @param point the point to check intersection with
  64493. * @returns if the point intersects
  64494. */
  64495. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64496. /**
  64497. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  64498. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64499. * @param boundingInfo the bounding info to check intersection with
  64500. * @param precise if the intersection should be done using OBB
  64501. * @returns if the bounding info intersects
  64502. */
  64503. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  64504. }
  64505. }
  64506. declare module BABYLON {
  64507. /**
  64508. * Defines an array and its length.
  64509. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  64510. */
  64511. export interface ISmartArrayLike<T> {
  64512. /**
  64513. * The data of the array.
  64514. */
  64515. data: Array<T>;
  64516. /**
  64517. * The active length of the array.
  64518. */
  64519. length: number;
  64520. }
  64521. /**
  64522. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64523. */
  64524. export class SmartArray<T> implements ISmartArrayLike<T> {
  64525. /**
  64526. * The full set of data from the array.
  64527. */
  64528. data: Array<T>;
  64529. /**
  64530. * The active length of the array.
  64531. */
  64532. length: number;
  64533. protected _id: number;
  64534. /**
  64535. * Instantiates a Smart Array.
  64536. * @param capacity defines the default capacity of the array.
  64537. */
  64538. constructor(capacity: number);
  64539. /**
  64540. * Pushes a value at the end of the active data.
  64541. * @param value defines the object to push in the array.
  64542. */
  64543. push(value: T): void;
  64544. /**
  64545. * Iterates over the active data and apply the lambda to them.
  64546. * @param func defines the action to apply on each value.
  64547. */
  64548. forEach(func: (content: T) => void): void;
  64549. /**
  64550. * Sorts the full sets of data.
  64551. * @param compareFn defines the comparison function to apply.
  64552. */
  64553. sort(compareFn: (a: T, b: T) => number): void;
  64554. /**
  64555. * Resets the active data to an empty array.
  64556. */
  64557. reset(): void;
  64558. /**
  64559. * Releases all the data from the array as well as the array.
  64560. */
  64561. dispose(): void;
  64562. /**
  64563. * Concats the active data with a given array.
  64564. * @param array defines the data to concatenate with.
  64565. */
  64566. concat(array: any): void;
  64567. /**
  64568. * Returns the position of a value in the active data.
  64569. * @param value defines the value to find the index for
  64570. * @returns the index if found in the active data otherwise -1
  64571. */
  64572. indexOf(value: T): number;
  64573. /**
  64574. * Returns whether an element is part of the active data.
  64575. * @param value defines the value to look for
  64576. * @returns true if found in the active data otherwise false
  64577. */
  64578. contains(value: T): boolean;
  64579. private static _GlobalId;
  64580. }
  64581. /**
  64582. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64583. * The data in this array can only be present once
  64584. */
  64585. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  64586. private _duplicateId;
  64587. /**
  64588. * Pushes a value at the end of the active data.
  64589. * THIS DOES NOT PREVENT DUPPLICATE DATA
  64590. * @param value defines the object to push in the array.
  64591. */
  64592. push(value: T): void;
  64593. /**
  64594. * Pushes a value at the end of the active data.
  64595. * If the data is already present, it won t be added again
  64596. * @param value defines the object to push in the array.
  64597. * @returns true if added false if it was already present
  64598. */
  64599. pushNoDuplicate(value: T): boolean;
  64600. /**
  64601. * Resets the active data to an empty array.
  64602. */
  64603. reset(): void;
  64604. /**
  64605. * Concats the active data with a given array.
  64606. * This ensures no dupplicate will be present in the result.
  64607. * @param array defines the data to concatenate with.
  64608. */
  64609. concatWithNoDuplicate(array: any): void;
  64610. }
  64611. }
  64612. declare module BABYLON {
  64613. /**
  64614. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64615. * separate meshes. This can be use to improve performances.
  64616. * @see http://doc.babylonjs.com/how_to/multi_materials
  64617. */
  64618. export class MultiMaterial extends Material {
  64619. private _subMaterials;
  64620. /**
  64621. * Gets or Sets the list of Materials used within the multi material.
  64622. * They need to be ordered according to the submeshes order in the associated mesh
  64623. */
  64624. subMaterials: Nullable<Material>[];
  64625. /**
  64626. * Function used to align with Node.getChildren()
  64627. * @returns the list of Materials used within the multi material
  64628. */
  64629. getChildren(): Nullable<Material>[];
  64630. /**
  64631. * Instantiates a new Multi Material
  64632. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64633. * separate meshes. This can be use to improve performances.
  64634. * @see http://doc.babylonjs.com/how_to/multi_materials
  64635. * @param name Define the name in the scene
  64636. * @param scene Define the scene the material belongs to
  64637. */
  64638. constructor(name: string, scene: Scene);
  64639. private _hookArray;
  64640. /**
  64641. * Get one of the submaterial by its index in the submaterials array
  64642. * @param index The index to look the sub material at
  64643. * @returns The Material if the index has been defined
  64644. */
  64645. getSubMaterial(index: number): Nullable<Material>;
  64646. /**
  64647. * Get the list of active textures for the whole sub materials list.
  64648. * @returns All the textures that will be used during the rendering
  64649. */
  64650. getActiveTextures(): BaseTexture[];
  64651. /**
  64652. * Gets the current class name of the material e.g. "MultiMaterial"
  64653. * Mainly use in serialization.
  64654. * @returns the class name
  64655. */
  64656. getClassName(): string;
  64657. /**
  64658. * Checks if the material is ready to render the requested sub mesh
  64659. * @param mesh Define the mesh the submesh belongs to
  64660. * @param subMesh Define the sub mesh to look readyness for
  64661. * @param useInstances Define whether or not the material is used with instances
  64662. * @returns true if ready, otherwise false
  64663. */
  64664. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  64665. /**
  64666. * Clones the current material and its related sub materials
  64667. * @param name Define the name of the newly cloned material
  64668. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64669. * @returns the cloned material
  64670. */
  64671. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  64672. /**
  64673. * Serializes the materials into a JSON representation.
  64674. * @returns the JSON representation
  64675. */
  64676. serialize(): any;
  64677. /**
  64678. * Dispose the material and release its associated resources
  64679. * @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)
  64680. * @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)
  64681. * @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)
  64682. */
  64683. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  64684. /**
  64685. * Creates a MultiMaterial from parsed MultiMaterial data.
  64686. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64687. * @param scene defines the hosting scene
  64688. * @returns a new MultiMaterial
  64689. */
  64690. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  64691. }
  64692. }
  64693. declare module BABYLON {
  64694. /**
  64695. * Class used to represent data loading progression
  64696. */
  64697. export class SceneLoaderFlags {
  64698. private static _ForceFullSceneLoadingForIncremental;
  64699. private static _ShowLoadingScreen;
  64700. private static _CleanBoneMatrixWeights;
  64701. private static _loggingLevel;
  64702. /**
  64703. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  64704. */
  64705. static ForceFullSceneLoadingForIncremental: boolean;
  64706. /**
  64707. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  64708. */
  64709. static ShowLoadingScreen: boolean;
  64710. /**
  64711. * Defines the current logging level (while loading the scene)
  64712. * @ignorenaming
  64713. */
  64714. static loggingLevel: number;
  64715. /**
  64716. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  64717. */
  64718. static CleanBoneMatrixWeights: boolean;
  64719. }
  64720. }
  64721. declare module BABYLON {
  64722. /**
  64723. * 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.
  64724. * @see https://doc.babylonjs.com/how_to/transformnode
  64725. */
  64726. export class TransformNode extends Node {
  64727. /**
  64728. * Object will not rotate to face the camera
  64729. */
  64730. static BILLBOARDMODE_NONE: number;
  64731. /**
  64732. * Object will rotate to face the camera but only on the x axis
  64733. */
  64734. static BILLBOARDMODE_X: number;
  64735. /**
  64736. * Object will rotate to face the camera but only on the y axis
  64737. */
  64738. static BILLBOARDMODE_Y: number;
  64739. /**
  64740. * Object will rotate to face the camera but only on the z axis
  64741. */
  64742. static BILLBOARDMODE_Z: number;
  64743. /**
  64744. * Object will rotate to face the camera
  64745. */
  64746. static BILLBOARDMODE_ALL: number;
  64747. private _forward;
  64748. private _forwardInverted;
  64749. private _up;
  64750. private _right;
  64751. private _rightInverted;
  64752. private _position;
  64753. private _rotation;
  64754. private _rotationQuaternion;
  64755. protected _scaling: Vector3;
  64756. protected _isDirty: boolean;
  64757. private _transformToBoneReferal;
  64758. /**
  64759. * Set the billboard mode. Default is 0.
  64760. *
  64761. * | Value | Type | Description |
  64762. * | --- | --- | --- |
  64763. * | 0 | BILLBOARDMODE_NONE | |
  64764. * | 1 | BILLBOARDMODE_X | |
  64765. * | 2 | BILLBOARDMODE_Y | |
  64766. * | 4 | BILLBOARDMODE_Z | |
  64767. * | 7 | BILLBOARDMODE_ALL | |
  64768. *
  64769. */
  64770. billboardMode: number;
  64771. /**
  64772. * 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
  64773. */
  64774. scalingDeterminant: number;
  64775. /**
  64776. * Sets the distance of the object to max, often used by skybox
  64777. */
  64778. infiniteDistance: boolean;
  64779. /**
  64780. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  64781. * By default the system will update normals to compensate
  64782. */
  64783. ignoreNonUniformScaling: boolean;
  64784. /** @hidden */
  64785. _poseMatrix: Matrix;
  64786. /** @hidden */
  64787. _localMatrix: Matrix;
  64788. private _absolutePosition;
  64789. private _pivotMatrix;
  64790. private _pivotMatrixInverse;
  64791. protected _postMultiplyPivotMatrix: boolean;
  64792. protected _isWorldMatrixFrozen: boolean;
  64793. /** @hidden */
  64794. _indexInSceneTransformNodesArray: number;
  64795. /**
  64796. * An event triggered after the world matrix is updated
  64797. */
  64798. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  64799. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  64800. /**
  64801. * Gets a string identifying the name of the class
  64802. * @returns "TransformNode" string
  64803. */
  64804. getClassName(): string;
  64805. /**
  64806. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  64807. */
  64808. position: Vector3;
  64809. /**
  64810. * 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)).
  64811. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  64812. */
  64813. rotation: Vector3;
  64814. /**
  64815. * 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)).
  64816. */
  64817. scaling: Vector3;
  64818. /**
  64819. * 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).
  64820. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  64821. */
  64822. rotationQuaternion: Nullable<Quaternion>;
  64823. /**
  64824. * The forward direction of that transform in world space.
  64825. */
  64826. readonly forward: Vector3;
  64827. /**
  64828. * The up direction of that transform in world space.
  64829. */
  64830. readonly up: Vector3;
  64831. /**
  64832. * The right direction of that transform in world space.
  64833. */
  64834. readonly right: Vector3;
  64835. /**
  64836. * Copies the parameter passed Matrix into the mesh Pose matrix.
  64837. * @param matrix the matrix to copy the pose from
  64838. * @returns this TransformNode.
  64839. */
  64840. updatePoseMatrix(matrix: Matrix): TransformNode;
  64841. /**
  64842. * Returns the mesh Pose matrix.
  64843. * @returns the pose matrix
  64844. */
  64845. getPoseMatrix(): Matrix;
  64846. /** @hidden */
  64847. _isSynchronized(): boolean;
  64848. /** @hidden */
  64849. _initCache(): void;
  64850. /**
  64851. * Flag the transform node as dirty (Forcing it to update everything)
  64852. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  64853. * @returns this transform node
  64854. */
  64855. markAsDirty(property: string): TransformNode;
  64856. /**
  64857. * Returns the current mesh absolute position.
  64858. * Returns a Vector3.
  64859. */
  64860. readonly absolutePosition: Vector3;
  64861. /**
  64862. * Sets a new matrix to apply before all other transformation
  64863. * @param matrix defines the transform matrix
  64864. * @returns the current TransformNode
  64865. */
  64866. setPreTransformMatrix(matrix: Matrix): TransformNode;
  64867. /**
  64868. * Sets a new pivot matrix to the current node
  64869. * @param matrix defines the new pivot matrix to use
  64870. * @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
  64871. * @returns the current TransformNode
  64872. */
  64873. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  64874. /**
  64875. * Returns the mesh pivot matrix.
  64876. * Default : Identity.
  64877. * @returns the matrix
  64878. */
  64879. getPivotMatrix(): Matrix;
  64880. /**
  64881. * Prevents the World matrix to be computed any longer.
  64882. * @returns the TransformNode.
  64883. */
  64884. freezeWorldMatrix(): TransformNode;
  64885. /**
  64886. * Allows back the World matrix computation.
  64887. * @returns the TransformNode.
  64888. */
  64889. unfreezeWorldMatrix(): this;
  64890. /**
  64891. * True if the World matrix has been frozen.
  64892. */
  64893. readonly isWorldMatrixFrozen: boolean;
  64894. /**
  64895. * Retuns the mesh absolute position in the World.
  64896. * @returns a Vector3.
  64897. */
  64898. getAbsolutePosition(): Vector3;
  64899. /**
  64900. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  64901. * @param absolutePosition the absolute position to set
  64902. * @returns the TransformNode.
  64903. */
  64904. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  64905. /**
  64906. * Sets the mesh position in its local space.
  64907. * @param vector3 the position to set in localspace
  64908. * @returns the TransformNode.
  64909. */
  64910. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  64911. /**
  64912. * Returns the mesh position in the local space from the current World matrix values.
  64913. * @returns a new Vector3.
  64914. */
  64915. getPositionExpressedInLocalSpace(): Vector3;
  64916. /**
  64917. * Translates the mesh along the passed Vector3 in its local space.
  64918. * @param vector3 the distance to translate in localspace
  64919. * @returns the TransformNode.
  64920. */
  64921. locallyTranslate(vector3: Vector3): TransformNode;
  64922. private static _lookAtVectorCache;
  64923. /**
  64924. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  64925. * @param targetPoint the position (must be in same space as current mesh) to look at
  64926. * @param yawCor optional yaw (y-axis) correction in radians
  64927. * @param pitchCor optional pitch (x-axis) correction in radians
  64928. * @param rollCor optional roll (z-axis) correction in radians
  64929. * @param space the choosen space of the target
  64930. * @returns the TransformNode.
  64931. */
  64932. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  64933. /**
  64934. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  64935. * This Vector3 is expressed in the World space.
  64936. * @param localAxis axis to rotate
  64937. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  64938. */
  64939. getDirection(localAxis: Vector3): Vector3;
  64940. /**
  64941. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  64942. * localAxis is expressed in the mesh local space.
  64943. * result is computed in the Wordl space from the mesh World matrix.
  64944. * @param localAxis axis to rotate
  64945. * @param result the resulting transformnode
  64946. * @returns this TransformNode.
  64947. */
  64948. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  64949. /**
  64950. * Sets this transform node rotation to the given local axis.
  64951. * @param localAxis the axis in local space
  64952. * @param yawCor optional yaw (y-axis) correction in radians
  64953. * @param pitchCor optional pitch (x-axis) correction in radians
  64954. * @param rollCor optional roll (z-axis) correction in radians
  64955. * @returns this TransformNode
  64956. */
  64957. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  64958. /**
  64959. * Sets a new pivot point to the current node
  64960. * @param point defines the new pivot point to use
  64961. * @param space defines if the point is in world or local space (local by default)
  64962. * @returns the current TransformNode
  64963. */
  64964. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  64965. /**
  64966. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  64967. * @returns the pivot point
  64968. */
  64969. getPivotPoint(): Vector3;
  64970. /**
  64971. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  64972. * @param result the vector3 to store the result
  64973. * @returns this TransformNode.
  64974. */
  64975. getPivotPointToRef(result: Vector3): TransformNode;
  64976. /**
  64977. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  64978. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  64979. */
  64980. getAbsolutePivotPoint(): Vector3;
  64981. /**
  64982. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  64983. * @param result vector3 to store the result
  64984. * @returns this TransformNode.
  64985. */
  64986. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  64987. /**
  64988. * Defines the passed node as the parent of the current node.
  64989. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  64990. * @param node the node ot set as the parent
  64991. * @returns this TransformNode.
  64992. */
  64993. setParent(node: Nullable<Node>): TransformNode;
  64994. private _nonUniformScaling;
  64995. /**
  64996. * True if the scaling property of this object is non uniform eg. (1,2,1)
  64997. */
  64998. readonly nonUniformScaling: boolean;
  64999. /** @hidden */
  65000. _updateNonUniformScalingState(value: boolean): boolean;
  65001. /**
  65002. * Attach the current TransformNode to another TransformNode associated with a bone
  65003. * @param bone Bone affecting the TransformNode
  65004. * @param affectedTransformNode TransformNode associated with the bone
  65005. * @returns this object
  65006. */
  65007. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  65008. /**
  65009. * Detach the transform node if its associated with a bone
  65010. * @returns this object
  65011. */
  65012. detachFromBone(): TransformNode;
  65013. private static _rotationAxisCache;
  65014. /**
  65015. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  65016. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65017. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65018. * The passed axis is also normalized.
  65019. * @param axis the axis to rotate around
  65020. * @param amount the amount to rotate in radians
  65021. * @param space Space to rotate in (Default: local)
  65022. * @returns the TransformNode.
  65023. */
  65024. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  65025. /**
  65026. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  65027. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65028. * The passed axis is also normalized. .
  65029. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  65030. * @param point the point to rotate around
  65031. * @param axis the axis to rotate around
  65032. * @param amount the amount to rotate in radians
  65033. * @returns the TransformNode
  65034. */
  65035. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  65036. /**
  65037. * Translates the mesh along the axis vector for the passed distance in the given space.
  65038. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65039. * @param axis the axis to translate in
  65040. * @param distance the distance to translate
  65041. * @param space Space to rotate in (Default: local)
  65042. * @returns the TransformNode.
  65043. */
  65044. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  65045. /**
  65046. * Adds a rotation step to the mesh current rotation.
  65047. * x, y, z are Euler angles expressed in radians.
  65048. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  65049. * This means this rotation is made in the mesh local space only.
  65050. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  65051. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  65052. * ```javascript
  65053. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  65054. * ```
  65055. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  65056. * 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.
  65057. * @param x Rotation to add
  65058. * @param y Rotation to add
  65059. * @param z Rotation to add
  65060. * @returns the TransformNode.
  65061. */
  65062. addRotation(x: number, y: number, z: number): TransformNode;
  65063. /**
  65064. * Computes the world matrix of the node
  65065. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65066. * @returns the world matrix
  65067. */
  65068. computeWorldMatrix(force?: boolean): Matrix;
  65069. protected _afterComputeWorldMatrix(): void;
  65070. /**
  65071. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  65072. * @param func callback function to add
  65073. *
  65074. * @returns the TransformNode.
  65075. */
  65076. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65077. /**
  65078. * Removes a registered callback function.
  65079. * @param func callback function to remove
  65080. * @returns the TransformNode.
  65081. */
  65082. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65083. /**
  65084. * Gets the position of the current mesh in camera space
  65085. * @param camera defines the camera to use
  65086. * @returns a position
  65087. */
  65088. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  65089. /**
  65090. * Returns the distance from the mesh to the active camera
  65091. * @param camera defines the camera to use
  65092. * @returns the distance
  65093. */
  65094. getDistanceToCamera(camera?: Nullable<Camera>): number;
  65095. /**
  65096. * Clone the current transform node
  65097. * @param name Name of the new clone
  65098. * @param newParent New parent for the clone
  65099. * @param doNotCloneChildren Do not clone children hierarchy
  65100. * @returns the new transform node
  65101. */
  65102. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  65103. /**
  65104. * Serializes the objects information.
  65105. * @param currentSerializationObject defines the object to serialize in
  65106. * @returns the serialized object
  65107. */
  65108. serialize(currentSerializationObject?: any): any;
  65109. /**
  65110. * Returns a new TransformNode object parsed from the source provided.
  65111. * @param parsedTransformNode is the source.
  65112. * @param scene the scne the object belongs to
  65113. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  65114. * @returns a new TransformNode object parsed from the source provided.
  65115. */
  65116. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  65117. /**
  65118. * Get all child-transformNodes of this node
  65119. * @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
  65120. * @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
  65121. * @returns an array of TransformNode
  65122. */
  65123. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  65124. /**
  65125. * Releases resources associated with this transform node.
  65126. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  65127. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  65128. */
  65129. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  65130. }
  65131. }
  65132. declare module BABYLON {
  65133. /**
  65134. * Class used to override all child animations of a given target
  65135. */
  65136. export class AnimationPropertiesOverride {
  65137. /**
  65138. * Gets or sets a value indicating if animation blending must be used
  65139. */
  65140. enableBlending: boolean;
  65141. /**
  65142. * Gets or sets the blending speed to use when enableBlending is true
  65143. */
  65144. blendingSpeed: number;
  65145. /**
  65146. * Gets or sets the default loop mode to use
  65147. */
  65148. loopMode: number;
  65149. }
  65150. }
  65151. declare module BABYLON {
  65152. /**
  65153. * Class used to store bone information
  65154. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  65155. */
  65156. export class Bone extends Node {
  65157. /**
  65158. * defines the bone name
  65159. */
  65160. name: string;
  65161. private static _tmpVecs;
  65162. private static _tmpQuat;
  65163. private static _tmpMats;
  65164. /**
  65165. * Gets the list of child bones
  65166. */
  65167. children: Bone[];
  65168. /** Gets the animations associated with this bone */
  65169. animations: Animation[];
  65170. /**
  65171. * Gets or sets bone length
  65172. */
  65173. length: number;
  65174. /**
  65175. * @hidden Internal only
  65176. * Set this value to map this bone to a different index in the transform matrices
  65177. * Set this value to -1 to exclude the bone from the transform matrices
  65178. */
  65179. _index: Nullable<number>;
  65180. private _skeleton;
  65181. private _localMatrix;
  65182. private _restPose;
  65183. private _baseMatrix;
  65184. private _absoluteTransform;
  65185. private _invertedAbsoluteTransform;
  65186. private _parent;
  65187. private _scalingDeterminant;
  65188. private _worldTransform;
  65189. private _localScaling;
  65190. private _localRotation;
  65191. private _localPosition;
  65192. private _needToDecompose;
  65193. private _needToCompose;
  65194. /** @hidden */
  65195. _linkedTransformNode: Nullable<TransformNode>;
  65196. /** @hidden */
  65197. /** @hidden */
  65198. _matrix: Matrix;
  65199. /**
  65200. * Create a new bone
  65201. * @param name defines the bone name
  65202. * @param skeleton defines the parent skeleton
  65203. * @param parentBone defines the parent (can be null if the bone is the root)
  65204. * @param localMatrix defines the local matrix
  65205. * @param restPose defines the rest pose matrix
  65206. * @param baseMatrix defines the base matrix
  65207. * @param index defines index of the bone in the hiearchy
  65208. */
  65209. constructor(
  65210. /**
  65211. * defines the bone name
  65212. */
  65213. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  65214. /**
  65215. * Gets the current object class name.
  65216. * @return the class name
  65217. */
  65218. getClassName(): string;
  65219. /**
  65220. * Gets the parent skeleton
  65221. * @returns a skeleton
  65222. */
  65223. getSkeleton(): Skeleton;
  65224. /**
  65225. * Gets parent bone
  65226. * @returns a bone or null if the bone is the root of the bone hierarchy
  65227. */
  65228. getParent(): Nullable<Bone>;
  65229. /**
  65230. * Returns an array containing the root bones
  65231. * @returns an array containing the root bones
  65232. */
  65233. getChildren(): Array<Bone>;
  65234. /**
  65235. * Sets the parent bone
  65236. * @param parent defines the parent (can be null if the bone is the root)
  65237. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65238. */
  65239. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  65240. /**
  65241. * Gets the local matrix
  65242. * @returns a matrix
  65243. */
  65244. getLocalMatrix(): Matrix;
  65245. /**
  65246. * Gets the base matrix (initial matrix which remains unchanged)
  65247. * @returns a matrix
  65248. */
  65249. getBaseMatrix(): Matrix;
  65250. /**
  65251. * Gets the rest pose matrix
  65252. * @returns a matrix
  65253. */
  65254. getRestPose(): Matrix;
  65255. /**
  65256. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  65257. */
  65258. getWorldMatrix(): Matrix;
  65259. /**
  65260. * Sets the local matrix to rest pose matrix
  65261. */
  65262. returnToRest(): void;
  65263. /**
  65264. * Gets the inverse of the absolute transform matrix.
  65265. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  65266. * @returns a matrix
  65267. */
  65268. getInvertedAbsoluteTransform(): Matrix;
  65269. /**
  65270. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  65271. * @returns a matrix
  65272. */
  65273. getAbsoluteTransform(): Matrix;
  65274. /**
  65275. * Links with the given transform node.
  65276. * The local matrix of this bone is copied from the transform node every frame.
  65277. * @param transformNode defines the transform node to link to
  65278. */
  65279. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  65280. /** Gets or sets current position (in local space) */
  65281. position: Vector3;
  65282. /** Gets or sets current rotation (in local space) */
  65283. rotation: Vector3;
  65284. /** Gets or sets current rotation quaternion (in local space) */
  65285. rotationQuaternion: Quaternion;
  65286. /** Gets or sets current scaling (in local space) */
  65287. scaling: Vector3;
  65288. /**
  65289. * Gets the animation properties override
  65290. */
  65291. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  65292. private _decompose;
  65293. private _compose;
  65294. /**
  65295. * Update the base and local matrices
  65296. * @param matrix defines the new base or local matrix
  65297. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65298. * @param updateLocalMatrix defines if the local matrix should be updated
  65299. */
  65300. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  65301. /** @hidden */
  65302. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  65303. /**
  65304. * Flag the bone as dirty (Forcing it to update everything)
  65305. */
  65306. markAsDirty(): void;
  65307. private _markAsDirtyAndCompose;
  65308. private _markAsDirtyAndDecompose;
  65309. /**
  65310. * Translate the bone in local or world space
  65311. * @param vec The amount to translate the bone
  65312. * @param space The space that the translation is in
  65313. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65314. */
  65315. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65316. /**
  65317. * Set the postion of the bone in local or world space
  65318. * @param position The position to set the bone
  65319. * @param space The space that the position is in
  65320. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65321. */
  65322. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65323. /**
  65324. * Set the absolute position of the bone (world space)
  65325. * @param position The position to set the bone
  65326. * @param mesh The mesh that this bone is attached to
  65327. */
  65328. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  65329. /**
  65330. * Scale the bone on the x, y and z axes (in local space)
  65331. * @param x The amount to scale the bone on the x axis
  65332. * @param y The amount to scale the bone on the y axis
  65333. * @param z The amount to scale the bone on the z axis
  65334. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  65335. */
  65336. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  65337. /**
  65338. * Set the bone scaling in local space
  65339. * @param scale defines the scaling vector
  65340. */
  65341. setScale(scale: Vector3): void;
  65342. /**
  65343. * Gets the current scaling in local space
  65344. * @returns the current scaling vector
  65345. */
  65346. getScale(): Vector3;
  65347. /**
  65348. * Gets the current scaling in local space and stores it in a target vector
  65349. * @param result defines the target vector
  65350. */
  65351. getScaleToRef(result: Vector3): void;
  65352. /**
  65353. * Set the yaw, pitch, and roll of the bone in local or world space
  65354. * @param yaw The rotation of the bone on the y axis
  65355. * @param pitch The rotation of the bone on the x axis
  65356. * @param roll The rotation of the bone on the z axis
  65357. * @param space The space that the axes of rotation are in
  65358. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65359. */
  65360. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  65361. /**
  65362. * Add a rotation to the bone on an axis in local or world space
  65363. * @param axis The axis to rotate the bone on
  65364. * @param amount The amount to rotate the bone
  65365. * @param space The space that the axis is in
  65366. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65367. */
  65368. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  65369. /**
  65370. * Set the rotation of the bone to a particular axis angle in local or world space
  65371. * @param axis The axis to rotate the bone on
  65372. * @param angle The angle that the bone should be rotated to
  65373. * @param space The space that the axis is in
  65374. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65375. */
  65376. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  65377. /**
  65378. * Set the euler rotation of the bone in local of world space
  65379. * @param rotation The euler rotation that the bone should be set to
  65380. * @param space The space that the rotation is in
  65381. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65382. */
  65383. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65384. /**
  65385. * Set the quaternion rotation of the bone in local of world space
  65386. * @param quat The quaternion rotation that the bone should be set to
  65387. * @param space The space that the rotation is in
  65388. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65389. */
  65390. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  65391. /**
  65392. * Set the rotation matrix of the bone in local of world space
  65393. * @param rotMat The rotation matrix that the bone should be set to
  65394. * @param space The space that the rotation is in
  65395. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65396. */
  65397. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  65398. private _rotateWithMatrix;
  65399. private _getNegativeRotationToRef;
  65400. /**
  65401. * Get the position of the bone in local or world space
  65402. * @param space The space that the returned position is in
  65403. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65404. * @returns The position of the bone
  65405. */
  65406. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65407. /**
  65408. * Copy the position of the bone to a vector3 in local or world space
  65409. * @param space The space that the returned position is in
  65410. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65411. * @param result The vector3 to copy the position to
  65412. */
  65413. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  65414. /**
  65415. * Get the absolute position of the bone (world space)
  65416. * @param mesh The mesh that this bone is attached to
  65417. * @returns The absolute position of the bone
  65418. */
  65419. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  65420. /**
  65421. * Copy the absolute position of the bone (world space) to the result param
  65422. * @param mesh The mesh that this bone is attached to
  65423. * @param result The vector3 to copy the absolute position to
  65424. */
  65425. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  65426. /**
  65427. * Compute the absolute transforms of this bone and its children
  65428. */
  65429. computeAbsoluteTransforms(): void;
  65430. /**
  65431. * Get the world direction from an axis that is in the local space of the bone
  65432. * @param localAxis The local direction that is used to compute the world direction
  65433. * @param mesh The mesh that this bone is attached to
  65434. * @returns The world direction
  65435. */
  65436. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65437. /**
  65438. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  65439. * @param localAxis The local direction that is used to compute the world direction
  65440. * @param mesh The mesh that this bone is attached to
  65441. * @param result The vector3 that the world direction will be copied to
  65442. */
  65443. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65444. /**
  65445. * Get the euler rotation of the bone in local or world space
  65446. * @param space The space that the rotation should be in
  65447. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65448. * @returns The euler rotation
  65449. */
  65450. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65451. /**
  65452. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  65453. * @param space The space that the rotation should be in
  65454. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65455. * @param result The vector3 that the rotation should be copied to
  65456. */
  65457. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65458. /**
  65459. * Get the quaternion rotation of the bone in either local or world space
  65460. * @param space The space that the rotation should be in
  65461. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65462. * @returns The quaternion rotation
  65463. */
  65464. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  65465. /**
  65466. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  65467. * @param space The space that the rotation should be in
  65468. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65469. * @param result The quaternion that the rotation should be copied to
  65470. */
  65471. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  65472. /**
  65473. * Get the rotation matrix of the bone in local or world space
  65474. * @param space The space that the rotation should be in
  65475. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65476. * @returns The rotation matrix
  65477. */
  65478. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  65479. /**
  65480. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  65481. * @param space The space that the rotation should be in
  65482. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65483. * @param result The quaternion that the rotation should be copied to
  65484. */
  65485. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  65486. /**
  65487. * Get the world position of a point that is in the local space of the bone
  65488. * @param position The local position
  65489. * @param mesh The mesh that this bone is attached to
  65490. * @returns The world position
  65491. */
  65492. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65493. /**
  65494. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  65495. * @param position The local position
  65496. * @param mesh The mesh that this bone is attached to
  65497. * @param result The vector3 that the world position should be copied to
  65498. */
  65499. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65500. /**
  65501. * Get the local position of a point that is in world space
  65502. * @param position The world position
  65503. * @param mesh The mesh that this bone is attached to
  65504. * @returns The local position
  65505. */
  65506. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65507. /**
  65508. * Get the local position of a point that is in world space and copy it to the result param
  65509. * @param position The world position
  65510. * @param mesh The mesh that this bone is attached to
  65511. * @param result The vector3 that the local position should be copied to
  65512. */
  65513. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65514. }
  65515. }
  65516. declare module BABYLON {
  65517. /**
  65518. * Class for creating a cube texture
  65519. */
  65520. export class CubeTexture extends BaseTexture {
  65521. private _delayedOnLoad;
  65522. /**
  65523. * The url of the texture
  65524. */
  65525. url: string;
  65526. /**
  65527. * Gets or sets the center of the bounding box associated with the cube texture.
  65528. * It must define where the camera used to render the texture was set
  65529. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65530. */
  65531. boundingBoxPosition: Vector3;
  65532. private _boundingBoxSize;
  65533. /**
  65534. * Gets or sets the size of the bounding box associated with the cube texture
  65535. * When defined, the cubemap will switch to local mode
  65536. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65537. * @example https://www.babylonjs-playground.com/#RNASML
  65538. */
  65539. /**
  65540. * Returns the bounding box size
  65541. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65542. */
  65543. boundingBoxSize: Vector3;
  65544. protected _rotationY: number;
  65545. /**
  65546. * Sets texture matrix rotation angle around Y axis in radians.
  65547. */
  65548. /**
  65549. * Gets texture matrix rotation angle around Y axis radians.
  65550. */
  65551. rotationY: number;
  65552. /**
  65553. * Are mip maps generated for this texture or not.
  65554. */
  65555. readonly noMipmap: boolean;
  65556. private _noMipmap;
  65557. private _files;
  65558. private _extensions;
  65559. private _textureMatrix;
  65560. private _format;
  65561. private _createPolynomials;
  65562. /** @hidden */
  65563. _prefiltered: boolean;
  65564. /**
  65565. * Creates a cube texture from an array of image urls
  65566. * @param files defines an array of image urls
  65567. * @param scene defines the hosting scene
  65568. * @param noMipmap specifies if mip maps are not used
  65569. * @returns a cube texture
  65570. */
  65571. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  65572. /**
  65573. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  65574. * @param url defines the url of the prefiltered texture
  65575. * @param scene defines the scene the texture is attached to
  65576. * @param forcedExtension defines the extension of the file if different from the url
  65577. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65578. * @return the prefiltered texture
  65579. */
  65580. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  65581. /**
  65582. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  65583. * as prefiltered data.
  65584. * @param rootUrl defines the url of the texture or the root name of the six images
  65585. * @param scene defines the scene the texture is attached to
  65586. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  65587. * @param noMipmap defines if mipmaps should be created or not
  65588. * @param files defines the six files to load for the different faces
  65589. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  65590. * @param onError defines a callback triggered in case of error during load
  65591. * @param format defines the internal format to use for the texture once loaded
  65592. * @param prefiltered defines whether or not the texture is created from prefiltered data
  65593. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  65594. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65595. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65596. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65597. * @return the cube texture
  65598. */
  65599. 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);
  65600. /**
  65601. * Get the current class name of the texture useful for serialization or dynamic coding.
  65602. * @returns "CubeTexture"
  65603. */
  65604. getClassName(): string;
  65605. /**
  65606. * Update the url (and optional buffer) of this texture if url was null during construction.
  65607. * @param url the url of the texture
  65608. * @param forcedExtension defines the extension to use
  65609. * @param onLoad callback called when the texture is loaded (defaults to null)
  65610. */
  65611. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  65612. /**
  65613. * Delays loading of the cube texture
  65614. * @param forcedExtension defines the extension to use
  65615. */
  65616. delayLoad(forcedExtension?: string): void;
  65617. /**
  65618. * Returns the reflection texture matrix
  65619. * @returns the reflection texture matrix
  65620. */
  65621. getReflectionTextureMatrix(): Matrix;
  65622. /**
  65623. * Sets the reflection texture matrix
  65624. * @param value Reflection texture matrix
  65625. */
  65626. setReflectionTextureMatrix(value: Matrix): void;
  65627. /**
  65628. * Parses text to create a cube texture
  65629. * @param parsedTexture define the serialized text to read from
  65630. * @param scene defines the hosting scene
  65631. * @param rootUrl defines the root url of the cube texture
  65632. * @returns a cube texture
  65633. */
  65634. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  65635. /**
  65636. * Makes a clone, or deep copy, of the cube texture
  65637. * @returns a new cube texture
  65638. */
  65639. clone(): CubeTexture;
  65640. }
  65641. }
  65642. declare module BABYLON {
  65643. /** @hidden */
  65644. export var postprocessVertexShader: {
  65645. name: string;
  65646. shader: string;
  65647. };
  65648. }
  65649. declare module BABYLON {
  65650. /**
  65651. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  65652. * This is the base of the follow, arc rotate cameras and Free camera
  65653. * @see http://doc.babylonjs.com/features/cameras
  65654. */
  65655. export class TargetCamera extends Camera {
  65656. private static _RigCamTransformMatrix;
  65657. private static _TargetTransformMatrix;
  65658. private static _TargetFocalPoint;
  65659. /**
  65660. * Define the current direction the camera is moving to
  65661. */
  65662. cameraDirection: Vector3;
  65663. /**
  65664. * Define the current rotation the camera is rotating to
  65665. */
  65666. cameraRotation: Vector2;
  65667. /**
  65668. * When set, the up vector of the camera will be updated by the rotation of the camera
  65669. */
  65670. updateUpVectorFromRotation: boolean;
  65671. private _tmpQuaternion;
  65672. /**
  65673. * Define the current rotation of the camera
  65674. */
  65675. rotation: Vector3;
  65676. /**
  65677. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  65678. */
  65679. rotationQuaternion: Quaternion;
  65680. /**
  65681. * Define the current speed of the camera
  65682. */
  65683. speed: number;
  65684. /**
  65685. * Add cconstraint to the camera to prevent it to move freely in all directions and
  65686. * around all axis.
  65687. */
  65688. noRotationConstraint: boolean;
  65689. /**
  65690. * Define the current target of the camera as an object or a position.
  65691. */
  65692. lockedTarget: any;
  65693. /** @hidden */
  65694. _currentTarget: Vector3;
  65695. /** @hidden */
  65696. _initialFocalDistance: number;
  65697. /** @hidden */
  65698. _viewMatrix: Matrix;
  65699. /** @hidden */
  65700. _camMatrix: Matrix;
  65701. /** @hidden */
  65702. _cameraTransformMatrix: Matrix;
  65703. /** @hidden */
  65704. _cameraRotationMatrix: Matrix;
  65705. /** @hidden */
  65706. _referencePoint: Vector3;
  65707. /** @hidden */
  65708. _transformedReferencePoint: Vector3;
  65709. protected _globalCurrentTarget: Vector3;
  65710. protected _globalCurrentUpVector: Vector3;
  65711. /** @hidden */
  65712. _reset: () => void;
  65713. private _defaultUp;
  65714. /**
  65715. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  65716. * This is the base of the follow, arc rotate cameras and Free camera
  65717. * @see http://doc.babylonjs.com/features/cameras
  65718. * @param name Defines the name of the camera in the scene
  65719. * @param position Defines the start position of the camera in the scene
  65720. * @param scene Defines the scene the camera belongs to
  65721. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  65722. */
  65723. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  65724. /**
  65725. * Gets the position in front of the camera at a given distance.
  65726. * @param distance The distance from the camera we want the position to be
  65727. * @returns the position
  65728. */
  65729. getFrontPosition(distance: number): Vector3;
  65730. /** @hidden */
  65731. _getLockedTargetPosition(): Nullable<Vector3>;
  65732. private _storedPosition;
  65733. private _storedRotation;
  65734. private _storedRotationQuaternion;
  65735. /**
  65736. * Store current camera state of the camera (fov, position, rotation, etc..)
  65737. * @returns the camera
  65738. */
  65739. storeState(): Camera;
  65740. /**
  65741. * Restored camera state. You must call storeState() first
  65742. * @returns whether it was successful or not
  65743. * @hidden
  65744. */
  65745. _restoreStateValues(): boolean;
  65746. /** @hidden */
  65747. _initCache(): void;
  65748. /** @hidden */
  65749. _updateCache(ignoreParentClass?: boolean): void;
  65750. /** @hidden */
  65751. _isSynchronizedViewMatrix(): boolean;
  65752. /** @hidden */
  65753. _computeLocalCameraSpeed(): number;
  65754. /** @hidden */
  65755. setTarget(target: Vector3): void;
  65756. /**
  65757. * Return the current target position of the camera. This value is expressed in local space.
  65758. * @returns the target position
  65759. */
  65760. getTarget(): Vector3;
  65761. /** @hidden */
  65762. _decideIfNeedsToMove(): boolean;
  65763. /** @hidden */
  65764. _updatePosition(): void;
  65765. /** @hidden */
  65766. _checkInputs(): void;
  65767. protected _updateCameraRotationMatrix(): void;
  65768. /**
  65769. * 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)
  65770. * @returns the current camera
  65771. */
  65772. private _rotateUpVectorWithCameraRotationMatrix;
  65773. private _cachedRotationZ;
  65774. private _cachedQuaternionRotationZ;
  65775. /** @hidden */
  65776. _getViewMatrix(): Matrix;
  65777. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  65778. /**
  65779. * @hidden
  65780. */
  65781. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  65782. /**
  65783. * @hidden
  65784. */
  65785. _updateRigCameras(): void;
  65786. private _getRigCamPositionAndTarget;
  65787. /**
  65788. * Gets the current object class name.
  65789. * @return the class name
  65790. */
  65791. getClassName(): string;
  65792. }
  65793. }
  65794. declare module BABYLON {
  65795. /**
  65796. * @ignore
  65797. * This is a list of all the different input types that are available in the application.
  65798. * Fo instance: ArcRotateCameraGamepadInput...
  65799. */
  65800. export var CameraInputTypes: {};
  65801. /**
  65802. * This is the contract to implement in order to create a new input class.
  65803. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  65804. */
  65805. export interface ICameraInput<TCamera extends Camera> {
  65806. /**
  65807. * Defines the camera the input is attached to.
  65808. */
  65809. camera: Nullable<TCamera>;
  65810. /**
  65811. * Gets the class name of the current intput.
  65812. * @returns the class name
  65813. */
  65814. getClassName(): string;
  65815. /**
  65816. * Get the friendly name associated with the input class.
  65817. * @returns the input friendly name
  65818. */
  65819. getSimpleName(): string;
  65820. /**
  65821. * Attach the input controls to a specific dom element to get the input from.
  65822. * @param element Defines the element the controls should be listened from
  65823. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65824. */
  65825. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  65826. /**
  65827. * Detach the current controls from the specified dom element.
  65828. * @param element Defines the element to stop listening the inputs from
  65829. */
  65830. detachControl(element: Nullable<HTMLElement>): void;
  65831. /**
  65832. * Update the current camera state depending on the inputs that have been used this frame.
  65833. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  65834. */
  65835. checkInputs?: () => void;
  65836. }
  65837. /**
  65838. * Represents a map of input types to input instance or input index to input instance.
  65839. */
  65840. export interface CameraInputsMap<TCamera extends Camera> {
  65841. /**
  65842. * Accessor to the input by input type.
  65843. */
  65844. [name: string]: ICameraInput<TCamera>;
  65845. /**
  65846. * Accessor to the input by input index.
  65847. */
  65848. [idx: number]: ICameraInput<TCamera>;
  65849. }
  65850. /**
  65851. * This represents the input manager used within a camera.
  65852. * It helps dealing with all the different kind of input attached to a camera.
  65853. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  65854. */
  65855. export class CameraInputsManager<TCamera extends Camera> {
  65856. /**
  65857. * Defines the list of inputs attahed to the camera.
  65858. */
  65859. attached: CameraInputsMap<TCamera>;
  65860. /**
  65861. * Defines the dom element the camera is collecting inputs from.
  65862. * This is null if the controls have not been attached.
  65863. */
  65864. attachedElement: Nullable<HTMLElement>;
  65865. /**
  65866. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65867. */
  65868. noPreventDefault: boolean;
  65869. /**
  65870. * Defined the camera the input manager belongs to.
  65871. */
  65872. camera: TCamera;
  65873. /**
  65874. * Update the current camera state depending on the inputs that have been used this frame.
  65875. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  65876. */
  65877. checkInputs: () => void;
  65878. /**
  65879. * Instantiate a new Camera Input Manager.
  65880. * @param camera Defines the camera the input manager blongs to
  65881. */
  65882. constructor(camera: TCamera);
  65883. /**
  65884. * Add an input method to a camera
  65885. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  65886. * @param input camera input method
  65887. */
  65888. add(input: ICameraInput<TCamera>): void;
  65889. /**
  65890. * Remove a specific input method from a camera
  65891. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  65892. * @param inputToRemove camera input method
  65893. */
  65894. remove(inputToRemove: ICameraInput<TCamera>): void;
  65895. /**
  65896. * Remove a specific input type from a camera
  65897. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  65898. * @param inputType the type of the input to remove
  65899. */
  65900. removeByType(inputType: string): void;
  65901. private _addCheckInputs;
  65902. /**
  65903. * Attach the input controls to the currently attached dom element to listen the events from.
  65904. * @param input Defines the input to attach
  65905. */
  65906. attachInput(input: ICameraInput<TCamera>): void;
  65907. /**
  65908. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  65909. * @param element Defines the dom element to collect the events from
  65910. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65911. */
  65912. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  65913. /**
  65914. * Detach the current manager inputs controls from a specific dom element.
  65915. * @param element Defines the dom element to collect the events from
  65916. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  65917. */
  65918. detachElement(element: HTMLElement, disconnect?: boolean): void;
  65919. /**
  65920. * Rebuild the dynamic inputCheck function from the current list of
  65921. * defined inputs in the manager.
  65922. */
  65923. rebuildInputCheck(): void;
  65924. /**
  65925. * Remove all attached input methods from a camera
  65926. */
  65927. clear(): void;
  65928. /**
  65929. * Serialize the current input manager attached to a camera.
  65930. * This ensures than once parsed,
  65931. * the input associated to the camera will be identical to the current ones
  65932. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  65933. */
  65934. serialize(serializedCamera: any): void;
  65935. /**
  65936. * Parses an input manager serialized JSON to restore the previous list of inputs
  65937. * and states associated to a camera.
  65938. * @param parsedCamera Defines the JSON to parse
  65939. */
  65940. parse(parsedCamera: any): void;
  65941. }
  65942. }
  65943. declare module BABYLON {
  65944. /**
  65945. * Gather the list of keyboard event types as constants.
  65946. */
  65947. export class KeyboardEventTypes {
  65948. /**
  65949. * The keydown event is fired when a key becomes active (pressed).
  65950. */
  65951. static readonly KEYDOWN: number;
  65952. /**
  65953. * The keyup event is fired when a key has been released.
  65954. */
  65955. static readonly KEYUP: number;
  65956. }
  65957. /**
  65958. * This class is used to store keyboard related info for the onKeyboardObservable event.
  65959. */
  65960. export class KeyboardInfo {
  65961. /**
  65962. * Defines the type of event (KeyboardEventTypes)
  65963. */
  65964. type: number;
  65965. /**
  65966. * Defines the related dom event
  65967. */
  65968. event: KeyboardEvent;
  65969. /**
  65970. * Instantiates a new keyboard info.
  65971. * This class is used to store keyboard related info for the onKeyboardObservable event.
  65972. * @param type Defines the type of event (KeyboardEventTypes)
  65973. * @param event Defines the related dom event
  65974. */
  65975. constructor(
  65976. /**
  65977. * Defines the type of event (KeyboardEventTypes)
  65978. */
  65979. type: number,
  65980. /**
  65981. * Defines the related dom event
  65982. */
  65983. event: KeyboardEvent);
  65984. }
  65985. /**
  65986. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  65987. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  65988. */
  65989. export class KeyboardInfoPre extends KeyboardInfo {
  65990. /**
  65991. * Defines the type of event (KeyboardEventTypes)
  65992. */
  65993. type: number;
  65994. /**
  65995. * Defines the related dom event
  65996. */
  65997. event: KeyboardEvent;
  65998. /**
  65999. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  66000. */
  66001. skipOnPointerObservable: boolean;
  66002. /**
  66003. * Instantiates a new keyboard pre info.
  66004. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66005. * @param type Defines the type of event (KeyboardEventTypes)
  66006. * @param event Defines the related dom event
  66007. */
  66008. constructor(
  66009. /**
  66010. * Defines the type of event (KeyboardEventTypes)
  66011. */
  66012. type: number,
  66013. /**
  66014. * Defines the related dom event
  66015. */
  66016. event: KeyboardEvent);
  66017. }
  66018. }
  66019. declare module BABYLON {
  66020. /**
  66021. * Manage the keyboard inputs to control the movement of a free camera.
  66022. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66023. */
  66024. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  66025. /**
  66026. * Defines the camera the input is attached to.
  66027. */
  66028. camera: FreeCamera;
  66029. /**
  66030. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  66031. */
  66032. keysUp: number[];
  66033. /**
  66034. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  66035. */
  66036. keysDown: number[];
  66037. /**
  66038. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  66039. */
  66040. keysLeft: number[];
  66041. /**
  66042. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  66043. */
  66044. keysRight: number[];
  66045. private _keys;
  66046. private _onCanvasBlurObserver;
  66047. private _onKeyboardObserver;
  66048. private _engine;
  66049. private _scene;
  66050. /**
  66051. * Attach the input controls to a specific dom element to get the input from.
  66052. * @param element Defines the element the controls should be listened from
  66053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66054. */
  66055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66056. /**
  66057. * Detach the current controls from the specified dom element.
  66058. * @param element Defines the element to stop listening the inputs from
  66059. */
  66060. detachControl(element: Nullable<HTMLElement>): void;
  66061. /**
  66062. * Update the current camera state depending on the inputs that have been used this frame.
  66063. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66064. */
  66065. checkInputs(): void;
  66066. /**
  66067. * Gets the class name of the current intput.
  66068. * @returns the class name
  66069. */
  66070. getClassName(): string;
  66071. /** @hidden */
  66072. _onLostFocus(): void;
  66073. /**
  66074. * Get the friendly name associated with the input class.
  66075. * @returns the input friendly name
  66076. */
  66077. getSimpleName(): string;
  66078. }
  66079. }
  66080. declare module BABYLON {
  66081. /**
  66082. * Interface describing all the common properties and methods a shadow light needs to implement.
  66083. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  66084. * as well as binding the different shadow properties to the effects.
  66085. */
  66086. export interface IShadowLight extends Light {
  66087. /**
  66088. * The light id in the scene (used in scene.findLighById for instance)
  66089. */
  66090. id: string;
  66091. /**
  66092. * The position the shdow will be casted from.
  66093. */
  66094. position: Vector3;
  66095. /**
  66096. * In 2d mode (needCube being false), the direction used to cast the shadow.
  66097. */
  66098. direction: Vector3;
  66099. /**
  66100. * The transformed position. Position of the light in world space taking parenting in account.
  66101. */
  66102. transformedPosition: Vector3;
  66103. /**
  66104. * The transformed direction. Direction of the light in world space taking parenting in account.
  66105. */
  66106. transformedDirection: Vector3;
  66107. /**
  66108. * The friendly name of the light in the scene.
  66109. */
  66110. name: string;
  66111. /**
  66112. * Defines the shadow projection clipping minimum z value.
  66113. */
  66114. shadowMinZ: number;
  66115. /**
  66116. * Defines the shadow projection clipping maximum z value.
  66117. */
  66118. shadowMaxZ: number;
  66119. /**
  66120. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66121. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66122. */
  66123. computeTransformedInformation(): boolean;
  66124. /**
  66125. * Gets the scene the light belongs to.
  66126. * @returns The scene
  66127. */
  66128. getScene(): Scene;
  66129. /**
  66130. * Callback defining a custom Projection Matrix Builder.
  66131. * This can be used to override the default projection matrix computation.
  66132. */
  66133. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66134. /**
  66135. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66136. * @param matrix The materix to updated with the projection information
  66137. * @param viewMatrix The transform matrix of the light
  66138. * @param renderList The list of mesh to render in the map
  66139. * @returns The current light
  66140. */
  66141. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66142. /**
  66143. * Gets the current depth scale used in ESM.
  66144. * @returns The scale
  66145. */
  66146. getDepthScale(): number;
  66147. /**
  66148. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66149. * @returns true if a cube texture needs to be use
  66150. */
  66151. needCube(): boolean;
  66152. /**
  66153. * Detects if the projection matrix requires to be recomputed this frame.
  66154. * @returns true if it requires to be recomputed otherwise, false.
  66155. */
  66156. needProjectionMatrixCompute(): boolean;
  66157. /**
  66158. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66159. */
  66160. forceProjectionMatrixCompute(): void;
  66161. /**
  66162. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66163. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66164. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66165. */
  66166. getShadowDirection(faceIndex?: number): Vector3;
  66167. /**
  66168. * Gets the minZ used for shadow according to both the scene and the light.
  66169. * @param activeCamera The camera we are returning the min for
  66170. * @returns the depth min z
  66171. */
  66172. getDepthMinZ(activeCamera: Camera): number;
  66173. /**
  66174. * Gets the maxZ used for shadow according to both the scene and the light.
  66175. * @param activeCamera The camera we are returning the max for
  66176. * @returns the depth max z
  66177. */
  66178. getDepthMaxZ(activeCamera: Camera): number;
  66179. }
  66180. /**
  66181. * Base implementation IShadowLight
  66182. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  66183. */
  66184. export abstract class ShadowLight extends Light implements IShadowLight {
  66185. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  66186. protected _position: Vector3;
  66187. protected _setPosition(value: Vector3): void;
  66188. /**
  66189. * Sets the position the shadow will be casted from. Also use as the light position for both
  66190. * point and spot lights.
  66191. */
  66192. /**
  66193. * Sets the position the shadow will be casted from. Also use as the light position for both
  66194. * point and spot lights.
  66195. */
  66196. position: Vector3;
  66197. protected _direction: Vector3;
  66198. protected _setDirection(value: Vector3): void;
  66199. /**
  66200. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  66201. * Also use as the light direction on spot and directional lights.
  66202. */
  66203. /**
  66204. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  66205. * Also use as the light direction on spot and directional lights.
  66206. */
  66207. direction: Vector3;
  66208. private _shadowMinZ;
  66209. /**
  66210. * Gets the shadow projection clipping minimum z value.
  66211. */
  66212. /**
  66213. * Sets the shadow projection clipping minimum z value.
  66214. */
  66215. shadowMinZ: number;
  66216. private _shadowMaxZ;
  66217. /**
  66218. * Sets the shadow projection clipping maximum z value.
  66219. */
  66220. /**
  66221. * Gets the shadow projection clipping maximum z value.
  66222. */
  66223. shadowMaxZ: number;
  66224. /**
  66225. * Callback defining a custom Projection Matrix Builder.
  66226. * This can be used to override the default projection matrix computation.
  66227. */
  66228. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66229. /**
  66230. * The transformed position. Position of the light in world space taking parenting in account.
  66231. */
  66232. transformedPosition: Vector3;
  66233. /**
  66234. * The transformed direction. Direction of the light in world space taking parenting in account.
  66235. */
  66236. transformedDirection: Vector3;
  66237. private _needProjectionMatrixCompute;
  66238. /**
  66239. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66240. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66241. */
  66242. computeTransformedInformation(): boolean;
  66243. /**
  66244. * Return the depth scale used for the shadow map.
  66245. * @returns the depth scale.
  66246. */
  66247. getDepthScale(): number;
  66248. /**
  66249. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66250. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66251. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66252. */
  66253. getShadowDirection(faceIndex?: number): Vector3;
  66254. /**
  66255. * Returns the ShadowLight absolute position in the World.
  66256. * @returns the position vector in world space
  66257. */
  66258. getAbsolutePosition(): Vector3;
  66259. /**
  66260. * Sets the ShadowLight direction toward the passed target.
  66261. * @param target The point to target in local space
  66262. * @returns the updated ShadowLight direction
  66263. */
  66264. setDirectionToTarget(target: Vector3): Vector3;
  66265. /**
  66266. * Returns the light rotation in euler definition.
  66267. * @returns the x y z rotation in local space.
  66268. */
  66269. getRotation(): Vector3;
  66270. /**
  66271. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66272. * @returns true if a cube texture needs to be use
  66273. */
  66274. needCube(): boolean;
  66275. /**
  66276. * Detects if the projection matrix requires to be recomputed this frame.
  66277. * @returns true if it requires to be recomputed otherwise, false.
  66278. */
  66279. needProjectionMatrixCompute(): boolean;
  66280. /**
  66281. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66282. */
  66283. forceProjectionMatrixCompute(): void;
  66284. /** @hidden */
  66285. _initCache(): void;
  66286. /** @hidden */
  66287. _isSynchronized(): boolean;
  66288. /**
  66289. * Computes the world matrix of the node
  66290. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66291. * @returns the world matrix
  66292. */
  66293. computeWorldMatrix(force?: boolean): Matrix;
  66294. /**
  66295. * Gets the minZ used for shadow according to both the scene and the light.
  66296. * @param activeCamera The camera we are returning the min for
  66297. * @returns the depth min z
  66298. */
  66299. getDepthMinZ(activeCamera: Camera): number;
  66300. /**
  66301. * Gets the maxZ used for shadow according to both the scene and the light.
  66302. * @param activeCamera The camera we are returning the max for
  66303. * @returns the depth max z
  66304. */
  66305. getDepthMaxZ(activeCamera: Camera): number;
  66306. /**
  66307. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66308. * @param matrix The materix to updated with the projection information
  66309. * @param viewMatrix The transform matrix of the light
  66310. * @param renderList The list of mesh to render in the map
  66311. * @returns The current light
  66312. */
  66313. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66314. }
  66315. }
  66316. declare module BABYLON {
  66317. /**
  66318. * "Static Class" containing the most commonly used helper while dealing with material for
  66319. * rendering purpose.
  66320. *
  66321. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66322. *
  66323. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66324. */
  66325. export class MaterialHelper {
  66326. /**
  66327. * Bind the current view position to an effect.
  66328. * @param effect The effect to be bound
  66329. * @param scene The scene the eyes position is used from
  66330. */
  66331. static BindEyePosition(effect: Effect, scene: Scene): void;
  66332. /**
  66333. * Helps preparing the defines values about the UVs in used in the effect.
  66334. * UVs are shared as much as we can accross channels in the shaders.
  66335. * @param texture The texture we are preparing the UVs for
  66336. * @param defines The defines to update
  66337. * @param key The channel key "diffuse", "specular"... used in the shader
  66338. */
  66339. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  66340. /**
  66341. * Binds a texture matrix value to its corrsponding uniform
  66342. * @param texture The texture to bind the matrix for
  66343. * @param uniformBuffer The uniform buffer receivin the data
  66344. * @param key The channel key "diffuse", "specular"... used in the shader
  66345. */
  66346. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  66347. /**
  66348. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66349. * @param mesh defines the current mesh
  66350. * @param scene defines the current scene
  66351. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66352. * @param pointsCloud defines if point cloud rendering has to be turned on
  66353. * @param fogEnabled defines if fog has to be turned on
  66354. * @param alphaTest defines if alpha testing has to be turned on
  66355. * @param defines defines the current list of defines
  66356. */
  66357. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  66358. /**
  66359. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66360. * @param scene defines the current scene
  66361. * @param engine defines the current engine
  66362. * @param defines specifies the list of active defines
  66363. * @param useInstances defines if instances have to be turned on
  66364. * @param useClipPlane defines if clip plane have to be turned on
  66365. */
  66366. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  66367. /**
  66368. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  66369. * @param mesh The mesh containing the geometry data we will draw
  66370. * @param defines The defines to update
  66371. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  66372. * @param useBones Precise whether bones should be used or not (override mesh info)
  66373. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  66374. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  66375. * @returns false if defines are considered not dirty and have not been checked
  66376. */
  66377. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  66378. /**
  66379. * Prepares the defines related to the light information passed in parameter
  66380. * @param scene The scene we are intending to draw
  66381. * @param mesh The mesh the effect is compiling for
  66382. * @param defines The defines to update
  66383. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  66384. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  66385. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  66386. * @returns true if normals will be required for the rest of the effect
  66387. */
  66388. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  66389. /**
  66390. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  66391. * that won t be acctive due to defines being turned off.
  66392. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  66393. * @param samplersList The samplers list
  66394. * @param defines The defines helping in the list generation
  66395. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  66396. */
  66397. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  66398. /**
  66399. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  66400. * @param defines The defines to update while falling back
  66401. * @param fallbacks The authorized effect fallbacks
  66402. * @param maxSimultaneousLights The maximum number of lights allowed
  66403. * @param rank the current rank of the Effect
  66404. * @returns The newly affected rank
  66405. */
  66406. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  66407. /**
  66408. * Prepares the list of attributes required for morph targets according to the effect defines.
  66409. * @param attribs The current list of supported attribs
  66410. * @param mesh The mesh to prepare the morph targets attributes for
  66411. * @param defines The current Defines of the effect
  66412. */
  66413. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  66414. /**
  66415. * Prepares the list of attributes required for bones according to the effect defines.
  66416. * @param attribs The current list of supported attribs
  66417. * @param mesh The mesh to prepare the bones attributes for
  66418. * @param defines The current Defines of the effect
  66419. * @param fallbacks The current efffect fallback strategy
  66420. */
  66421. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  66422. /**
  66423. * Prepares the list of attributes required for instances according to the effect defines.
  66424. * @param attribs The current list of supported attribs
  66425. * @param defines The current Defines of the effect
  66426. */
  66427. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  66428. /**
  66429. * Binds the light shadow information to the effect for the given mesh.
  66430. * @param light The light containing the generator
  66431. * @param scene The scene the lights belongs to
  66432. * @param mesh The mesh we are binding the information to render
  66433. * @param lightIndex The light index in the effect used to render the mesh
  66434. * @param effect The effect we are binding the data to
  66435. */
  66436. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  66437. /**
  66438. * Binds the light information to the effect.
  66439. * @param light The light containing the generator
  66440. * @param effect The effect we are binding the data to
  66441. * @param lightIndex The light index in the effect used to render
  66442. */
  66443. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  66444. /**
  66445. * Binds the lights information from the scene to the effect for the given mesh.
  66446. * @param scene The scene the lights belongs to
  66447. * @param mesh The mesh we are binding the information to render
  66448. * @param effect The effect we are binding the data to
  66449. * @param defines The generated defines for the effect
  66450. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66451. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66452. */
  66453. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  66454. private static _tempFogColor;
  66455. /**
  66456. * Binds the fog information from the scene to the effect for the given mesh.
  66457. * @param scene The scene the lights belongs to
  66458. * @param mesh The mesh we are binding the information to render
  66459. * @param effect The effect we are binding the data to
  66460. * @param linearSpace Defines if the fog effect is applied in linear space
  66461. */
  66462. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  66463. /**
  66464. * Binds the bones information from the mesh to the effect.
  66465. * @param mesh The mesh we are binding the information to render
  66466. * @param effect The effect we are binding the data to
  66467. */
  66468. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  66469. /**
  66470. * Binds the morph targets information from the mesh to the effect.
  66471. * @param abstractMesh The mesh we are binding the information to render
  66472. * @param effect The effect we are binding the data to
  66473. */
  66474. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  66475. /**
  66476. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66477. * @param defines The generated defines used in the effect
  66478. * @param effect The effect we are binding the data to
  66479. * @param scene The scene we are willing to render with logarithmic scale for
  66480. */
  66481. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  66482. /**
  66483. * Binds the clip plane information from the scene to the effect.
  66484. * @param scene The scene the clip plane information are extracted from
  66485. * @param effect The effect we are binding the data to
  66486. */
  66487. static BindClipPlane(effect: Effect, scene: Scene): void;
  66488. }
  66489. }
  66490. declare module BABYLON {
  66491. /** @hidden */
  66492. export var kernelBlurVaryingDeclaration: {
  66493. name: string;
  66494. shader: string;
  66495. };
  66496. }
  66497. declare module BABYLON {
  66498. /** @hidden */
  66499. export var kernelBlurFragment: {
  66500. name: string;
  66501. shader: string;
  66502. };
  66503. }
  66504. declare module BABYLON {
  66505. /** @hidden */
  66506. export var kernelBlurFragment2: {
  66507. name: string;
  66508. shader: string;
  66509. };
  66510. }
  66511. declare module BABYLON {
  66512. /** @hidden */
  66513. export var kernelBlurPixelShader: {
  66514. name: string;
  66515. shader: string;
  66516. };
  66517. }
  66518. declare module BABYLON {
  66519. /** @hidden */
  66520. export var kernelBlurVertex: {
  66521. name: string;
  66522. shader: string;
  66523. };
  66524. }
  66525. declare module BABYLON {
  66526. /** @hidden */
  66527. export var kernelBlurVertexShader: {
  66528. name: string;
  66529. shader: string;
  66530. };
  66531. }
  66532. declare module BABYLON {
  66533. /**
  66534. * The Blur Post Process which blurs an image based on a kernel and direction.
  66535. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  66536. */
  66537. export class BlurPostProcess extends PostProcess {
  66538. /** The direction in which to blur the image. */
  66539. direction: Vector2;
  66540. private blockCompilation;
  66541. protected _kernel: number;
  66542. protected _idealKernel: number;
  66543. protected _packedFloat: boolean;
  66544. private _staticDefines;
  66545. /**
  66546. * Sets the length in pixels of the blur sample region
  66547. */
  66548. /**
  66549. * Gets the length in pixels of the blur sample region
  66550. */
  66551. kernel: number;
  66552. /**
  66553. * Sets wether or not the blur needs to unpack/repack floats
  66554. */
  66555. /**
  66556. * Gets wether or not the blur is unpacking/repacking floats
  66557. */
  66558. packedFloat: boolean;
  66559. /**
  66560. * Creates a new instance BlurPostProcess
  66561. * @param name The name of the effect.
  66562. * @param direction The direction in which to blur the image.
  66563. * @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.
  66564. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  66565. * @param camera The camera to apply the render pass to.
  66566. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66567. * @param engine The engine which the post process will be applied. (default: current engine)
  66568. * @param reusable If the post process can be reused on the same frame. (default: false)
  66569. * @param textureType Type of textures used when performing the post process. (default: 0)
  66570. * @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)
  66571. */
  66572. constructor(name: string,
  66573. /** The direction in which to blur the image. */
  66574. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  66575. /**
  66576. * Updates the effect with the current post process compile time values and recompiles the shader.
  66577. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66578. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66579. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66580. * @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
  66581. * @param onCompiled Called when the shader has been compiled.
  66582. * @param onError Called if there is an error when compiling a shader.
  66583. */
  66584. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66585. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66586. /**
  66587. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  66588. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  66589. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  66590. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  66591. * The gaps between physical kernels are compensated for in the weighting of the samples
  66592. * @param idealKernel Ideal blur kernel.
  66593. * @return Nearest best kernel.
  66594. */
  66595. protected _nearestBestKernel(idealKernel: number): number;
  66596. /**
  66597. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  66598. * @param x The point on the Gaussian distribution to sample.
  66599. * @return the value of the Gaussian function at x.
  66600. */
  66601. protected _gaussianWeight(x: number): number;
  66602. /**
  66603. * Generates a string that can be used as a floating point number in GLSL.
  66604. * @param x Value to print.
  66605. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  66606. * @return GLSL float string.
  66607. */
  66608. protected _glslFloat(x: number, decimalFigures?: number): string;
  66609. }
  66610. }
  66611. declare module BABYLON {
  66612. /** @hidden */
  66613. export var shadowMapPixelShader: {
  66614. name: string;
  66615. shader: string;
  66616. };
  66617. }
  66618. declare module BABYLON {
  66619. /** @hidden */
  66620. export var bonesDeclaration: {
  66621. name: string;
  66622. shader: string;
  66623. };
  66624. }
  66625. declare module BABYLON {
  66626. /** @hidden */
  66627. export var morphTargetsVertexGlobalDeclaration: {
  66628. name: string;
  66629. shader: string;
  66630. };
  66631. }
  66632. declare module BABYLON {
  66633. /** @hidden */
  66634. export var morphTargetsVertexDeclaration: {
  66635. name: string;
  66636. shader: string;
  66637. };
  66638. }
  66639. declare module BABYLON {
  66640. /** @hidden */
  66641. export var instancesDeclaration: {
  66642. name: string;
  66643. shader: string;
  66644. };
  66645. }
  66646. declare module BABYLON {
  66647. /** @hidden */
  66648. export var helperFunctions: {
  66649. name: string;
  66650. shader: string;
  66651. };
  66652. }
  66653. declare module BABYLON {
  66654. /** @hidden */
  66655. export var morphTargetsVertex: {
  66656. name: string;
  66657. shader: string;
  66658. };
  66659. }
  66660. declare module BABYLON {
  66661. /** @hidden */
  66662. export var instancesVertex: {
  66663. name: string;
  66664. shader: string;
  66665. };
  66666. }
  66667. declare module BABYLON {
  66668. /** @hidden */
  66669. export var bonesVertex: {
  66670. name: string;
  66671. shader: string;
  66672. };
  66673. }
  66674. declare module BABYLON {
  66675. /** @hidden */
  66676. export var shadowMapVertexShader: {
  66677. name: string;
  66678. shader: string;
  66679. };
  66680. }
  66681. declare module BABYLON {
  66682. /** @hidden */
  66683. export var depthBoxBlurPixelShader: {
  66684. name: string;
  66685. shader: string;
  66686. };
  66687. }
  66688. declare module BABYLON {
  66689. /**
  66690. * Defines the options associated with the creation of a custom shader for a shadow generator.
  66691. */
  66692. export interface ICustomShaderOptions {
  66693. /**
  66694. * Gets or sets the custom shader name to use
  66695. */
  66696. shaderName: string;
  66697. /**
  66698. * The list of attribute names used in the shader
  66699. */
  66700. attributes?: string[];
  66701. /**
  66702. * The list of unifrom names used in the shader
  66703. */
  66704. uniforms?: string[];
  66705. /**
  66706. * The list of sampler names used in the shader
  66707. */
  66708. samplers?: string[];
  66709. /**
  66710. * The list of defines used in the shader
  66711. */
  66712. defines?: string[];
  66713. }
  66714. /**
  66715. * Interface to implement to create a shadow generator compatible with BJS.
  66716. */
  66717. export interface IShadowGenerator {
  66718. /**
  66719. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  66720. * @returns The render target texture if present otherwise, null
  66721. */
  66722. getShadowMap(): Nullable<RenderTargetTexture>;
  66723. /**
  66724. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  66725. * @returns The render target texture if the shadow map is present otherwise, null
  66726. */
  66727. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  66728. /**
  66729. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  66730. * @param subMesh The submesh we want to render in the shadow map
  66731. * @param useInstances Defines wether will draw in the map using instances
  66732. * @returns true if ready otherwise, false
  66733. */
  66734. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66735. /**
  66736. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  66737. * @param defines Defines of the material we want to update
  66738. * @param lightIndex Index of the light in the enabled light list of the material
  66739. */
  66740. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  66741. /**
  66742. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  66743. * defined in the generator but impacting the effect).
  66744. * It implies the unifroms available on the materials are the standard BJS ones.
  66745. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  66746. * @param effect The effect we are binfing the information for
  66747. */
  66748. bindShadowLight(lightIndex: string, effect: Effect): void;
  66749. /**
  66750. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  66751. * (eq to shadow prjection matrix * light transform matrix)
  66752. * @returns The transform matrix used to create the shadow map
  66753. */
  66754. getTransformMatrix(): Matrix;
  66755. /**
  66756. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  66757. * Cube and 2D textures for instance.
  66758. */
  66759. recreateShadowMap(): void;
  66760. /**
  66761. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66762. * @param onCompiled Callback triggered at the and of the effects compilation
  66763. * @param options Sets of optional options forcing the compilation with different modes
  66764. */
  66765. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  66766. useInstances: boolean;
  66767. }>): void;
  66768. /**
  66769. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66770. * @param options Sets of optional options forcing the compilation with different modes
  66771. * @returns A promise that resolves when the compilation completes
  66772. */
  66773. forceCompilationAsync(options?: Partial<{
  66774. useInstances: boolean;
  66775. }>): Promise<void>;
  66776. /**
  66777. * Serializes the shadow generator setup to a json object.
  66778. * @returns The serialized JSON object
  66779. */
  66780. serialize(): any;
  66781. /**
  66782. * Disposes the Shadow map and related Textures and effects.
  66783. */
  66784. dispose(): void;
  66785. }
  66786. /**
  66787. * Default implementation IShadowGenerator.
  66788. * This is the main object responsible of generating shadows in the framework.
  66789. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  66790. */
  66791. export class ShadowGenerator implements IShadowGenerator {
  66792. /**
  66793. * Shadow generator mode None: no filtering applied.
  66794. */
  66795. static readonly FILTER_NONE: number;
  66796. /**
  66797. * Shadow generator mode ESM: Exponential Shadow Mapping.
  66798. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66799. */
  66800. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  66801. /**
  66802. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  66803. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  66804. */
  66805. static readonly FILTER_POISSONSAMPLING: number;
  66806. /**
  66807. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  66808. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66809. */
  66810. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  66811. /**
  66812. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  66813. * edge artifacts on steep falloff.
  66814. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66815. */
  66816. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  66817. /**
  66818. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  66819. * edge artifacts on steep falloff.
  66820. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66821. */
  66822. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  66823. /**
  66824. * Shadow generator mode PCF: Percentage Closer Filtering
  66825. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66826. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  66827. */
  66828. static readonly FILTER_PCF: number;
  66829. /**
  66830. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  66831. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66832. * Contact Hardening
  66833. */
  66834. static readonly FILTER_PCSS: number;
  66835. /**
  66836. * Reserved for PCF and PCSS
  66837. * Highest Quality.
  66838. *
  66839. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  66840. *
  66841. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  66842. */
  66843. static readonly QUALITY_HIGH: number;
  66844. /**
  66845. * Reserved for PCF and PCSS
  66846. * Good tradeoff for quality/perf cross devices
  66847. *
  66848. * Execute PCF on a 3*3 kernel.
  66849. *
  66850. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  66851. */
  66852. static readonly QUALITY_MEDIUM: number;
  66853. /**
  66854. * Reserved for PCF and PCSS
  66855. * The lowest quality but the fastest.
  66856. *
  66857. * Execute PCF on a 1*1 kernel.
  66858. *
  66859. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  66860. */
  66861. static readonly QUALITY_LOW: number;
  66862. /** Gets or sets the custom shader name to use */
  66863. customShaderOptions: ICustomShaderOptions;
  66864. /**
  66865. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  66866. */
  66867. onBeforeShadowMapRenderObservable: Observable<Effect>;
  66868. private _bias;
  66869. /**
  66870. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  66871. */
  66872. /**
  66873. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  66874. */
  66875. bias: number;
  66876. private _normalBias;
  66877. /**
  66878. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66879. */
  66880. /**
  66881. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66882. */
  66883. normalBias: number;
  66884. private _blurBoxOffset;
  66885. /**
  66886. * Gets the blur box offset: offset applied during the blur pass.
  66887. * Only useful if useKernelBlur = false
  66888. */
  66889. /**
  66890. * Sets the blur box offset: offset applied during the blur pass.
  66891. * Only useful if useKernelBlur = false
  66892. */
  66893. blurBoxOffset: number;
  66894. private _blurScale;
  66895. /**
  66896. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  66897. * 2 means half of the size.
  66898. */
  66899. /**
  66900. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  66901. * 2 means half of the size.
  66902. */
  66903. blurScale: number;
  66904. private _blurKernel;
  66905. /**
  66906. * Gets the blur kernel: kernel size of the blur pass.
  66907. * Only useful if useKernelBlur = true
  66908. */
  66909. /**
  66910. * Sets the blur kernel: kernel size of the blur pass.
  66911. * Only useful if useKernelBlur = true
  66912. */
  66913. blurKernel: number;
  66914. private _useKernelBlur;
  66915. /**
  66916. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  66917. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  66918. */
  66919. /**
  66920. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  66921. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  66922. */
  66923. useKernelBlur: boolean;
  66924. private _depthScale;
  66925. /**
  66926. * Gets the depth scale used in ESM mode.
  66927. */
  66928. /**
  66929. * Sets the depth scale used in ESM mode.
  66930. * This can override the scale stored on the light.
  66931. */
  66932. depthScale: number;
  66933. private _filter;
  66934. /**
  66935. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  66936. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  66937. */
  66938. /**
  66939. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  66940. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  66941. */
  66942. filter: number;
  66943. /**
  66944. * Gets if the current filter is set to Poisson Sampling.
  66945. */
  66946. /**
  66947. * Sets the current filter to Poisson Sampling.
  66948. */
  66949. usePoissonSampling: boolean;
  66950. /**
  66951. * Gets if the current filter is set to ESM.
  66952. */
  66953. /**
  66954. * Sets the current filter is to ESM.
  66955. */
  66956. useExponentialShadowMap: boolean;
  66957. /**
  66958. * Gets if the current filter is set to filtered ESM.
  66959. */
  66960. /**
  66961. * Gets if the current filter is set to filtered ESM.
  66962. */
  66963. useBlurExponentialShadowMap: boolean;
  66964. /**
  66965. * Gets if the current filter is set to "close ESM" (using the inverse of the
  66966. * exponential to prevent steep falloff artifacts).
  66967. */
  66968. /**
  66969. * Sets the current filter to "close ESM" (using the inverse of the
  66970. * exponential to prevent steep falloff artifacts).
  66971. */
  66972. useCloseExponentialShadowMap: boolean;
  66973. /**
  66974. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  66975. * exponential to prevent steep falloff artifacts).
  66976. */
  66977. /**
  66978. * Sets the current filter to filtered "close ESM" (using the inverse of the
  66979. * exponential to prevent steep falloff artifacts).
  66980. */
  66981. useBlurCloseExponentialShadowMap: boolean;
  66982. /**
  66983. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  66984. */
  66985. /**
  66986. * Sets the current filter to "PCF" (percentage closer filtering).
  66987. */
  66988. usePercentageCloserFiltering: boolean;
  66989. private _filteringQuality;
  66990. /**
  66991. * Gets the PCF or PCSS Quality.
  66992. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  66993. */
  66994. /**
  66995. * Sets the PCF or PCSS Quality.
  66996. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  66997. */
  66998. filteringQuality: number;
  66999. /**
  67000. * Gets if the current filter is set to "PCSS" (contact hardening).
  67001. */
  67002. /**
  67003. * Sets the current filter to "PCSS" (contact hardening).
  67004. */
  67005. useContactHardeningShadow: boolean;
  67006. private _contactHardeningLightSizeUVRatio;
  67007. /**
  67008. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67009. * Using a ratio helps keeping shape stability independently of the map size.
  67010. *
  67011. * It does not account for the light projection as it was having too much
  67012. * instability during the light setup or during light position changes.
  67013. *
  67014. * Only valid if useContactHardeningShadow is true.
  67015. */
  67016. /**
  67017. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67018. * Using a ratio helps keeping shape stability independently of the map size.
  67019. *
  67020. * It does not account for the light projection as it was having too much
  67021. * instability during the light setup or during light position changes.
  67022. *
  67023. * Only valid if useContactHardeningShadow is true.
  67024. */
  67025. contactHardeningLightSizeUVRatio: number;
  67026. private _darkness;
  67027. /**
  67028. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  67029. * 0 means strongest and 1 would means no shadow.
  67030. * @returns the darkness.
  67031. */
  67032. getDarkness(): number;
  67033. /**
  67034. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  67035. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  67036. * @returns the shadow generator allowing fluent coding.
  67037. */
  67038. setDarkness(darkness: number): ShadowGenerator;
  67039. private _transparencyShadow;
  67040. /**
  67041. * Sets the ability to have transparent shadow (boolean).
  67042. * @param transparent True if transparent else False
  67043. * @returns the shadow generator allowing fluent coding
  67044. */
  67045. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  67046. private _shadowMap;
  67047. private _shadowMap2;
  67048. /**
  67049. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67050. * @returns The render target texture if present otherwise, null
  67051. */
  67052. getShadowMap(): Nullable<RenderTargetTexture>;
  67053. /**
  67054. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67055. * @returns The render target texture if the shadow map is present otherwise, null
  67056. */
  67057. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67058. /**
  67059. * Helper function to add a mesh and its descendants to the list of shadow casters.
  67060. * @param mesh Mesh to add
  67061. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  67062. * @returns the Shadow Generator itself
  67063. */
  67064. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67065. /**
  67066. * Helper function to remove a mesh and its descendants from the list of shadow casters
  67067. * @param mesh Mesh to remove
  67068. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  67069. * @returns the Shadow Generator itself
  67070. */
  67071. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67072. /**
  67073. * Controls the extent to which the shadows fade out at the edge of the frustum
  67074. * Used only by directionals and spots
  67075. */
  67076. frustumEdgeFalloff: number;
  67077. private _light;
  67078. /**
  67079. * Returns the associated light object.
  67080. * @returns the light generating the shadow
  67081. */
  67082. getLight(): IShadowLight;
  67083. /**
  67084. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  67085. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  67086. * It might on the other hand introduce peter panning.
  67087. */
  67088. forceBackFacesOnly: boolean;
  67089. private _scene;
  67090. private _lightDirection;
  67091. private _effect;
  67092. private _viewMatrix;
  67093. private _projectionMatrix;
  67094. private _transformMatrix;
  67095. private _cachedPosition;
  67096. private _cachedDirection;
  67097. private _cachedDefines;
  67098. private _currentRenderID;
  67099. private _boxBlurPostprocess;
  67100. private _kernelBlurXPostprocess;
  67101. private _kernelBlurYPostprocess;
  67102. private _blurPostProcesses;
  67103. private _mapSize;
  67104. private _currentFaceIndex;
  67105. private _currentFaceIndexCache;
  67106. private _textureType;
  67107. private _defaultTextureMatrix;
  67108. /** @hidden */
  67109. static _SceneComponentInitialization: (scene: Scene) => void;
  67110. /**
  67111. * Creates a ShadowGenerator object.
  67112. * A ShadowGenerator is the required tool to use the shadows.
  67113. * Each light casting shadows needs to use its own ShadowGenerator.
  67114. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  67115. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67116. * @param light The light object generating the shadows.
  67117. * @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.
  67118. */
  67119. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  67120. private _initializeGenerator;
  67121. private _initializeShadowMap;
  67122. private _initializeBlurRTTAndPostProcesses;
  67123. private _renderForShadowMap;
  67124. private _renderSubMeshForShadowMap;
  67125. private _applyFilterValues;
  67126. /**
  67127. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67128. * @param onCompiled Callback triggered at the and of the effects compilation
  67129. * @param options Sets of optional options forcing the compilation with different modes
  67130. */
  67131. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67132. useInstances: boolean;
  67133. }>): void;
  67134. /**
  67135. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67136. * @param options Sets of optional options forcing the compilation with different modes
  67137. * @returns A promise that resolves when the compilation completes
  67138. */
  67139. forceCompilationAsync(options?: Partial<{
  67140. useInstances: boolean;
  67141. }>): Promise<void>;
  67142. /**
  67143. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67144. * @param subMesh The submesh we want to render in the shadow map
  67145. * @param useInstances Defines wether will draw in the map using instances
  67146. * @returns true if ready otherwise, false
  67147. */
  67148. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67149. /**
  67150. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67151. * @param defines Defines of the material we want to update
  67152. * @param lightIndex Index of the light in the enabled light list of the material
  67153. */
  67154. prepareDefines(defines: any, lightIndex: number): void;
  67155. /**
  67156. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67157. * defined in the generator but impacting the effect).
  67158. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67159. * @param effect The effect we are binfing the information for
  67160. */
  67161. bindShadowLight(lightIndex: string, effect: Effect): void;
  67162. /**
  67163. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67164. * (eq to shadow prjection matrix * light transform matrix)
  67165. * @returns The transform matrix used to create the shadow map
  67166. */
  67167. getTransformMatrix(): Matrix;
  67168. /**
  67169. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67170. * Cube and 2D textures for instance.
  67171. */
  67172. recreateShadowMap(): void;
  67173. private _disposeBlurPostProcesses;
  67174. private _disposeRTTandPostProcesses;
  67175. /**
  67176. * Disposes the ShadowGenerator.
  67177. * Returns nothing.
  67178. */
  67179. dispose(): void;
  67180. /**
  67181. * Serializes the shadow generator setup to a json object.
  67182. * @returns The serialized JSON object
  67183. */
  67184. serialize(): any;
  67185. /**
  67186. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67187. * @param parsedShadowGenerator The JSON object to parse
  67188. * @param scene The scene to create the shadow map for
  67189. * @returns The parsed shadow generator
  67190. */
  67191. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67192. }
  67193. }
  67194. declare module BABYLON {
  67195. /**
  67196. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  67197. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  67198. * 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.
  67199. */
  67200. export abstract class Light extends Node {
  67201. /**
  67202. * Falloff Default: light is falling off following the material specification:
  67203. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  67204. */
  67205. static readonly FALLOFF_DEFAULT: number;
  67206. /**
  67207. * Falloff Physical: light is falling off following the inverse squared distance law.
  67208. */
  67209. static readonly FALLOFF_PHYSICAL: number;
  67210. /**
  67211. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  67212. * to enhance interoperability with other engines.
  67213. */
  67214. static readonly FALLOFF_GLTF: number;
  67215. /**
  67216. * Falloff Standard: light is falling off like in the standard material
  67217. * to enhance interoperability with other materials.
  67218. */
  67219. static readonly FALLOFF_STANDARD: number;
  67220. /**
  67221. * If every light affecting the material is in this lightmapMode,
  67222. * material.lightmapTexture adds or multiplies
  67223. * (depends on material.useLightmapAsShadowmap)
  67224. * after every other light calculations.
  67225. */
  67226. static readonly LIGHTMAP_DEFAULT: number;
  67227. /**
  67228. * material.lightmapTexture as only diffuse lighting from this light
  67229. * adds only specular lighting from this light
  67230. * adds dynamic shadows
  67231. */
  67232. static readonly LIGHTMAP_SPECULAR: number;
  67233. /**
  67234. * material.lightmapTexture as only lighting
  67235. * no light calculation from this light
  67236. * only adds dynamic shadows from this light
  67237. */
  67238. static readonly LIGHTMAP_SHADOWSONLY: number;
  67239. /**
  67240. * Each light type uses the default quantity according to its type:
  67241. * point/spot lights use luminous intensity
  67242. * directional lights use illuminance
  67243. */
  67244. static readonly INTENSITYMODE_AUTOMATIC: number;
  67245. /**
  67246. * lumen (lm)
  67247. */
  67248. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  67249. /**
  67250. * candela (lm/sr)
  67251. */
  67252. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  67253. /**
  67254. * lux (lm/m^2)
  67255. */
  67256. static readonly INTENSITYMODE_ILLUMINANCE: number;
  67257. /**
  67258. * nit (cd/m^2)
  67259. */
  67260. static readonly INTENSITYMODE_LUMINANCE: number;
  67261. /**
  67262. * Light type const id of the point light.
  67263. */
  67264. static readonly LIGHTTYPEID_POINTLIGHT: number;
  67265. /**
  67266. * Light type const id of the directional light.
  67267. */
  67268. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  67269. /**
  67270. * Light type const id of the spot light.
  67271. */
  67272. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  67273. /**
  67274. * Light type const id of the hemispheric light.
  67275. */
  67276. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  67277. /**
  67278. * Diffuse gives the basic color to an object.
  67279. */
  67280. diffuse: Color3;
  67281. /**
  67282. * Specular produces a highlight color on an object.
  67283. * Note: This is note affecting PBR materials.
  67284. */
  67285. specular: Color3;
  67286. /**
  67287. * Defines the falloff type for this light. This lets overrriding how punctual light are
  67288. * falling off base on range or angle.
  67289. * This can be set to any values in Light.FALLOFF_x.
  67290. *
  67291. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  67292. * other types of materials.
  67293. */
  67294. falloffType: number;
  67295. /**
  67296. * Strength of the light.
  67297. * Note: By default it is define in the framework own unit.
  67298. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  67299. */
  67300. intensity: number;
  67301. private _range;
  67302. protected _inverseSquaredRange: number;
  67303. /**
  67304. * Defines how far from the source the light is impacting in scene units.
  67305. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67306. */
  67307. /**
  67308. * Defines how far from the source the light is impacting in scene units.
  67309. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67310. */
  67311. range: number;
  67312. /**
  67313. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  67314. * of light.
  67315. */
  67316. private _photometricScale;
  67317. private _intensityMode;
  67318. /**
  67319. * Gets the photometric scale used to interpret the intensity.
  67320. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67321. */
  67322. /**
  67323. * Sets the photometric scale used to interpret the intensity.
  67324. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67325. */
  67326. intensityMode: number;
  67327. private _radius;
  67328. /**
  67329. * Gets the light radius used by PBR Materials to simulate soft area lights.
  67330. */
  67331. /**
  67332. * sets the light radius used by PBR Materials to simulate soft area lights.
  67333. */
  67334. radius: number;
  67335. private _renderPriority;
  67336. /**
  67337. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  67338. * exceeding the number allowed of the materials.
  67339. */
  67340. renderPriority: number;
  67341. private _shadowEnabled;
  67342. /**
  67343. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67344. * the current shadow generator.
  67345. */
  67346. /**
  67347. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67348. * the current shadow generator.
  67349. */
  67350. shadowEnabled: boolean;
  67351. private _includedOnlyMeshes;
  67352. /**
  67353. * Gets the only meshes impacted by this light.
  67354. */
  67355. /**
  67356. * Sets the only meshes impacted by this light.
  67357. */
  67358. includedOnlyMeshes: AbstractMesh[];
  67359. private _excludedMeshes;
  67360. /**
  67361. * Gets the meshes not impacted by this light.
  67362. */
  67363. /**
  67364. * Sets the meshes not impacted by this light.
  67365. */
  67366. excludedMeshes: AbstractMesh[];
  67367. private _excludeWithLayerMask;
  67368. /**
  67369. * Gets the layer id use to find what meshes are not impacted by the light.
  67370. * Inactive if 0
  67371. */
  67372. /**
  67373. * Sets the layer id use to find what meshes are not impacted by the light.
  67374. * Inactive if 0
  67375. */
  67376. excludeWithLayerMask: number;
  67377. private _includeOnlyWithLayerMask;
  67378. /**
  67379. * Gets the layer id use to find what meshes are impacted by the light.
  67380. * Inactive if 0
  67381. */
  67382. /**
  67383. * Sets the layer id use to find what meshes are impacted by the light.
  67384. * Inactive if 0
  67385. */
  67386. includeOnlyWithLayerMask: number;
  67387. private _lightmapMode;
  67388. /**
  67389. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67390. */
  67391. /**
  67392. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67393. */
  67394. lightmapMode: number;
  67395. /**
  67396. * Shadow generator associted to the light.
  67397. * @hidden Internal use only.
  67398. */
  67399. _shadowGenerator: Nullable<IShadowGenerator>;
  67400. /**
  67401. * @hidden Internal use only.
  67402. */
  67403. _excludedMeshesIds: string[];
  67404. /**
  67405. * @hidden Internal use only.
  67406. */
  67407. _includedOnlyMeshesIds: string[];
  67408. /**
  67409. * The current light unifom buffer.
  67410. * @hidden Internal use only.
  67411. */
  67412. _uniformBuffer: UniformBuffer;
  67413. /**
  67414. * Creates a Light object in the scene.
  67415. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67416. * @param name The firendly name of the light
  67417. * @param scene The scene the light belongs too
  67418. */
  67419. constructor(name: string, scene: Scene);
  67420. protected abstract _buildUniformLayout(): void;
  67421. /**
  67422. * Sets the passed Effect "effect" with the Light information.
  67423. * @param effect The effect to update
  67424. * @param lightIndex The index of the light in the effect to update
  67425. * @returns The light
  67426. */
  67427. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  67428. /**
  67429. * Returns the string "Light".
  67430. * @returns the class name
  67431. */
  67432. getClassName(): string;
  67433. /** @hidden */
  67434. readonly _isLight: boolean;
  67435. /**
  67436. * Converts the light information to a readable string for debug purpose.
  67437. * @param fullDetails Supports for multiple levels of logging within scene loading
  67438. * @returns the human readable light info
  67439. */
  67440. toString(fullDetails?: boolean): string;
  67441. /** @hidden */
  67442. protected _syncParentEnabledState(): void;
  67443. /**
  67444. * Set the enabled state of this node.
  67445. * @param value - the new enabled state
  67446. */
  67447. setEnabled(value: boolean): void;
  67448. /**
  67449. * Returns the Light associated shadow generator if any.
  67450. * @return the associated shadow generator.
  67451. */
  67452. getShadowGenerator(): Nullable<IShadowGenerator>;
  67453. /**
  67454. * Returns a Vector3, the absolute light position in the World.
  67455. * @returns the world space position of the light
  67456. */
  67457. getAbsolutePosition(): Vector3;
  67458. /**
  67459. * Specifies if the light will affect the passed mesh.
  67460. * @param mesh The mesh to test against the light
  67461. * @return true the mesh is affected otherwise, false.
  67462. */
  67463. canAffectMesh(mesh: AbstractMesh): boolean;
  67464. /**
  67465. * Sort function to order lights for rendering.
  67466. * @param a First Light object to compare to second.
  67467. * @param b Second Light object to compare first.
  67468. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  67469. */
  67470. static CompareLightsPriority(a: Light, b: Light): number;
  67471. /**
  67472. * Releases resources associated with this node.
  67473. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67474. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67475. */
  67476. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67477. /**
  67478. * Returns the light type ID (integer).
  67479. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67480. */
  67481. getTypeID(): number;
  67482. /**
  67483. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  67484. * @returns the scaled intensity in intensity mode unit
  67485. */
  67486. getScaledIntensity(): number;
  67487. /**
  67488. * Returns a new Light object, named "name", from the current one.
  67489. * @param name The name of the cloned light
  67490. * @returns the new created light
  67491. */
  67492. clone(name: string): Nullable<Light>;
  67493. /**
  67494. * Serializes the current light into a Serialization object.
  67495. * @returns the serialized object.
  67496. */
  67497. serialize(): any;
  67498. /**
  67499. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  67500. * This new light is named "name" and added to the passed scene.
  67501. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  67502. * @param name The friendly name of the light
  67503. * @param scene The scene the new light will belong to
  67504. * @returns the constructor function
  67505. */
  67506. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  67507. /**
  67508. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  67509. * @param parsedLight The JSON representation of the light
  67510. * @param scene The scene to create the parsed light in
  67511. * @returns the created light after parsing
  67512. */
  67513. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  67514. private _hookArrayForExcluded;
  67515. private _hookArrayForIncludedOnly;
  67516. private _resyncMeshes;
  67517. /**
  67518. * Forces the meshes to update their light related information in their rendering used effects
  67519. * @hidden Internal Use Only
  67520. */
  67521. _markMeshesAsLightDirty(): void;
  67522. /**
  67523. * Recomputes the cached photometric scale if needed.
  67524. */
  67525. private _computePhotometricScale;
  67526. /**
  67527. * Returns the Photometric Scale according to the light type and intensity mode.
  67528. */
  67529. private _getPhotometricScale;
  67530. /**
  67531. * Reorder the light in the scene according to their defined priority.
  67532. * @hidden Internal Use Only
  67533. */
  67534. _reorderLightsInScene(): void;
  67535. /**
  67536. * Prepares the list of defines specific to the light type.
  67537. * @param defines the list of defines
  67538. * @param lightIndex defines the index of the light for the effect
  67539. */
  67540. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67541. }
  67542. }
  67543. declare module BABYLON {
  67544. /**
  67545. * Interface used to define Action
  67546. */
  67547. export interface IAction {
  67548. /**
  67549. * Trigger for the action
  67550. */
  67551. trigger: number;
  67552. /** Options of the trigger */
  67553. triggerOptions: any;
  67554. /**
  67555. * Gets the trigger parameters
  67556. * @returns the trigger parameters
  67557. */
  67558. getTriggerParameter(): any;
  67559. /**
  67560. * Internal only - executes current action event
  67561. * @hidden
  67562. */
  67563. _executeCurrent(evt?: ActionEvent): void;
  67564. /**
  67565. * Serialize placeholder for child classes
  67566. * @param parent of child
  67567. * @returns the serialized object
  67568. */
  67569. serialize(parent: any): any;
  67570. }
  67571. /**
  67572. * The action to be carried out following a trigger
  67573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  67574. */
  67575. export class Action implements IAction {
  67576. /** the trigger, with or without parameters, for the action */
  67577. triggerOptions: any;
  67578. /**
  67579. * Trigger for the action
  67580. */
  67581. trigger: number;
  67582. /**
  67583. * Internal only - manager for action
  67584. * @hidden
  67585. */
  67586. _actionManager: ActionManager;
  67587. private _nextActiveAction;
  67588. private _child;
  67589. private _condition?;
  67590. private _triggerParameter;
  67591. /**
  67592. * An event triggered prior to action being executed.
  67593. */
  67594. onBeforeExecuteObservable: Observable<Action>;
  67595. /**
  67596. * Creates a new Action
  67597. * @param triggerOptions the trigger, with or without parameters, for the action
  67598. * @param condition an optional determinant of action
  67599. */
  67600. constructor(
  67601. /** the trigger, with or without parameters, for the action */
  67602. triggerOptions: any, condition?: Condition);
  67603. /**
  67604. * Internal only
  67605. * @hidden
  67606. */
  67607. _prepare(): void;
  67608. /**
  67609. * Gets the trigger parameters
  67610. * @returns the trigger parameters
  67611. */
  67612. getTriggerParameter(): any;
  67613. /**
  67614. * Internal only - executes current action event
  67615. * @hidden
  67616. */
  67617. _executeCurrent(evt?: ActionEvent): void;
  67618. /**
  67619. * Execute placeholder for child classes
  67620. * @param evt optional action event
  67621. */
  67622. execute(evt?: ActionEvent): void;
  67623. /**
  67624. * Skips to next active action
  67625. */
  67626. skipToNextActiveAction(): void;
  67627. /**
  67628. * Adds action to chain of actions, may be a DoNothingAction
  67629. * @param action defines the next action to execute
  67630. * @returns The action passed in
  67631. * @see https://www.babylonjs-playground.com/#1T30HR#0
  67632. */
  67633. then(action: Action): Action;
  67634. /**
  67635. * Internal only
  67636. * @hidden
  67637. */
  67638. _getProperty(propertyPath: string): string;
  67639. /**
  67640. * Internal only
  67641. * @hidden
  67642. */
  67643. _getEffectiveTarget(target: any, propertyPath: string): any;
  67644. /**
  67645. * Serialize placeholder for child classes
  67646. * @param parent of child
  67647. * @returns the serialized object
  67648. */
  67649. serialize(parent: any): any;
  67650. /**
  67651. * Internal only called by serialize
  67652. * @hidden
  67653. */
  67654. protected _serialize(serializedAction: any, parent?: any): any;
  67655. /**
  67656. * Internal only
  67657. * @hidden
  67658. */
  67659. static _SerializeValueAsString: (value: any) => string;
  67660. /**
  67661. * Internal only
  67662. * @hidden
  67663. */
  67664. static _GetTargetProperty: (target: Scene | Node) => {
  67665. name: string;
  67666. targetType: string;
  67667. value: string;
  67668. };
  67669. }
  67670. }
  67671. declare module BABYLON {
  67672. /**
  67673. * A Condition applied to an Action
  67674. */
  67675. export class Condition {
  67676. /**
  67677. * Internal only - manager for action
  67678. * @hidden
  67679. */
  67680. _actionManager: ActionManager;
  67681. /**
  67682. * Internal only
  67683. * @hidden
  67684. */
  67685. _evaluationId: number;
  67686. /**
  67687. * Internal only
  67688. * @hidden
  67689. */
  67690. _currentResult: boolean;
  67691. /**
  67692. * Creates a new Condition
  67693. * @param actionManager the manager of the action the condition is applied to
  67694. */
  67695. constructor(actionManager: ActionManager);
  67696. /**
  67697. * Check if the current condition is valid
  67698. * @returns a boolean
  67699. */
  67700. isValid(): boolean;
  67701. /**
  67702. * Internal only
  67703. * @hidden
  67704. */
  67705. _getProperty(propertyPath: string): string;
  67706. /**
  67707. * Internal only
  67708. * @hidden
  67709. */
  67710. _getEffectiveTarget(target: any, propertyPath: string): any;
  67711. /**
  67712. * Serialize placeholder for child classes
  67713. * @returns the serialized object
  67714. */
  67715. serialize(): any;
  67716. /**
  67717. * Internal only
  67718. * @hidden
  67719. */
  67720. protected _serialize(serializedCondition: any): any;
  67721. }
  67722. /**
  67723. * Defines specific conditional operators as extensions of Condition
  67724. */
  67725. export class ValueCondition extends Condition {
  67726. /** path to specify the property of the target the conditional operator uses */
  67727. propertyPath: string;
  67728. /** the value compared by the conditional operator against the current value of the property */
  67729. value: any;
  67730. /** the conditional operator, default ValueCondition.IsEqual */
  67731. operator: number;
  67732. /**
  67733. * Internal only
  67734. * @hidden
  67735. */
  67736. private static _IsEqual;
  67737. /**
  67738. * Internal only
  67739. * @hidden
  67740. */
  67741. private static _IsDifferent;
  67742. /**
  67743. * Internal only
  67744. * @hidden
  67745. */
  67746. private static _IsGreater;
  67747. /**
  67748. * Internal only
  67749. * @hidden
  67750. */
  67751. private static _IsLesser;
  67752. /**
  67753. * returns the number for IsEqual
  67754. */
  67755. static readonly IsEqual: number;
  67756. /**
  67757. * Returns the number for IsDifferent
  67758. */
  67759. static readonly IsDifferent: number;
  67760. /**
  67761. * Returns the number for IsGreater
  67762. */
  67763. static readonly IsGreater: number;
  67764. /**
  67765. * Returns the number for IsLesser
  67766. */
  67767. static readonly IsLesser: number;
  67768. /**
  67769. * Internal only The action manager for the condition
  67770. * @hidden
  67771. */
  67772. _actionManager: ActionManager;
  67773. /**
  67774. * Internal only
  67775. * @hidden
  67776. */
  67777. private _target;
  67778. /**
  67779. * Internal only
  67780. * @hidden
  67781. */
  67782. private _effectiveTarget;
  67783. /**
  67784. * Internal only
  67785. * @hidden
  67786. */
  67787. private _property;
  67788. /**
  67789. * Creates a new ValueCondition
  67790. * @param actionManager manager for the action the condition applies to
  67791. * @param target for the action
  67792. * @param propertyPath path to specify the property of the target the conditional operator uses
  67793. * @param value the value compared by the conditional operator against the current value of the property
  67794. * @param operator the conditional operator, default ValueCondition.IsEqual
  67795. */
  67796. constructor(actionManager: ActionManager, target: any,
  67797. /** path to specify the property of the target the conditional operator uses */
  67798. propertyPath: string,
  67799. /** the value compared by the conditional operator against the current value of the property */
  67800. value: any,
  67801. /** the conditional operator, default ValueCondition.IsEqual */
  67802. operator?: number);
  67803. /**
  67804. * Compares the given value with the property value for the specified conditional operator
  67805. * @returns the result of the comparison
  67806. */
  67807. isValid(): boolean;
  67808. /**
  67809. * Serialize the ValueCondition into a JSON compatible object
  67810. * @returns serialization object
  67811. */
  67812. serialize(): any;
  67813. /**
  67814. * Gets the name of the conditional operator for the ValueCondition
  67815. * @param operator the conditional operator
  67816. * @returns the name
  67817. */
  67818. static GetOperatorName(operator: number): string;
  67819. }
  67820. /**
  67821. * Defines a predicate condition as an extension of Condition
  67822. */
  67823. export class PredicateCondition extends Condition {
  67824. /** defines the predicate function used to validate the condition */
  67825. predicate: () => boolean;
  67826. /**
  67827. * Internal only - manager for action
  67828. * @hidden
  67829. */
  67830. _actionManager: ActionManager;
  67831. /**
  67832. * Creates a new PredicateCondition
  67833. * @param actionManager manager for the action the condition applies to
  67834. * @param predicate defines the predicate function used to validate the condition
  67835. */
  67836. constructor(actionManager: ActionManager,
  67837. /** defines the predicate function used to validate the condition */
  67838. predicate: () => boolean);
  67839. /**
  67840. * @returns the validity of the predicate condition
  67841. */
  67842. isValid(): boolean;
  67843. }
  67844. /**
  67845. * Defines a state condition as an extension of Condition
  67846. */
  67847. export class StateCondition extends Condition {
  67848. /** Value to compare with target state */
  67849. value: string;
  67850. /**
  67851. * Internal only - manager for action
  67852. * @hidden
  67853. */
  67854. _actionManager: ActionManager;
  67855. /**
  67856. * Internal only
  67857. * @hidden
  67858. */
  67859. private _target;
  67860. /**
  67861. * Creates a new StateCondition
  67862. * @param actionManager manager for the action the condition applies to
  67863. * @param target of the condition
  67864. * @param value to compare with target state
  67865. */
  67866. constructor(actionManager: ActionManager, target: any,
  67867. /** Value to compare with target state */
  67868. value: string);
  67869. /**
  67870. * Gets a boolean indicating if the current condition is met
  67871. * @returns the validity of the state
  67872. */
  67873. isValid(): boolean;
  67874. /**
  67875. * Serialize the StateCondition into a JSON compatible object
  67876. * @returns serialization object
  67877. */
  67878. serialize(): any;
  67879. }
  67880. }
  67881. declare module BABYLON {
  67882. /**
  67883. * This defines an action responsible to toggle a boolean once triggered.
  67884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67885. */
  67886. export class SwitchBooleanAction extends Action {
  67887. /**
  67888. * The path to the boolean property in the target object
  67889. */
  67890. propertyPath: string;
  67891. private _target;
  67892. private _effectiveTarget;
  67893. private _property;
  67894. /**
  67895. * Instantiate the action
  67896. * @param triggerOptions defines the trigger options
  67897. * @param target defines the object containing the boolean
  67898. * @param propertyPath defines the path to the boolean property in the target object
  67899. * @param condition defines the trigger related conditions
  67900. */
  67901. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  67902. /** @hidden */
  67903. _prepare(): void;
  67904. /**
  67905. * Execute the action toggle the boolean value.
  67906. */
  67907. execute(): void;
  67908. /**
  67909. * Serializes the actions and its related information.
  67910. * @param parent defines the object to serialize in
  67911. * @returns the serialized object
  67912. */
  67913. serialize(parent: any): any;
  67914. }
  67915. /**
  67916. * This defines an action responsible to set a the state field of the target
  67917. * to a desired value once triggered.
  67918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67919. */
  67920. export class SetStateAction extends Action {
  67921. /**
  67922. * The value to store in the state field.
  67923. */
  67924. value: string;
  67925. private _target;
  67926. /**
  67927. * Instantiate the action
  67928. * @param triggerOptions defines the trigger options
  67929. * @param target defines the object containing the state property
  67930. * @param value defines the value to store in the state field
  67931. * @param condition defines the trigger related conditions
  67932. */
  67933. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  67934. /**
  67935. * Execute the action and store the value on the target state property.
  67936. */
  67937. execute(): void;
  67938. /**
  67939. * Serializes the actions and its related information.
  67940. * @param parent defines the object to serialize in
  67941. * @returns the serialized object
  67942. */
  67943. serialize(parent: any): any;
  67944. }
  67945. /**
  67946. * This defines an action responsible to set a property of the target
  67947. * to a desired value once triggered.
  67948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67949. */
  67950. export class SetValueAction extends Action {
  67951. /**
  67952. * The path of the property to set in the target.
  67953. */
  67954. propertyPath: string;
  67955. /**
  67956. * The value to set in the property
  67957. */
  67958. value: any;
  67959. private _target;
  67960. private _effectiveTarget;
  67961. private _property;
  67962. /**
  67963. * Instantiate the action
  67964. * @param triggerOptions defines the trigger options
  67965. * @param target defines the object containing the property
  67966. * @param propertyPath defines the path of the property to set in the target
  67967. * @param value defines the value to set in the property
  67968. * @param condition defines the trigger related conditions
  67969. */
  67970. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  67971. /** @hidden */
  67972. _prepare(): void;
  67973. /**
  67974. * Execute the action and set the targetted property to the desired value.
  67975. */
  67976. execute(): void;
  67977. /**
  67978. * Serializes the actions and its related information.
  67979. * @param parent defines the object to serialize in
  67980. * @returns the serialized object
  67981. */
  67982. serialize(parent: any): any;
  67983. }
  67984. /**
  67985. * This defines an action responsible to increment the target value
  67986. * to a desired value once triggered.
  67987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67988. */
  67989. export class IncrementValueAction extends Action {
  67990. /**
  67991. * The path of the property to increment in the target.
  67992. */
  67993. propertyPath: string;
  67994. /**
  67995. * The value we should increment the property by.
  67996. */
  67997. value: any;
  67998. private _target;
  67999. private _effectiveTarget;
  68000. private _property;
  68001. /**
  68002. * Instantiate the action
  68003. * @param triggerOptions defines the trigger options
  68004. * @param target defines the object containing the property
  68005. * @param propertyPath defines the path of the property to increment in the target
  68006. * @param value defines the value value we should increment the property by
  68007. * @param condition defines the trigger related conditions
  68008. */
  68009. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68010. /** @hidden */
  68011. _prepare(): void;
  68012. /**
  68013. * Execute the action and increment the target of the value amount.
  68014. */
  68015. execute(): void;
  68016. /**
  68017. * Serializes the actions and its related information.
  68018. * @param parent defines the object to serialize in
  68019. * @returns the serialized object
  68020. */
  68021. serialize(parent: any): any;
  68022. }
  68023. /**
  68024. * This defines an action responsible to start an animation once triggered.
  68025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68026. */
  68027. export class PlayAnimationAction extends Action {
  68028. /**
  68029. * Where the animation should start (animation frame)
  68030. */
  68031. from: number;
  68032. /**
  68033. * Where the animation should stop (animation frame)
  68034. */
  68035. to: number;
  68036. /**
  68037. * Define if the animation should loop or stop after the first play.
  68038. */
  68039. loop?: boolean;
  68040. private _target;
  68041. /**
  68042. * Instantiate the action
  68043. * @param triggerOptions defines the trigger options
  68044. * @param target defines the target animation or animation name
  68045. * @param from defines from where the animation should start (animation frame)
  68046. * @param end defines where the animation should stop (animation frame)
  68047. * @param loop defines if the animation should loop or stop after the first play
  68048. * @param condition defines the trigger related conditions
  68049. */
  68050. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  68051. /** @hidden */
  68052. _prepare(): void;
  68053. /**
  68054. * Execute the action and play the animation.
  68055. */
  68056. execute(): void;
  68057. /**
  68058. * Serializes the actions and its related information.
  68059. * @param parent defines the object to serialize in
  68060. * @returns the serialized object
  68061. */
  68062. serialize(parent: any): any;
  68063. }
  68064. /**
  68065. * This defines an action responsible to stop an animation once triggered.
  68066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68067. */
  68068. export class StopAnimationAction extends Action {
  68069. private _target;
  68070. /**
  68071. * Instantiate the action
  68072. * @param triggerOptions defines the trigger options
  68073. * @param target defines the target animation or animation name
  68074. * @param condition defines the trigger related conditions
  68075. */
  68076. constructor(triggerOptions: any, target: any, condition?: Condition);
  68077. /** @hidden */
  68078. _prepare(): void;
  68079. /**
  68080. * Execute the action and stop the animation.
  68081. */
  68082. execute(): void;
  68083. /**
  68084. * Serializes the actions and its related information.
  68085. * @param parent defines the object to serialize in
  68086. * @returns the serialized object
  68087. */
  68088. serialize(parent: any): any;
  68089. }
  68090. /**
  68091. * This defines an action responsible that does nothing once triggered.
  68092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68093. */
  68094. export class DoNothingAction extends Action {
  68095. /**
  68096. * Instantiate the action
  68097. * @param triggerOptions defines the trigger options
  68098. * @param condition defines the trigger related conditions
  68099. */
  68100. constructor(triggerOptions?: any, condition?: Condition);
  68101. /**
  68102. * Execute the action and do nothing.
  68103. */
  68104. execute(): void;
  68105. /**
  68106. * Serializes the actions and its related information.
  68107. * @param parent defines the object to serialize in
  68108. * @returns the serialized object
  68109. */
  68110. serialize(parent: any): any;
  68111. }
  68112. /**
  68113. * This defines an action responsible to trigger several actions once triggered.
  68114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68115. */
  68116. export class CombineAction extends Action {
  68117. /**
  68118. * The list of aggregated animations to run.
  68119. */
  68120. children: Action[];
  68121. /**
  68122. * Instantiate the action
  68123. * @param triggerOptions defines the trigger options
  68124. * @param children defines the list of aggregated animations to run
  68125. * @param condition defines the trigger related conditions
  68126. */
  68127. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  68128. /** @hidden */
  68129. _prepare(): void;
  68130. /**
  68131. * Execute the action and executes all the aggregated actions.
  68132. */
  68133. execute(evt: ActionEvent): void;
  68134. /**
  68135. * Serializes the actions and its related information.
  68136. * @param parent defines the object to serialize in
  68137. * @returns the serialized object
  68138. */
  68139. serialize(parent: any): any;
  68140. }
  68141. /**
  68142. * This defines an action responsible to run code (external event) once triggered.
  68143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68144. */
  68145. export class ExecuteCodeAction extends Action {
  68146. /**
  68147. * The callback function to run.
  68148. */
  68149. func: (evt: ActionEvent) => void;
  68150. /**
  68151. * Instantiate the action
  68152. * @param triggerOptions defines the trigger options
  68153. * @param func defines the callback function to run
  68154. * @param condition defines the trigger related conditions
  68155. */
  68156. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  68157. /**
  68158. * Execute the action and run the attached code.
  68159. */
  68160. execute(evt: ActionEvent): void;
  68161. }
  68162. /**
  68163. * This defines an action responsible to set the parent property of the target once triggered.
  68164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68165. */
  68166. export class SetParentAction extends Action {
  68167. private _parent;
  68168. private _target;
  68169. /**
  68170. * Instantiate the action
  68171. * @param triggerOptions defines the trigger options
  68172. * @param target defines the target containing the parent property
  68173. * @param parent defines from where the animation should start (animation frame)
  68174. * @param condition defines the trigger related conditions
  68175. */
  68176. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  68177. /** @hidden */
  68178. _prepare(): void;
  68179. /**
  68180. * Execute the action and set the parent property.
  68181. */
  68182. execute(): void;
  68183. /**
  68184. * Serializes the actions and its related information.
  68185. * @param parent defines the object to serialize in
  68186. * @returns the serialized object
  68187. */
  68188. serialize(parent: any): any;
  68189. }
  68190. }
  68191. declare module BABYLON {
  68192. /**
  68193. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  68194. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  68195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68196. */
  68197. export class ActionManager extends AbstractActionManager {
  68198. /**
  68199. * Nothing
  68200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68201. */
  68202. static readonly NothingTrigger: number;
  68203. /**
  68204. * On pick
  68205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68206. */
  68207. static readonly OnPickTrigger: number;
  68208. /**
  68209. * On left pick
  68210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68211. */
  68212. static readonly OnLeftPickTrigger: number;
  68213. /**
  68214. * On right pick
  68215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68216. */
  68217. static readonly OnRightPickTrigger: number;
  68218. /**
  68219. * On center pick
  68220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68221. */
  68222. static readonly OnCenterPickTrigger: number;
  68223. /**
  68224. * On pick down
  68225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68226. */
  68227. static readonly OnPickDownTrigger: number;
  68228. /**
  68229. * On double pick
  68230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68231. */
  68232. static readonly OnDoublePickTrigger: number;
  68233. /**
  68234. * On pick up
  68235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68236. */
  68237. static readonly OnPickUpTrigger: number;
  68238. /**
  68239. * On pick out.
  68240. * This trigger will only be raised if you also declared a OnPickDown
  68241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68242. */
  68243. static readonly OnPickOutTrigger: number;
  68244. /**
  68245. * On long press
  68246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68247. */
  68248. static readonly OnLongPressTrigger: number;
  68249. /**
  68250. * On pointer over
  68251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68252. */
  68253. static readonly OnPointerOverTrigger: number;
  68254. /**
  68255. * On pointer out
  68256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68257. */
  68258. static readonly OnPointerOutTrigger: number;
  68259. /**
  68260. * On every frame
  68261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68262. */
  68263. static readonly OnEveryFrameTrigger: number;
  68264. /**
  68265. * On intersection enter
  68266. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68267. */
  68268. static readonly OnIntersectionEnterTrigger: number;
  68269. /**
  68270. * On intersection exit
  68271. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68272. */
  68273. static readonly OnIntersectionExitTrigger: number;
  68274. /**
  68275. * On key down
  68276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68277. */
  68278. static readonly OnKeyDownTrigger: number;
  68279. /**
  68280. * On key up
  68281. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68282. */
  68283. static readonly OnKeyUpTrigger: number;
  68284. private _scene;
  68285. /**
  68286. * Creates a new action manager
  68287. * @param scene defines the hosting scene
  68288. */
  68289. constructor(scene: Scene);
  68290. /**
  68291. * Releases all associated resources
  68292. */
  68293. dispose(): void;
  68294. /**
  68295. * Gets hosting scene
  68296. * @returns the hosting scene
  68297. */
  68298. getScene(): Scene;
  68299. /**
  68300. * Does this action manager handles actions of any of the given triggers
  68301. * @param triggers defines the triggers to be tested
  68302. * @return a boolean indicating whether one (or more) of the triggers is handled
  68303. */
  68304. hasSpecificTriggers(triggers: number[]): boolean;
  68305. /**
  68306. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  68307. * speed.
  68308. * @param triggerA defines the trigger to be tested
  68309. * @param triggerB defines the trigger to be tested
  68310. * @return a boolean indicating whether one (or more) of the triggers is handled
  68311. */
  68312. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  68313. /**
  68314. * Does this action manager handles actions of a given trigger
  68315. * @param trigger defines the trigger to be tested
  68316. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  68317. * @return whether the trigger is handled
  68318. */
  68319. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  68320. /**
  68321. * Does this action manager has pointer triggers
  68322. */
  68323. readonly hasPointerTriggers: boolean;
  68324. /**
  68325. * Does this action manager has pick triggers
  68326. */
  68327. readonly hasPickTriggers: boolean;
  68328. /**
  68329. * Registers an action to this action manager
  68330. * @param action defines the action to be registered
  68331. * @return the action amended (prepared) after registration
  68332. */
  68333. registerAction(action: Action): Nullable<Action>;
  68334. /**
  68335. * Unregisters an action to this action manager
  68336. * @param action defines the action to be unregistered
  68337. * @return a boolean indicating whether the action has been unregistered
  68338. */
  68339. unregisterAction(action: Action): Boolean;
  68340. /**
  68341. * Process a specific trigger
  68342. * @param trigger defines the trigger to process
  68343. * @param evt defines the event details to be processed
  68344. */
  68345. processTrigger(trigger: number, evt?: IActionEvent): void;
  68346. /** @hidden */
  68347. _getEffectiveTarget(target: any, propertyPath: string): any;
  68348. /** @hidden */
  68349. _getProperty(propertyPath: string): string;
  68350. /**
  68351. * Serialize this manager to a JSON object
  68352. * @param name defines the property name to store this manager
  68353. * @returns a JSON representation of this manager
  68354. */
  68355. serialize(name: string): any;
  68356. /**
  68357. * Creates a new ActionManager from a JSON data
  68358. * @param parsedActions defines the JSON data to read from
  68359. * @param object defines the hosting mesh
  68360. * @param scene defines the hosting scene
  68361. */
  68362. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  68363. /**
  68364. * Get a trigger name by index
  68365. * @param trigger defines the trigger index
  68366. * @returns a trigger name
  68367. */
  68368. static GetTriggerName(trigger: number): string;
  68369. }
  68370. }
  68371. declare module BABYLON {
  68372. /**
  68373. * Class representing a ray with position and direction
  68374. */
  68375. export class Ray {
  68376. /** origin point */
  68377. origin: Vector3;
  68378. /** direction */
  68379. direction: Vector3;
  68380. /** length of the ray */
  68381. length: number;
  68382. private static readonly TmpVector3;
  68383. private _tmpRay;
  68384. /**
  68385. * Creates a new ray
  68386. * @param origin origin point
  68387. * @param direction direction
  68388. * @param length length of the ray
  68389. */
  68390. constructor(
  68391. /** origin point */
  68392. origin: Vector3,
  68393. /** direction */
  68394. direction: Vector3,
  68395. /** length of the ray */
  68396. length?: number);
  68397. /**
  68398. * Checks if the ray intersects a box
  68399. * @param minimum bound of the box
  68400. * @param maximum bound of the box
  68401. * @param intersectionTreshold extra extend to be added to the box in all direction
  68402. * @returns if the box was hit
  68403. */
  68404. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  68405. /**
  68406. * Checks if the ray intersects a box
  68407. * @param box the bounding box to check
  68408. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  68409. * @returns if the box was hit
  68410. */
  68411. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  68412. /**
  68413. * If the ray hits a sphere
  68414. * @param sphere the bounding sphere to check
  68415. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  68416. * @returns true if it hits the sphere
  68417. */
  68418. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  68419. /**
  68420. * If the ray hits a triange
  68421. * @param vertex0 triangle vertex
  68422. * @param vertex1 triangle vertex
  68423. * @param vertex2 triangle vertex
  68424. * @returns intersection information if hit
  68425. */
  68426. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  68427. /**
  68428. * Checks if ray intersects a plane
  68429. * @param plane the plane to check
  68430. * @returns the distance away it was hit
  68431. */
  68432. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  68433. /**
  68434. * Checks if ray intersects a mesh
  68435. * @param mesh the mesh to check
  68436. * @param fastCheck if only the bounding box should checked
  68437. * @returns picking info of the intersecton
  68438. */
  68439. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  68440. /**
  68441. * Checks if ray intersects a mesh
  68442. * @param meshes the meshes to check
  68443. * @param fastCheck if only the bounding box should checked
  68444. * @param results array to store result in
  68445. * @returns Array of picking infos
  68446. */
  68447. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  68448. private _comparePickingInfo;
  68449. private static smallnum;
  68450. private static rayl;
  68451. /**
  68452. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  68453. * @param sega the first point of the segment to test the intersection against
  68454. * @param segb the second point of the segment to test the intersection against
  68455. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  68456. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  68457. */
  68458. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  68459. /**
  68460. * Update the ray from viewport position
  68461. * @param x position
  68462. * @param y y position
  68463. * @param viewportWidth viewport width
  68464. * @param viewportHeight viewport height
  68465. * @param world world matrix
  68466. * @param view view matrix
  68467. * @param projection projection matrix
  68468. * @returns this ray updated
  68469. */
  68470. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68471. /**
  68472. * Creates a ray with origin and direction of 0,0,0
  68473. * @returns the new ray
  68474. */
  68475. static Zero(): Ray;
  68476. /**
  68477. * Creates a new ray from screen space and viewport
  68478. * @param x position
  68479. * @param y y position
  68480. * @param viewportWidth viewport width
  68481. * @param viewportHeight viewport height
  68482. * @param world world matrix
  68483. * @param view view matrix
  68484. * @param projection projection matrix
  68485. * @returns new ray
  68486. */
  68487. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68488. /**
  68489. * 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
  68490. * transformed to the given world matrix.
  68491. * @param origin The origin point
  68492. * @param end The end point
  68493. * @param world a matrix to transform the ray to. Default is the identity matrix.
  68494. * @returns the new ray
  68495. */
  68496. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  68497. /**
  68498. * Transforms a ray by a matrix
  68499. * @param ray ray to transform
  68500. * @param matrix matrix to apply
  68501. * @returns the resulting new ray
  68502. */
  68503. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  68504. /**
  68505. * Transforms a ray by a matrix
  68506. * @param ray ray to transform
  68507. * @param matrix matrix to apply
  68508. * @param result ray to store result in
  68509. */
  68510. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  68511. /**
  68512. * Unproject a ray from screen space to object space
  68513. * @param sourceX defines the screen space x coordinate to use
  68514. * @param sourceY defines the screen space y coordinate to use
  68515. * @param viewportWidth defines the current width of the viewport
  68516. * @param viewportHeight defines the current height of the viewport
  68517. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68518. * @param view defines the view matrix to use
  68519. * @param projection defines the projection matrix to use
  68520. */
  68521. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  68522. }
  68523. interface Scene {
  68524. /** @hidden */
  68525. _tempPickingRay: Nullable<Ray>;
  68526. /** @hidden */
  68527. _cachedRayForTransform: Ray;
  68528. /** @hidden */
  68529. _pickWithRayInverseMatrix: Matrix;
  68530. /** @hidden */
  68531. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68532. /** @hidden */
  68533. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  68534. }
  68535. }
  68536. declare module BABYLON {
  68537. /**
  68538. * Groups all the scene component constants in one place to ease maintenance.
  68539. * @hidden
  68540. */
  68541. export class SceneComponentConstants {
  68542. static readonly NAME_EFFECTLAYER: string;
  68543. static readonly NAME_LAYER: string;
  68544. static readonly NAME_LENSFLARESYSTEM: string;
  68545. static readonly NAME_BOUNDINGBOXRENDERER: string;
  68546. static readonly NAME_PARTICLESYSTEM: string;
  68547. static readonly NAME_GAMEPAD: string;
  68548. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  68549. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  68550. static readonly NAME_DEPTHRENDERER: string;
  68551. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  68552. static readonly NAME_SPRITE: string;
  68553. static readonly NAME_OUTLINERENDERER: string;
  68554. static readonly NAME_PROCEDURALTEXTURE: string;
  68555. static readonly NAME_SHADOWGENERATOR: string;
  68556. static readonly NAME_OCTREE: string;
  68557. static readonly NAME_PHYSICSENGINE: string;
  68558. static readonly NAME_AUDIO: string;
  68559. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  68560. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68561. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  68562. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68563. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  68564. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  68565. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  68566. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  68567. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  68568. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  68569. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  68570. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  68571. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  68572. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  68573. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  68574. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  68575. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  68576. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  68577. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  68578. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  68579. static readonly STEP_AFTERRENDER_AUDIO: number;
  68580. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  68581. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  68582. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  68583. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  68584. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  68585. static readonly STEP_POINTERMOVE_SPRITE: number;
  68586. static readonly STEP_POINTERDOWN_SPRITE: number;
  68587. static readonly STEP_POINTERUP_SPRITE: number;
  68588. }
  68589. /**
  68590. * This represents a scene component.
  68591. *
  68592. * This is used to decouple the dependency the scene is having on the different workloads like
  68593. * layers, post processes...
  68594. */
  68595. export interface ISceneComponent {
  68596. /**
  68597. * The name of the component. Each component must have a unique name.
  68598. */
  68599. name: string;
  68600. /**
  68601. * The scene the component belongs to.
  68602. */
  68603. scene: Scene;
  68604. /**
  68605. * Register the component to one instance of a scene.
  68606. */
  68607. register(): void;
  68608. /**
  68609. * Rebuilds the elements related to this component in case of
  68610. * context lost for instance.
  68611. */
  68612. rebuild(): void;
  68613. /**
  68614. * Disposes the component and the associated ressources.
  68615. */
  68616. dispose(): void;
  68617. }
  68618. /**
  68619. * This represents a SERIALIZABLE scene component.
  68620. *
  68621. * This extends Scene Component to add Serialization methods on top.
  68622. */
  68623. export interface ISceneSerializableComponent extends ISceneComponent {
  68624. /**
  68625. * Adds all the element from the container to the scene
  68626. * @param container the container holding the elements
  68627. */
  68628. addFromContainer(container: AbstractScene): void;
  68629. /**
  68630. * Removes all the elements in the container from the scene
  68631. * @param container contains the elements to remove
  68632. */
  68633. removeFromContainer(container: AbstractScene): void;
  68634. /**
  68635. * Serializes the component data to the specified json object
  68636. * @param serializationObject The object to serialize to
  68637. */
  68638. serialize(serializationObject: any): void;
  68639. }
  68640. /**
  68641. * Strong typing of a Mesh related stage step action
  68642. */
  68643. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  68644. /**
  68645. * Strong typing of a Evaluate Sub Mesh related stage step action
  68646. */
  68647. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  68648. /**
  68649. * Strong typing of a Active Mesh related stage step action
  68650. */
  68651. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  68652. /**
  68653. * Strong typing of a Camera related stage step action
  68654. */
  68655. export type CameraStageAction = (camera: Camera) => void;
  68656. /**
  68657. * Strong typing of a Render Target related stage step action
  68658. */
  68659. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  68660. /**
  68661. * Strong typing of a RenderingGroup related stage step action
  68662. */
  68663. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  68664. /**
  68665. * Strong typing of a Mesh Render related stage step action
  68666. */
  68667. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  68668. /**
  68669. * Strong typing of a simple stage step action
  68670. */
  68671. export type SimpleStageAction = () => void;
  68672. /**
  68673. * Strong typing of a render target action.
  68674. */
  68675. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  68676. /**
  68677. * Strong typing of a pointer move action.
  68678. */
  68679. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  68680. /**
  68681. * Strong typing of a pointer up/down action.
  68682. */
  68683. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  68684. /**
  68685. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  68686. * @hidden
  68687. */
  68688. export class Stage<T extends Function> extends Array<{
  68689. index: number;
  68690. component: ISceneComponent;
  68691. action: T;
  68692. }> {
  68693. /**
  68694. * Hide ctor from the rest of the world.
  68695. * @param items The items to add.
  68696. */
  68697. private constructor();
  68698. /**
  68699. * Creates a new Stage.
  68700. * @returns A new instance of a Stage
  68701. */
  68702. static Create<T extends Function>(): Stage<T>;
  68703. /**
  68704. * Registers a step in an ordered way in the targeted stage.
  68705. * @param index Defines the position to register the step in
  68706. * @param component Defines the component attached to the step
  68707. * @param action Defines the action to launch during the step
  68708. */
  68709. registerStep(index: number, component: ISceneComponent, action: T): void;
  68710. /**
  68711. * Clears all the steps from the stage.
  68712. */
  68713. clear(): void;
  68714. }
  68715. }
  68716. declare module BABYLON {
  68717. interface Scene {
  68718. /** @hidden */
  68719. _pointerOverSprite: Nullable<Sprite>;
  68720. /** @hidden */
  68721. _pickedDownSprite: Nullable<Sprite>;
  68722. /** @hidden */
  68723. _tempSpritePickingRay: Nullable<Ray>;
  68724. /**
  68725. * All of the sprite managers added to this scene
  68726. * @see http://doc.babylonjs.com/babylon101/sprites
  68727. */
  68728. spriteManagers: Array<ISpriteManager>;
  68729. /**
  68730. * An event triggered when sprites rendering is about to start
  68731. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68732. */
  68733. onBeforeSpritesRenderingObservable: Observable<Scene>;
  68734. /**
  68735. * An event triggered when sprites rendering is done
  68736. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68737. */
  68738. onAfterSpritesRenderingObservable: Observable<Scene>;
  68739. /** @hidden */
  68740. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68741. /** Launch a ray to try to pick a sprite in the scene
  68742. * @param x position on screen
  68743. * @param y position on screen
  68744. * @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
  68745. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68746. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  68747. * @returns a PickingInfo
  68748. */
  68749. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68750. /** Use the given ray to pick a sprite in the scene
  68751. * @param ray The ray (in world space) to use to pick meshes
  68752. * @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
  68753. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68754. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  68755. * @returns a PickingInfo
  68756. */
  68757. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68758. /**
  68759. * Force the sprite under the pointer
  68760. * @param sprite defines the sprite to use
  68761. */
  68762. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  68763. /**
  68764. * Gets the sprite under the pointer
  68765. * @returns a Sprite or null if no sprite is under the pointer
  68766. */
  68767. getPointerOverSprite(): Nullable<Sprite>;
  68768. }
  68769. /**
  68770. * Defines the sprite scene component responsible to manage sprites
  68771. * in a given scene.
  68772. */
  68773. export class SpriteSceneComponent implements ISceneComponent {
  68774. /**
  68775. * The component name helpfull to identify the component in the list of scene components.
  68776. */
  68777. readonly name: string;
  68778. /**
  68779. * The scene the component belongs to.
  68780. */
  68781. scene: Scene;
  68782. /** @hidden */
  68783. private _spritePredicate;
  68784. /**
  68785. * Creates a new instance of the component for the given scene
  68786. * @param scene Defines the scene to register the component in
  68787. */
  68788. constructor(scene: Scene);
  68789. /**
  68790. * Registers the component in a given scene
  68791. */
  68792. register(): void;
  68793. /**
  68794. * Rebuilds the elements related to this component in case of
  68795. * context lost for instance.
  68796. */
  68797. rebuild(): void;
  68798. /**
  68799. * Disposes the component and the associated ressources.
  68800. */
  68801. dispose(): void;
  68802. private _pickSpriteButKeepRay;
  68803. private _pointerMove;
  68804. private _pointerDown;
  68805. private _pointerUp;
  68806. }
  68807. }
  68808. declare module BABYLON {
  68809. /** @hidden */
  68810. export var fogFragmentDeclaration: {
  68811. name: string;
  68812. shader: string;
  68813. };
  68814. }
  68815. declare module BABYLON {
  68816. /** @hidden */
  68817. export var fogFragment: {
  68818. name: string;
  68819. shader: string;
  68820. };
  68821. }
  68822. declare module BABYLON {
  68823. /** @hidden */
  68824. export var spritesPixelShader: {
  68825. name: string;
  68826. shader: string;
  68827. };
  68828. }
  68829. declare module BABYLON {
  68830. /** @hidden */
  68831. export var fogVertexDeclaration: {
  68832. name: string;
  68833. shader: string;
  68834. };
  68835. }
  68836. declare module BABYLON {
  68837. /** @hidden */
  68838. export var spritesVertexShader: {
  68839. name: string;
  68840. shader: string;
  68841. };
  68842. }
  68843. declare module BABYLON {
  68844. /**
  68845. * Defines the minimum interface to fullfil in order to be a sprite manager.
  68846. */
  68847. export interface ISpriteManager extends IDisposable {
  68848. /**
  68849. * Restricts the camera to viewing objects with the same layerMask.
  68850. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  68851. */
  68852. layerMask: number;
  68853. /**
  68854. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  68855. */
  68856. isPickable: boolean;
  68857. /**
  68858. * Specifies the rendering group id for this mesh (0 by default)
  68859. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  68860. */
  68861. renderingGroupId: number;
  68862. /**
  68863. * Defines the list of sprites managed by the manager.
  68864. */
  68865. sprites: Array<Sprite>;
  68866. /**
  68867. * Tests the intersection of a sprite with a specific ray.
  68868. * @param ray The ray we are sending to test the collision
  68869. * @param camera The camera space we are sending rays in
  68870. * @param predicate A predicate allowing excluding sprites from the list of object to test
  68871. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  68872. * @returns picking info or null.
  68873. */
  68874. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68875. /**
  68876. * Renders the list of sprites on screen.
  68877. */
  68878. render(): void;
  68879. }
  68880. /**
  68881. * Class used to manage multiple sprites on the same spritesheet
  68882. * @see http://doc.babylonjs.com/babylon101/sprites
  68883. */
  68884. export class SpriteManager implements ISpriteManager {
  68885. /** defines the manager's name */
  68886. name: string;
  68887. /** Gets the list of sprites */
  68888. sprites: Sprite[];
  68889. /** Gets or sets the rendering group id (0 by default) */
  68890. renderingGroupId: number;
  68891. /** Gets or sets camera layer mask */
  68892. layerMask: number;
  68893. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  68894. fogEnabled: boolean;
  68895. /** Gets or sets a boolean indicating if the sprites are pickable */
  68896. isPickable: boolean;
  68897. /** Defines the default width of a cell in the spritesheet */
  68898. cellWidth: number;
  68899. /** Defines the default height of a cell in the spritesheet */
  68900. cellHeight: number;
  68901. /**
  68902. * An event triggered when the manager is disposed.
  68903. */
  68904. onDisposeObservable: Observable<SpriteManager>;
  68905. private _onDisposeObserver;
  68906. /**
  68907. * Callback called when the manager is disposed
  68908. */
  68909. onDispose: () => void;
  68910. private _capacity;
  68911. private _spriteTexture;
  68912. private _epsilon;
  68913. private _scene;
  68914. private _vertexData;
  68915. private _buffer;
  68916. private _vertexBuffers;
  68917. private _indexBuffer;
  68918. private _effectBase;
  68919. private _effectFog;
  68920. /**
  68921. * Gets or sets the spritesheet texture
  68922. */
  68923. texture: Texture;
  68924. /**
  68925. * Creates a new sprite manager
  68926. * @param name defines the manager's name
  68927. * @param imgUrl defines the sprite sheet url
  68928. * @param capacity defines the maximum allowed number of sprites
  68929. * @param cellSize defines the size of a sprite cell
  68930. * @param scene defines the hosting scene
  68931. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68932. * @param samplingMode defines the smapling mode to use with spritesheet
  68933. */
  68934. constructor(
  68935. /** defines the manager's name */
  68936. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  68937. private _appendSpriteVertex;
  68938. /**
  68939. * Intersects the sprites with a ray
  68940. * @param ray defines the ray to intersect with
  68941. * @param camera defines the current active camera
  68942. * @param predicate defines a predicate used to select candidate sprites
  68943. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  68944. * @returns null if no hit or a PickingInfo
  68945. */
  68946. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68947. /**
  68948. * Render all child sprites
  68949. */
  68950. render(): void;
  68951. /**
  68952. * Release associated resources
  68953. */
  68954. dispose(): void;
  68955. }
  68956. }
  68957. declare module BABYLON {
  68958. /**
  68959. * Class used to represent a sprite
  68960. * @see http://doc.babylonjs.com/babylon101/sprites
  68961. */
  68962. export class Sprite {
  68963. /** defines the name */
  68964. name: string;
  68965. /** Gets or sets the current world position */
  68966. position: Vector3;
  68967. /** Gets or sets the main color */
  68968. color: Color4;
  68969. /** Gets or sets the width */
  68970. width: number;
  68971. /** Gets or sets the height */
  68972. height: number;
  68973. /** Gets or sets rotation angle */
  68974. angle: number;
  68975. /** Gets or sets the cell index in the sprite sheet */
  68976. cellIndex: number;
  68977. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  68978. invertU: number;
  68979. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  68980. invertV: number;
  68981. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  68982. disposeWhenFinishedAnimating: boolean;
  68983. /** Gets the list of attached animations */
  68984. animations: Animation[];
  68985. /** Gets or sets a boolean indicating if the sprite can be picked */
  68986. isPickable: boolean;
  68987. /**
  68988. * Gets or sets the associated action manager
  68989. */
  68990. actionManager: Nullable<ActionManager>;
  68991. private _animationStarted;
  68992. private _loopAnimation;
  68993. private _fromIndex;
  68994. private _toIndex;
  68995. private _delay;
  68996. private _direction;
  68997. private _manager;
  68998. private _time;
  68999. private _onAnimationEnd;
  69000. /**
  69001. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  69002. */
  69003. isVisible: boolean;
  69004. /**
  69005. * Gets or sets the sprite size
  69006. */
  69007. size: number;
  69008. /**
  69009. * Creates a new Sprite
  69010. * @param name defines the name
  69011. * @param manager defines the manager
  69012. */
  69013. constructor(
  69014. /** defines the name */
  69015. name: string, manager: ISpriteManager);
  69016. /**
  69017. * Starts an animation
  69018. * @param from defines the initial key
  69019. * @param to defines the end key
  69020. * @param loop defines if the animation must loop
  69021. * @param delay defines the start delay (in ms)
  69022. * @param onAnimationEnd defines a callback to call when animation ends
  69023. */
  69024. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  69025. /** Stops current animation (if any) */
  69026. stopAnimation(): void;
  69027. /** @hidden */
  69028. _animate(deltaTime: number): void;
  69029. /** Release associated resources */
  69030. dispose(): void;
  69031. }
  69032. }
  69033. declare module BABYLON {
  69034. /**
  69035. * Information about the result of picking within a scene
  69036. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  69037. */
  69038. export class PickingInfo {
  69039. /** @hidden */
  69040. _pickingUnavailable: boolean;
  69041. /**
  69042. * If the pick collided with an object
  69043. */
  69044. hit: boolean;
  69045. /**
  69046. * Distance away where the pick collided
  69047. */
  69048. distance: number;
  69049. /**
  69050. * The location of pick collision
  69051. */
  69052. pickedPoint: Nullable<Vector3>;
  69053. /**
  69054. * The mesh corresponding the the pick collision
  69055. */
  69056. pickedMesh: Nullable<AbstractMesh>;
  69057. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  69058. bu: number;
  69059. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  69060. bv: number;
  69061. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  69062. faceId: number;
  69063. /** Id of the the submesh that was picked */
  69064. subMeshId: number;
  69065. /** If a sprite was picked, this will be the sprite the pick collided with */
  69066. pickedSprite: Nullable<Sprite>;
  69067. /**
  69068. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  69069. */
  69070. originMesh: Nullable<AbstractMesh>;
  69071. /**
  69072. * The ray that was used to perform the picking.
  69073. */
  69074. ray: Nullable<Ray>;
  69075. /**
  69076. * Gets the normal correspodning to the face the pick collided with
  69077. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  69078. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  69079. * @returns The normal correspodning to the face the pick collided with
  69080. */
  69081. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  69082. /**
  69083. * Gets the texture coordinates of where the pick occured
  69084. * @returns the vector containing the coordnates of the texture
  69085. */
  69086. getTextureCoordinates(): Nullable<Vector2>;
  69087. }
  69088. }
  69089. declare module BABYLON {
  69090. /**
  69091. * Gather the list of pointer event types as constants.
  69092. */
  69093. export class PointerEventTypes {
  69094. /**
  69095. * 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.
  69096. */
  69097. static readonly POINTERDOWN: number;
  69098. /**
  69099. * The pointerup event is fired when a pointer is no longer active.
  69100. */
  69101. static readonly POINTERUP: number;
  69102. /**
  69103. * The pointermove event is fired when a pointer changes coordinates.
  69104. */
  69105. static readonly POINTERMOVE: number;
  69106. /**
  69107. * The pointerwheel event is fired when a mouse wheel has been rotated.
  69108. */
  69109. static readonly POINTERWHEEL: number;
  69110. /**
  69111. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  69112. */
  69113. static readonly POINTERPICK: number;
  69114. /**
  69115. * The pointertap event is fired when a the object has been touched and released without drag.
  69116. */
  69117. static readonly POINTERTAP: number;
  69118. /**
  69119. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  69120. */
  69121. static readonly POINTERDOUBLETAP: number;
  69122. }
  69123. /**
  69124. * Base class of pointer info types.
  69125. */
  69126. export class PointerInfoBase {
  69127. /**
  69128. * Defines the type of event (PointerEventTypes)
  69129. */
  69130. type: number;
  69131. /**
  69132. * Defines the related dom event
  69133. */
  69134. event: PointerEvent | MouseWheelEvent;
  69135. /**
  69136. * Instantiates the base class of pointers info.
  69137. * @param type Defines the type of event (PointerEventTypes)
  69138. * @param event Defines the related dom event
  69139. */
  69140. constructor(
  69141. /**
  69142. * Defines the type of event (PointerEventTypes)
  69143. */
  69144. type: number,
  69145. /**
  69146. * Defines the related dom event
  69147. */
  69148. event: PointerEvent | MouseWheelEvent);
  69149. }
  69150. /**
  69151. * This class is used to store pointer related info for the onPrePointerObservable event.
  69152. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  69153. */
  69154. export class PointerInfoPre extends PointerInfoBase {
  69155. /**
  69156. * Ray from a pointer if availible (eg. 6dof controller)
  69157. */
  69158. ray: Nullable<Ray>;
  69159. /**
  69160. * Defines the local position of the pointer on the canvas.
  69161. */
  69162. localPosition: Vector2;
  69163. /**
  69164. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  69165. */
  69166. skipOnPointerObservable: boolean;
  69167. /**
  69168. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  69169. * @param type Defines the type of event (PointerEventTypes)
  69170. * @param event Defines the related dom event
  69171. * @param localX Defines the local x coordinates of the pointer when the event occured
  69172. * @param localY Defines the local y coordinates of the pointer when the event occured
  69173. */
  69174. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  69175. }
  69176. /**
  69177. * This type contains all the data related to a pointer event in Babylon.js.
  69178. * 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.
  69179. */
  69180. export class PointerInfo extends PointerInfoBase {
  69181. /**
  69182. * Defines the picking info associated to the info (if any)\
  69183. */
  69184. pickInfo: Nullable<PickingInfo>;
  69185. /**
  69186. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  69187. * @param type Defines the type of event (PointerEventTypes)
  69188. * @param event Defines the related dom event
  69189. * @param pickInfo Defines the picking info associated to the info (if any)\
  69190. */
  69191. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  69192. /**
  69193. * Defines the picking info associated to the info (if any)\
  69194. */
  69195. pickInfo: Nullable<PickingInfo>);
  69196. }
  69197. /**
  69198. * Data relating to a touch event on the screen.
  69199. */
  69200. export interface PointerTouch {
  69201. /**
  69202. * X coordinate of touch.
  69203. */
  69204. x: number;
  69205. /**
  69206. * Y coordinate of touch.
  69207. */
  69208. y: number;
  69209. /**
  69210. * Id of touch. Unique for each finger.
  69211. */
  69212. pointerId: number;
  69213. /**
  69214. * Event type passed from DOM.
  69215. */
  69216. type: any;
  69217. }
  69218. }
  69219. declare module BABYLON {
  69220. /**
  69221. * Manage the mouse inputs to control the movement of a free camera.
  69222. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69223. */
  69224. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  69225. /**
  69226. * Define if touch is enabled in the mouse input
  69227. */
  69228. touchEnabled: boolean;
  69229. /**
  69230. * Defines the camera the input is attached to.
  69231. */
  69232. camera: FreeCamera;
  69233. /**
  69234. * Defines the buttons associated with the input to handle camera move.
  69235. */
  69236. buttons: number[];
  69237. /**
  69238. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  69239. */
  69240. angularSensibility: number;
  69241. private _pointerInput;
  69242. private _onMouseMove;
  69243. private _observer;
  69244. private previousPosition;
  69245. /**
  69246. * Manage the mouse inputs to control the movement of a free camera.
  69247. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69248. * @param touchEnabled Defines if touch is enabled or not
  69249. */
  69250. constructor(
  69251. /**
  69252. * Define if touch is enabled in the mouse input
  69253. */
  69254. touchEnabled?: boolean);
  69255. /**
  69256. * Attach the input controls to a specific dom element to get the input from.
  69257. * @param element Defines the element the controls should be listened from
  69258. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69259. */
  69260. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69261. /**
  69262. * Detach the current controls from the specified dom element.
  69263. * @param element Defines the element to stop listening the inputs from
  69264. */
  69265. detachControl(element: Nullable<HTMLElement>): void;
  69266. /**
  69267. * Gets the class name of the current intput.
  69268. * @returns the class name
  69269. */
  69270. getClassName(): string;
  69271. /**
  69272. * Get the friendly name associated with the input class.
  69273. * @returns the input friendly name
  69274. */
  69275. getSimpleName(): string;
  69276. }
  69277. }
  69278. declare module BABYLON {
  69279. /**
  69280. * Manage the touch inputs to control the movement of a free camera.
  69281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69282. */
  69283. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  69284. /**
  69285. * Defines the camera the input is attached to.
  69286. */
  69287. camera: FreeCamera;
  69288. /**
  69289. * Defines the touch sensibility for rotation.
  69290. * The higher the faster.
  69291. */
  69292. touchAngularSensibility: number;
  69293. /**
  69294. * Defines the touch sensibility for move.
  69295. * The higher the faster.
  69296. */
  69297. touchMoveSensibility: number;
  69298. private _offsetX;
  69299. private _offsetY;
  69300. private _pointerPressed;
  69301. private _pointerInput;
  69302. private _observer;
  69303. private _onLostFocus;
  69304. /**
  69305. * Attach the input controls to a specific dom element to get the input from.
  69306. * @param element Defines the element the controls should be listened from
  69307. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69308. */
  69309. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69310. /**
  69311. * Detach the current controls from the specified dom element.
  69312. * @param element Defines the element to stop listening the inputs from
  69313. */
  69314. detachControl(element: Nullable<HTMLElement>): void;
  69315. /**
  69316. * Update the current camera state depending on the inputs that have been used this frame.
  69317. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69318. */
  69319. checkInputs(): void;
  69320. /**
  69321. * Gets the class name of the current intput.
  69322. * @returns the class name
  69323. */
  69324. getClassName(): string;
  69325. /**
  69326. * Get the friendly name associated with the input class.
  69327. * @returns the input friendly name
  69328. */
  69329. getSimpleName(): string;
  69330. }
  69331. }
  69332. declare module BABYLON {
  69333. /**
  69334. * Default Inputs manager for the FreeCamera.
  69335. * It groups all the default supported inputs for ease of use.
  69336. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69337. */
  69338. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  69339. /**
  69340. * Instantiates a new FreeCameraInputsManager.
  69341. * @param camera Defines the camera the inputs belong to
  69342. */
  69343. constructor(camera: FreeCamera);
  69344. /**
  69345. * Add keyboard input support to the input manager.
  69346. * @returns the current input manager
  69347. */
  69348. addKeyboard(): FreeCameraInputsManager;
  69349. /**
  69350. * Add mouse input support to the input manager.
  69351. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  69352. * @returns the current input manager
  69353. */
  69354. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  69355. /**
  69356. * Add touch input support to the input manager.
  69357. * @returns the current input manager
  69358. */
  69359. addTouch(): FreeCameraInputsManager;
  69360. }
  69361. }
  69362. declare module BABYLON {
  69363. /**
  69364. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69365. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  69366. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69367. */
  69368. export class FreeCamera extends TargetCamera {
  69369. /**
  69370. * Define the collision ellipsoid of the camera.
  69371. * This is helpful to simulate a camera body like the player body around the camera
  69372. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  69373. */
  69374. ellipsoid: Vector3;
  69375. /**
  69376. * Define an offset for the position of the ellipsoid around the camera.
  69377. * This can be helpful to determine the center of the body near the gravity center of the body
  69378. * instead of its head.
  69379. */
  69380. ellipsoidOffset: Vector3;
  69381. /**
  69382. * Enable or disable collisions of the camera with the rest of the scene objects.
  69383. */
  69384. checkCollisions: boolean;
  69385. /**
  69386. * Enable or disable gravity on the camera.
  69387. */
  69388. applyGravity: boolean;
  69389. /**
  69390. * Define the input manager associated to the camera.
  69391. */
  69392. inputs: FreeCameraInputsManager;
  69393. /**
  69394. * Gets the input sensibility for a mouse input. (default is 2000.0)
  69395. * Higher values reduce sensitivity.
  69396. */
  69397. /**
  69398. * Sets the input sensibility for a mouse input. (default is 2000.0)
  69399. * Higher values reduce sensitivity.
  69400. */
  69401. angularSensibility: number;
  69402. /**
  69403. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  69404. */
  69405. keysUp: number[];
  69406. /**
  69407. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  69408. */
  69409. keysDown: number[];
  69410. /**
  69411. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  69412. */
  69413. keysLeft: number[];
  69414. /**
  69415. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  69416. */
  69417. keysRight: number[];
  69418. /**
  69419. * Event raised when the camera collide with a mesh in the scene.
  69420. */
  69421. onCollide: (collidedMesh: AbstractMesh) => void;
  69422. private _collider;
  69423. private _needMoveForGravity;
  69424. private _oldPosition;
  69425. private _diffPosition;
  69426. private _newPosition;
  69427. /** @hidden */
  69428. _localDirection: Vector3;
  69429. /** @hidden */
  69430. _transformedDirection: Vector3;
  69431. /**
  69432. * Instantiates a Free Camera.
  69433. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69434. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  69435. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69436. * @param name Define the name of the camera in the scene
  69437. * @param position Define the start position of the camera in the scene
  69438. * @param scene Define the scene the camera belongs to
  69439. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  69440. */
  69441. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  69442. /**
  69443. * Attached controls to the current camera.
  69444. * @param element Defines the element the controls should be listened from
  69445. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69446. */
  69447. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69448. /**
  69449. * Detach the current controls from the camera.
  69450. * The camera will stop reacting to inputs.
  69451. * @param element Defines the element to stop listening the inputs from
  69452. */
  69453. detachControl(element: HTMLElement): void;
  69454. private _collisionMask;
  69455. /**
  69456. * Define a collision mask to limit the list of object the camera can collide with
  69457. */
  69458. collisionMask: number;
  69459. /** @hidden */
  69460. _collideWithWorld(displacement: Vector3): void;
  69461. private _onCollisionPositionChange;
  69462. /** @hidden */
  69463. _checkInputs(): void;
  69464. /** @hidden */
  69465. _decideIfNeedsToMove(): boolean;
  69466. /** @hidden */
  69467. _updatePosition(): void;
  69468. /**
  69469. * Destroy the camera and release the current resources hold by it.
  69470. */
  69471. dispose(): void;
  69472. /**
  69473. * Gets the current object class name.
  69474. * @return the class name
  69475. */
  69476. getClassName(): string;
  69477. }
  69478. }
  69479. declare module BABYLON {
  69480. /**
  69481. * Represents a gamepad control stick position
  69482. */
  69483. export class StickValues {
  69484. /**
  69485. * The x component of the control stick
  69486. */
  69487. x: number;
  69488. /**
  69489. * The y component of the control stick
  69490. */
  69491. y: number;
  69492. /**
  69493. * Initializes the gamepad x and y control stick values
  69494. * @param x The x component of the gamepad control stick value
  69495. * @param y The y component of the gamepad control stick value
  69496. */
  69497. constructor(
  69498. /**
  69499. * The x component of the control stick
  69500. */
  69501. x: number,
  69502. /**
  69503. * The y component of the control stick
  69504. */
  69505. y: number);
  69506. }
  69507. /**
  69508. * An interface which manages callbacks for gamepad button changes
  69509. */
  69510. export interface GamepadButtonChanges {
  69511. /**
  69512. * Called when a gamepad has been changed
  69513. */
  69514. changed: boolean;
  69515. /**
  69516. * Called when a gamepad press event has been triggered
  69517. */
  69518. pressChanged: boolean;
  69519. /**
  69520. * Called when a touch event has been triggered
  69521. */
  69522. touchChanged: boolean;
  69523. /**
  69524. * Called when a value has changed
  69525. */
  69526. valueChanged: boolean;
  69527. }
  69528. /**
  69529. * Represents a gamepad
  69530. */
  69531. export class Gamepad {
  69532. /**
  69533. * The id of the gamepad
  69534. */
  69535. id: string;
  69536. /**
  69537. * The index of the gamepad
  69538. */
  69539. index: number;
  69540. /**
  69541. * The browser gamepad
  69542. */
  69543. browserGamepad: any;
  69544. /**
  69545. * Specifies what type of gamepad this represents
  69546. */
  69547. type: number;
  69548. private _leftStick;
  69549. private _rightStick;
  69550. /** @hidden */
  69551. _isConnected: boolean;
  69552. private _leftStickAxisX;
  69553. private _leftStickAxisY;
  69554. private _rightStickAxisX;
  69555. private _rightStickAxisY;
  69556. /**
  69557. * Triggered when the left control stick has been changed
  69558. */
  69559. private _onleftstickchanged;
  69560. /**
  69561. * Triggered when the right control stick has been changed
  69562. */
  69563. private _onrightstickchanged;
  69564. /**
  69565. * Represents a gamepad controller
  69566. */
  69567. static GAMEPAD: number;
  69568. /**
  69569. * Represents a generic controller
  69570. */
  69571. static GENERIC: number;
  69572. /**
  69573. * Represents an XBox controller
  69574. */
  69575. static XBOX: number;
  69576. /**
  69577. * Represents a pose-enabled controller
  69578. */
  69579. static POSE_ENABLED: number;
  69580. /**
  69581. * Specifies whether the left control stick should be Y-inverted
  69582. */
  69583. protected _invertLeftStickY: boolean;
  69584. /**
  69585. * Specifies if the gamepad has been connected
  69586. */
  69587. readonly isConnected: boolean;
  69588. /**
  69589. * Initializes the gamepad
  69590. * @param id The id of the gamepad
  69591. * @param index The index of the gamepad
  69592. * @param browserGamepad The browser gamepad
  69593. * @param leftStickX The x component of the left joystick
  69594. * @param leftStickY The y component of the left joystick
  69595. * @param rightStickX The x component of the right joystick
  69596. * @param rightStickY The y component of the right joystick
  69597. */
  69598. constructor(
  69599. /**
  69600. * The id of the gamepad
  69601. */
  69602. id: string,
  69603. /**
  69604. * The index of the gamepad
  69605. */
  69606. index: number,
  69607. /**
  69608. * The browser gamepad
  69609. */
  69610. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  69611. /**
  69612. * Callback triggered when the left joystick has changed
  69613. * @param callback
  69614. */
  69615. onleftstickchanged(callback: (values: StickValues) => void): void;
  69616. /**
  69617. * Callback triggered when the right joystick has changed
  69618. * @param callback
  69619. */
  69620. onrightstickchanged(callback: (values: StickValues) => void): void;
  69621. /**
  69622. * Gets the left joystick
  69623. */
  69624. /**
  69625. * Sets the left joystick values
  69626. */
  69627. leftStick: StickValues;
  69628. /**
  69629. * Gets the right joystick
  69630. */
  69631. /**
  69632. * Sets the right joystick value
  69633. */
  69634. rightStick: StickValues;
  69635. /**
  69636. * Updates the gamepad joystick positions
  69637. */
  69638. update(): void;
  69639. /**
  69640. * Disposes the gamepad
  69641. */
  69642. dispose(): void;
  69643. }
  69644. /**
  69645. * Represents a generic gamepad
  69646. */
  69647. export class GenericPad extends Gamepad {
  69648. private _buttons;
  69649. private _onbuttondown;
  69650. private _onbuttonup;
  69651. /**
  69652. * Observable triggered when a button has been pressed
  69653. */
  69654. onButtonDownObservable: Observable<number>;
  69655. /**
  69656. * Observable triggered when a button has been released
  69657. */
  69658. onButtonUpObservable: Observable<number>;
  69659. /**
  69660. * Callback triggered when a button has been pressed
  69661. * @param callback Called when a button has been pressed
  69662. */
  69663. onbuttondown(callback: (buttonPressed: number) => void): void;
  69664. /**
  69665. * Callback triggered when a button has been released
  69666. * @param callback Called when a button has been released
  69667. */
  69668. onbuttonup(callback: (buttonReleased: number) => void): void;
  69669. /**
  69670. * Initializes the generic gamepad
  69671. * @param id The id of the generic gamepad
  69672. * @param index The index of the generic gamepad
  69673. * @param browserGamepad The browser gamepad
  69674. */
  69675. constructor(id: string, index: number, browserGamepad: any);
  69676. private _setButtonValue;
  69677. /**
  69678. * Updates the generic gamepad
  69679. */
  69680. update(): void;
  69681. /**
  69682. * Disposes the generic gamepad
  69683. */
  69684. dispose(): void;
  69685. }
  69686. }
  69687. declare module BABYLON {
  69688. /**
  69689. * Defines the types of pose enabled controllers that are supported
  69690. */
  69691. export enum PoseEnabledControllerType {
  69692. /**
  69693. * HTC Vive
  69694. */
  69695. VIVE = 0,
  69696. /**
  69697. * Oculus Rift
  69698. */
  69699. OCULUS = 1,
  69700. /**
  69701. * Windows mixed reality
  69702. */
  69703. WINDOWS = 2,
  69704. /**
  69705. * Samsung gear VR
  69706. */
  69707. GEAR_VR = 3,
  69708. /**
  69709. * Google Daydream
  69710. */
  69711. DAYDREAM = 4,
  69712. /**
  69713. * Generic
  69714. */
  69715. GENERIC = 5
  69716. }
  69717. /**
  69718. * Defines the MutableGamepadButton interface for the state of a gamepad button
  69719. */
  69720. export interface MutableGamepadButton {
  69721. /**
  69722. * Value of the button/trigger
  69723. */
  69724. value: number;
  69725. /**
  69726. * If the button/trigger is currently touched
  69727. */
  69728. touched: boolean;
  69729. /**
  69730. * If the button/trigger is currently pressed
  69731. */
  69732. pressed: boolean;
  69733. }
  69734. /**
  69735. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  69736. * @hidden
  69737. */
  69738. export interface ExtendedGamepadButton extends GamepadButton {
  69739. /**
  69740. * If the button/trigger is currently pressed
  69741. */
  69742. readonly pressed: boolean;
  69743. /**
  69744. * If the button/trigger is currently touched
  69745. */
  69746. readonly touched: boolean;
  69747. /**
  69748. * Value of the button/trigger
  69749. */
  69750. readonly value: number;
  69751. }
  69752. /** @hidden */
  69753. export interface _GamePadFactory {
  69754. /**
  69755. * Returns wether or not the current gamepad can be created for this type of controller.
  69756. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69757. * @returns true if it can be created, otherwise false
  69758. */
  69759. canCreate(gamepadInfo: any): boolean;
  69760. /**
  69761. * Creates a new instance of the Gamepad.
  69762. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69763. * @returns the new gamepad instance
  69764. */
  69765. create(gamepadInfo: any): Gamepad;
  69766. }
  69767. /**
  69768. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69769. */
  69770. export class PoseEnabledControllerHelper {
  69771. /** @hidden */
  69772. static _ControllerFactories: _GamePadFactory[];
  69773. /** @hidden */
  69774. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  69775. /**
  69776. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69777. * @param vrGamepad the gamepad to initialized
  69778. * @returns a vr controller of the type the gamepad identified as
  69779. */
  69780. static InitiateController(vrGamepad: any): Gamepad;
  69781. }
  69782. /**
  69783. * Defines the PoseEnabledController object that contains state of a vr capable controller
  69784. */
  69785. export class PoseEnabledController extends Gamepad implements PoseControlled {
  69786. private _deviceRoomPosition;
  69787. private _deviceRoomRotationQuaternion;
  69788. /**
  69789. * The device position in babylon space
  69790. */
  69791. devicePosition: Vector3;
  69792. /**
  69793. * The device rotation in babylon space
  69794. */
  69795. deviceRotationQuaternion: Quaternion;
  69796. /**
  69797. * The scale factor of the device in babylon space
  69798. */
  69799. deviceScaleFactor: number;
  69800. /**
  69801. * (Likely devicePosition should be used instead) The device position in its room space
  69802. */
  69803. position: Vector3;
  69804. /**
  69805. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  69806. */
  69807. rotationQuaternion: Quaternion;
  69808. /**
  69809. * The type of controller (Eg. Windows mixed reality)
  69810. */
  69811. controllerType: PoseEnabledControllerType;
  69812. protected _calculatedPosition: Vector3;
  69813. private _calculatedRotation;
  69814. /**
  69815. * The raw pose from the device
  69816. */
  69817. rawPose: DevicePose;
  69818. private _trackPosition;
  69819. private _maxRotationDistFromHeadset;
  69820. private _draggedRoomRotation;
  69821. /**
  69822. * @hidden
  69823. */
  69824. _disableTrackPosition(fixedPosition: Vector3): void;
  69825. /**
  69826. * Internal, the mesh attached to the controller
  69827. * @hidden
  69828. */
  69829. _mesh: Nullable<AbstractMesh>;
  69830. private _poseControlledCamera;
  69831. private _leftHandSystemQuaternion;
  69832. /**
  69833. * Internal, matrix used to convert room space to babylon space
  69834. * @hidden
  69835. */
  69836. _deviceToWorld: Matrix;
  69837. /**
  69838. * Node to be used when casting a ray from the controller
  69839. * @hidden
  69840. */
  69841. _pointingPoseNode: Nullable<TransformNode>;
  69842. /**
  69843. * Name of the child mesh that can be used to cast a ray from the controller
  69844. */
  69845. static readonly POINTING_POSE: string;
  69846. /**
  69847. * Creates a new PoseEnabledController from a gamepad
  69848. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  69849. */
  69850. constructor(browserGamepad: any);
  69851. private _workingMatrix;
  69852. /**
  69853. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  69854. */
  69855. update(): void;
  69856. /**
  69857. * Updates only the pose device and mesh without doing any button event checking
  69858. */
  69859. protected _updatePoseAndMesh(): void;
  69860. /**
  69861. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  69862. * @param poseData raw pose fromthe device
  69863. */
  69864. updateFromDevice(poseData: DevicePose): void;
  69865. /**
  69866. * @hidden
  69867. */
  69868. _meshAttachedObservable: Observable<AbstractMesh>;
  69869. /**
  69870. * Attaches a mesh to the controller
  69871. * @param mesh the mesh to be attached
  69872. */
  69873. attachToMesh(mesh: AbstractMesh): void;
  69874. /**
  69875. * Attaches the controllers mesh to a camera
  69876. * @param camera the camera the mesh should be attached to
  69877. */
  69878. attachToPoseControlledCamera(camera: TargetCamera): void;
  69879. /**
  69880. * Disposes of the controller
  69881. */
  69882. dispose(): void;
  69883. /**
  69884. * The mesh that is attached to the controller
  69885. */
  69886. readonly mesh: Nullable<AbstractMesh>;
  69887. /**
  69888. * Gets the ray of the controller in the direction the controller is pointing
  69889. * @param length the length the resulting ray should be
  69890. * @returns a ray in the direction the controller is pointing
  69891. */
  69892. getForwardRay(length?: number): Ray;
  69893. }
  69894. }
  69895. declare module BABYLON {
  69896. /**
  69897. * Defines the WebVRController object that represents controllers tracked in 3D space
  69898. */
  69899. export abstract class WebVRController extends PoseEnabledController {
  69900. /**
  69901. * Internal, the default controller model for the controller
  69902. */
  69903. protected _defaultModel: AbstractMesh;
  69904. /**
  69905. * Fired when the trigger state has changed
  69906. */
  69907. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  69908. /**
  69909. * Fired when the main button state has changed
  69910. */
  69911. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69912. /**
  69913. * Fired when the secondary button state has changed
  69914. */
  69915. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69916. /**
  69917. * Fired when the pad state has changed
  69918. */
  69919. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  69920. /**
  69921. * Fired when controllers stick values have changed
  69922. */
  69923. onPadValuesChangedObservable: Observable<StickValues>;
  69924. /**
  69925. * Array of button availible on the controller
  69926. */
  69927. protected _buttons: Array<MutableGamepadButton>;
  69928. private _onButtonStateChange;
  69929. /**
  69930. * Fired when a controller button's state has changed
  69931. * @param callback the callback containing the button that was modified
  69932. */
  69933. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  69934. /**
  69935. * X and Y axis corrisponding to the controllers joystick
  69936. */
  69937. pad: StickValues;
  69938. /**
  69939. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  69940. */
  69941. hand: string;
  69942. /**
  69943. * The default controller model for the controller
  69944. */
  69945. readonly defaultModel: AbstractMesh;
  69946. /**
  69947. * Creates a new WebVRController from a gamepad
  69948. * @param vrGamepad the gamepad that the WebVRController should be created from
  69949. */
  69950. constructor(vrGamepad: any);
  69951. /**
  69952. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  69953. */
  69954. update(): void;
  69955. /**
  69956. * Function to be called when a button is modified
  69957. */
  69958. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  69959. /**
  69960. * Loads a mesh and attaches it to the controller
  69961. * @param scene the scene the mesh should be added to
  69962. * @param meshLoaded callback for when the mesh has been loaded
  69963. */
  69964. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  69965. private _setButtonValue;
  69966. private _changes;
  69967. private _checkChanges;
  69968. /**
  69969. * Disposes of th webVRCOntroller
  69970. */
  69971. dispose(): void;
  69972. }
  69973. }
  69974. declare module BABYLON {
  69975. /**
  69976. * The HemisphericLight simulates the ambient environment light,
  69977. * so the passed direction is the light reflection direction, not the incoming direction.
  69978. */
  69979. export class HemisphericLight extends Light {
  69980. /**
  69981. * The groundColor is the light in the opposite direction to the one specified during creation.
  69982. * 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.
  69983. */
  69984. groundColor: Color3;
  69985. /**
  69986. * The light reflection direction, not the incoming direction.
  69987. */
  69988. direction: Vector3;
  69989. /**
  69990. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  69991. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  69992. * The HemisphericLight can't cast shadows.
  69993. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69994. * @param name The friendly name of the light
  69995. * @param direction The direction of the light reflection
  69996. * @param scene The scene the light belongs to
  69997. */
  69998. constructor(name: string, direction: Vector3, scene: Scene);
  69999. protected _buildUniformLayout(): void;
  70000. /**
  70001. * Returns the string "HemisphericLight".
  70002. * @return The class name
  70003. */
  70004. getClassName(): string;
  70005. /**
  70006. * Sets the HemisphericLight direction towards the passed target (Vector3).
  70007. * Returns the updated direction.
  70008. * @param target The target the direction should point to
  70009. * @return The computed direction
  70010. */
  70011. setDirectionToTarget(target: Vector3): Vector3;
  70012. /**
  70013. * Returns the shadow generator associated to the light.
  70014. * @returns Always null for hemispheric lights because it does not support shadows.
  70015. */
  70016. getShadowGenerator(): Nullable<IShadowGenerator>;
  70017. /**
  70018. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  70019. * @param effect The effect to update
  70020. * @param lightIndex The index of the light in the effect to update
  70021. * @returns The hemispheric light
  70022. */
  70023. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  70024. /**
  70025. * Computes the world matrix of the node
  70026. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  70027. * @param useWasUpdatedFlag defines a reserved property
  70028. * @returns the world matrix
  70029. */
  70030. computeWorldMatrix(): Matrix;
  70031. /**
  70032. * Returns the integer 3.
  70033. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70034. */
  70035. getTypeID(): number;
  70036. /**
  70037. * Prepares the list of defines specific to the light type.
  70038. * @param defines the list of defines
  70039. * @param lightIndex defines the index of the light for the effect
  70040. */
  70041. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70042. }
  70043. }
  70044. declare module BABYLON {
  70045. /**
  70046. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  70047. * IMPORTANT!! The data is right-hand data.
  70048. * @export
  70049. * @interface DevicePose
  70050. */
  70051. export interface DevicePose {
  70052. /**
  70053. * The position of the device, values in array are [x,y,z].
  70054. */
  70055. readonly position: Nullable<Float32Array>;
  70056. /**
  70057. * The linearVelocity of the device, values in array are [x,y,z].
  70058. */
  70059. readonly linearVelocity: Nullable<Float32Array>;
  70060. /**
  70061. * The linearAcceleration of the device, values in array are [x,y,z].
  70062. */
  70063. readonly linearAcceleration: Nullable<Float32Array>;
  70064. /**
  70065. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  70066. */
  70067. readonly orientation: Nullable<Float32Array>;
  70068. /**
  70069. * The angularVelocity of the device, values in array are [x,y,z].
  70070. */
  70071. readonly angularVelocity: Nullable<Float32Array>;
  70072. /**
  70073. * The angularAcceleration of the device, values in array are [x,y,z].
  70074. */
  70075. readonly angularAcceleration: Nullable<Float32Array>;
  70076. }
  70077. /**
  70078. * Interface representing a pose controlled object in Babylon.
  70079. * A pose controlled object has both regular pose values as well as pose values
  70080. * from an external device such as a VR head mounted display
  70081. */
  70082. export interface PoseControlled {
  70083. /**
  70084. * The position of the object in babylon space.
  70085. */
  70086. position: Vector3;
  70087. /**
  70088. * The rotation quaternion of the object in babylon space.
  70089. */
  70090. rotationQuaternion: Quaternion;
  70091. /**
  70092. * The position of the device in babylon space.
  70093. */
  70094. devicePosition?: Vector3;
  70095. /**
  70096. * The rotation quaternion of the device in babylon space.
  70097. */
  70098. deviceRotationQuaternion: Quaternion;
  70099. /**
  70100. * The raw pose coming from the device.
  70101. */
  70102. rawPose: Nullable<DevicePose>;
  70103. /**
  70104. * The scale of the device to be used when translating from device space to babylon space.
  70105. */
  70106. deviceScaleFactor: number;
  70107. /**
  70108. * Updates the poseControlled values based on the input device pose.
  70109. * @param poseData the pose data to update the object with
  70110. */
  70111. updateFromDevice(poseData: DevicePose): void;
  70112. }
  70113. /**
  70114. * Set of options to customize the webVRCamera
  70115. */
  70116. export interface WebVROptions {
  70117. /**
  70118. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  70119. */
  70120. trackPosition?: boolean;
  70121. /**
  70122. * Sets the scale of the vrDevice in babylon space. (default: 1)
  70123. */
  70124. positionScale?: number;
  70125. /**
  70126. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  70127. */
  70128. displayName?: string;
  70129. /**
  70130. * Should the native controller meshes be initialized. (default: true)
  70131. */
  70132. controllerMeshes?: boolean;
  70133. /**
  70134. * Creating a default HemiLight only on controllers. (default: true)
  70135. */
  70136. defaultLightingOnControllers?: boolean;
  70137. /**
  70138. * If you don't want to use the default VR button of the helper. (default: false)
  70139. */
  70140. useCustomVRButton?: boolean;
  70141. /**
  70142. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  70143. */
  70144. customVRButton?: HTMLButtonElement;
  70145. /**
  70146. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  70147. */
  70148. rayLength?: number;
  70149. /**
  70150. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  70151. */
  70152. defaultHeight?: number;
  70153. }
  70154. /**
  70155. * This represents a WebVR camera.
  70156. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  70157. * @example http://doc.babylonjs.com/how_to/webvr_camera
  70158. */
  70159. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  70160. private webVROptions;
  70161. /**
  70162. * @hidden
  70163. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  70164. */
  70165. _vrDevice: any;
  70166. /**
  70167. * The rawPose of the vrDevice.
  70168. */
  70169. rawPose: Nullable<DevicePose>;
  70170. private _onVREnabled;
  70171. private _specsVersion;
  70172. private _attached;
  70173. private _frameData;
  70174. protected _descendants: Array<Node>;
  70175. private _deviceRoomPosition;
  70176. /** @hidden */
  70177. _deviceRoomRotationQuaternion: Quaternion;
  70178. private _standingMatrix;
  70179. /**
  70180. * Represents device position in babylon space.
  70181. */
  70182. devicePosition: Vector3;
  70183. /**
  70184. * Represents device rotation in babylon space.
  70185. */
  70186. deviceRotationQuaternion: Quaternion;
  70187. /**
  70188. * The scale of the device to be used when translating from device space to babylon space.
  70189. */
  70190. deviceScaleFactor: number;
  70191. private _deviceToWorld;
  70192. private _worldToDevice;
  70193. /**
  70194. * References to the webVR controllers for the vrDevice.
  70195. */
  70196. controllers: Array<WebVRController>;
  70197. /**
  70198. * Emits an event when a controller is attached.
  70199. */
  70200. onControllersAttachedObservable: Observable<WebVRController[]>;
  70201. /**
  70202. * Emits an event when a controller's mesh has been loaded;
  70203. */
  70204. onControllerMeshLoadedObservable: Observable<WebVRController>;
  70205. /**
  70206. * Emits an event when the HMD's pose has been updated.
  70207. */
  70208. onPoseUpdatedFromDeviceObservable: Observable<any>;
  70209. private _poseSet;
  70210. /**
  70211. * If the rig cameras be used as parent instead of this camera.
  70212. */
  70213. rigParenting: boolean;
  70214. private _lightOnControllers;
  70215. private _defaultHeight?;
  70216. /**
  70217. * Instantiates a WebVRFreeCamera.
  70218. * @param name The name of the WebVRFreeCamera
  70219. * @param position The starting anchor position for the camera
  70220. * @param scene The scene the camera belongs to
  70221. * @param webVROptions a set of customizable options for the webVRCamera
  70222. */
  70223. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  70224. /**
  70225. * Gets the device distance from the ground in meters.
  70226. * @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.
  70227. */
  70228. deviceDistanceToRoomGround(): number;
  70229. /**
  70230. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70231. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  70232. */
  70233. useStandingMatrix(callback?: (bool: boolean) => void): void;
  70234. /**
  70235. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70236. * @returns A promise with a boolean set to if the standing matrix is supported.
  70237. */
  70238. useStandingMatrixAsync(): Promise<boolean>;
  70239. /**
  70240. * Disposes the camera
  70241. */
  70242. dispose(): void;
  70243. /**
  70244. * Gets a vrController by name.
  70245. * @param name The name of the controller to retreive
  70246. * @returns the controller matching the name specified or null if not found
  70247. */
  70248. getControllerByName(name: string): Nullable<WebVRController>;
  70249. private _leftController;
  70250. /**
  70251. * The controller corrisponding to the users left hand.
  70252. */
  70253. readonly leftController: Nullable<WebVRController>;
  70254. private _rightController;
  70255. /**
  70256. * The controller corrisponding to the users right hand.
  70257. */
  70258. readonly rightController: Nullable<WebVRController>;
  70259. /**
  70260. * Casts a ray forward from the vrCamera's gaze.
  70261. * @param length Length of the ray (default: 100)
  70262. * @returns the ray corrisponding to the gaze
  70263. */
  70264. getForwardRay(length?: number): Ray;
  70265. /**
  70266. * @hidden
  70267. * Updates the camera based on device's frame data
  70268. */
  70269. _checkInputs(): void;
  70270. /**
  70271. * Updates the poseControlled values based on the input device pose.
  70272. * @param poseData Pose coming from the device
  70273. */
  70274. updateFromDevice(poseData: DevicePose): void;
  70275. private _htmlElementAttached;
  70276. private _detachIfAttached;
  70277. /**
  70278. * WebVR's attach control will start broadcasting frames to the device.
  70279. * Note that in certain browsers (chrome for example) this function must be called
  70280. * within a user-interaction callback. Example:
  70281. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  70282. *
  70283. * @param element html element to attach the vrDevice to
  70284. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  70285. */
  70286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70287. /**
  70288. * Detaches the camera from the html element and disables VR
  70289. *
  70290. * @param element html element to detach from
  70291. */
  70292. detachControl(element: HTMLElement): void;
  70293. /**
  70294. * @returns the name of this class
  70295. */
  70296. getClassName(): string;
  70297. /**
  70298. * Calls resetPose on the vrDisplay
  70299. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  70300. */
  70301. resetToCurrentRotation(): void;
  70302. /**
  70303. * @hidden
  70304. * Updates the rig cameras (left and right eye)
  70305. */
  70306. _updateRigCameras(): void;
  70307. private _workingVector;
  70308. private _oneVector;
  70309. private _workingMatrix;
  70310. private updateCacheCalled;
  70311. private _correctPositionIfNotTrackPosition;
  70312. /**
  70313. * @hidden
  70314. * Updates the cached values of the camera
  70315. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  70316. */
  70317. _updateCache(ignoreParentClass?: boolean): void;
  70318. /**
  70319. * @hidden
  70320. * Get current device position in babylon world
  70321. */
  70322. _computeDevicePosition(): void;
  70323. /**
  70324. * Updates the current device position and rotation in the babylon world
  70325. */
  70326. update(): void;
  70327. /**
  70328. * @hidden
  70329. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  70330. * @returns an identity matrix
  70331. */
  70332. _getViewMatrix(): Matrix;
  70333. private _tmpMatrix;
  70334. /**
  70335. * This function is called by the two RIG cameras.
  70336. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  70337. * @hidden
  70338. */
  70339. _getWebVRViewMatrix(): Matrix;
  70340. /** @hidden */
  70341. _getWebVRProjectionMatrix(): Matrix;
  70342. private _onGamepadConnectedObserver;
  70343. private _onGamepadDisconnectedObserver;
  70344. private _updateCacheWhenTrackingDisabledObserver;
  70345. /**
  70346. * Initializes the controllers and their meshes
  70347. */
  70348. initControllers(): void;
  70349. }
  70350. }
  70351. declare module BABYLON {
  70352. /**
  70353. * Size options for a post process
  70354. */
  70355. export type PostProcessOptions = {
  70356. width: number;
  70357. height: number;
  70358. };
  70359. /**
  70360. * PostProcess can be used to apply a shader to a texture after it has been rendered
  70361. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70362. */
  70363. export class PostProcess {
  70364. /** Name of the PostProcess. */
  70365. name: string;
  70366. /**
  70367. * Gets or sets the unique id of the post process
  70368. */
  70369. uniqueId: number;
  70370. /**
  70371. * Width of the texture to apply the post process on
  70372. */
  70373. width: number;
  70374. /**
  70375. * Height of the texture to apply the post process on
  70376. */
  70377. height: number;
  70378. /**
  70379. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  70380. * @hidden
  70381. */
  70382. _outputTexture: Nullable<InternalTexture>;
  70383. /**
  70384. * Sampling mode used by the shader
  70385. * See https://doc.babylonjs.com/classes/3.1/texture
  70386. */
  70387. renderTargetSamplingMode: number;
  70388. /**
  70389. * Clear color to use when screen clearing
  70390. */
  70391. clearColor: Color4;
  70392. /**
  70393. * If the buffer needs to be cleared before applying the post process. (default: true)
  70394. * Should be set to false if shader will overwrite all previous pixels.
  70395. */
  70396. autoClear: boolean;
  70397. /**
  70398. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  70399. */
  70400. alphaMode: number;
  70401. /**
  70402. * Sets the setAlphaBlendConstants of the babylon engine
  70403. */
  70404. alphaConstants: Color4;
  70405. /**
  70406. * Animations to be used for the post processing
  70407. */
  70408. animations: Animation[];
  70409. /**
  70410. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  70411. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  70412. */
  70413. enablePixelPerfectMode: boolean;
  70414. /**
  70415. * Force the postprocess to be applied without taking in account viewport
  70416. */
  70417. forceFullscreenViewport: boolean;
  70418. /**
  70419. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  70420. *
  70421. * | Value | Type | Description |
  70422. * | ----- | ----------------------------------- | ----------- |
  70423. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  70424. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  70425. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  70426. *
  70427. */
  70428. scaleMode: number;
  70429. /**
  70430. * Force textures to be a power of two (default: false)
  70431. */
  70432. alwaysForcePOT: boolean;
  70433. private _samples;
  70434. /**
  70435. * Number of sample textures (default: 1)
  70436. */
  70437. samples: number;
  70438. /**
  70439. * Modify the scale of the post process to be the same as the viewport (default: false)
  70440. */
  70441. adaptScaleToCurrentViewport: boolean;
  70442. private _camera;
  70443. private _scene;
  70444. private _engine;
  70445. private _options;
  70446. private _reusable;
  70447. private _textureType;
  70448. /**
  70449. * Smart array of input and output textures for the post process.
  70450. * @hidden
  70451. */
  70452. _textures: SmartArray<InternalTexture>;
  70453. /**
  70454. * The index in _textures that corresponds to the output texture.
  70455. * @hidden
  70456. */
  70457. _currentRenderTextureInd: number;
  70458. private _effect;
  70459. private _samplers;
  70460. private _fragmentUrl;
  70461. private _vertexUrl;
  70462. private _parameters;
  70463. private _scaleRatio;
  70464. protected _indexParameters: any;
  70465. private _shareOutputWithPostProcess;
  70466. private _texelSize;
  70467. private _forcedOutputTexture;
  70468. /**
  70469. * Returns the fragment url or shader name used in the post process.
  70470. * @returns the fragment url or name in the shader store.
  70471. */
  70472. getEffectName(): string;
  70473. /**
  70474. * An event triggered when the postprocess is activated.
  70475. */
  70476. onActivateObservable: Observable<Camera>;
  70477. private _onActivateObserver;
  70478. /**
  70479. * A function that is added to the onActivateObservable
  70480. */
  70481. onActivate: Nullable<(camera: Camera) => void>;
  70482. /**
  70483. * An event triggered when the postprocess changes its size.
  70484. */
  70485. onSizeChangedObservable: Observable<PostProcess>;
  70486. private _onSizeChangedObserver;
  70487. /**
  70488. * A function that is added to the onSizeChangedObservable
  70489. */
  70490. onSizeChanged: (postProcess: PostProcess) => void;
  70491. /**
  70492. * An event triggered when the postprocess applies its effect.
  70493. */
  70494. onApplyObservable: Observable<Effect>;
  70495. private _onApplyObserver;
  70496. /**
  70497. * A function that is added to the onApplyObservable
  70498. */
  70499. onApply: (effect: Effect) => void;
  70500. /**
  70501. * An event triggered before rendering the postprocess
  70502. */
  70503. onBeforeRenderObservable: Observable<Effect>;
  70504. private _onBeforeRenderObserver;
  70505. /**
  70506. * A function that is added to the onBeforeRenderObservable
  70507. */
  70508. onBeforeRender: (effect: Effect) => void;
  70509. /**
  70510. * An event triggered after rendering the postprocess
  70511. */
  70512. onAfterRenderObservable: Observable<Effect>;
  70513. private _onAfterRenderObserver;
  70514. /**
  70515. * A function that is added to the onAfterRenderObservable
  70516. */
  70517. onAfterRender: (efect: Effect) => void;
  70518. /**
  70519. * 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
  70520. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  70521. */
  70522. inputTexture: InternalTexture;
  70523. /**
  70524. * Gets the camera which post process is applied to.
  70525. * @returns The camera the post process is applied to.
  70526. */
  70527. getCamera(): Camera;
  70528. /**
  70529. * Gets the texel size of the postprocess.
  70530. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  70531. */
  70532. readonly texelSize: Vector2;
  70533. /**
  70534. * Creates a new instance PostProcess
  70535. * @param name The name of the PostProcess.
  70536. * @param fragmentUrl The url of the fragment shader to be used.
  70537. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  70538. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  70539. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  70540. * @param camera The camera to apply the render pass to.
  70541. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70542. * @param engine The engine which the post process will be applied. (default: current engine)
  70543. * @param reusable If the post process can be reused on the same frame. (default: false)
  70544. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  70545. * @param textureType Type of textures used when performing the post process. (default: 0)
  70546. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  70547. * @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
  70548. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  70549. */
  70550. constructor(
  70551. /** Name of the PostProcess. */
  70552. 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);
  70553. /**
  70554. * Gets a string idenfifying the name of the class
  70555. * @returns "PostProcess" string
  70556. */
  70557. getClassName(): string;
  70558. /**
  70559. * Gets the engine which this post process belongs to.
  70560. * @returns The engine the post process was enabled with.
  70561. */
  70562. getEngine(): Engine;
  70563. /**
  70564. * The effect that is created when initializing the post process.
  70565. * @returns The created effect corrisponding the the postprocess.
  70566. */
  70567. getEffect(): Effect;
  70568. /**
  70569. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  70570. * @param postProcess The post process to share the output with.
  70571. * @returns This post process.
  70572. */
  70573. shareOutputWith(postProcess: PostProcess): PostProcess;
  70574. /**
  70575. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  70576. * This should be called if the post process that shares output with this post process is disabled/disposed.
  70577. */
  70578. useOwnOutput(): void;
  70579. /**
  70580. * Updates the effect with the current post process compile time values and recompiles the shader.
  70581. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70582. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70583. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70584. * @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
  70585. * @param onCompiled Called when the shader has been compiled.
  70586. * @param onError Called if there is an error when compiling a shader.
  70587. */
  70588. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70589. /**
  70590. * The post process is reusable if it can be used multiple times within one frame.
  70591. * @returns If the post process is reusable
  70592. */
  70593. isReusable(): boolean;
  70594. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  70595. markTextureDirty(): void;
  70596. /**
  70597. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  70598. * 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.
  70599. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  70600. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  70601. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  70602. * @returns The target texture that was bound to be written to.
  70603. */
  70604. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  70605. /**
  70606. * If the post process is supported.
  70607. */
  70608. readonly isSupported: boolean;
  70609. /**
  70610. * The aspect ratio of the output texture.
  70611. */
  70612. readonly aspectRatio: number;
  70613. /**
  70614. * Get a value indicating if the post-process is ready to be used
  70615. * @returns true if the post-process is ready (shader is compiled)
  70616. */
  70617. isReady(): boolean;
  70618. /**
  70619. * Binds all textures and uniforms to the shader, this will be run on every pass.
  70620. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  70621. */
  70622. apply(): Nullable<Effect>;
  70623. private _disposeTextures;
  70624. /**
  70625. * Disposes the post process.
  70626. * @param camera The camera to dispose the post process on.
  70627. */
  70628. dispose(camera?: Camera): void;
  70629. }
  70630. }
  70631. declare module BABYLON {
  70632. /**
  70633. * PostProcessManager is used to manage one or more post processes or post process pipelines
  70634. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70635. */
  70636. export class PostProcessManager {
  70637. private _scene;
  70638. private _indexBuffer;
  70639. private _vertexBuffers;
  70640. /**
  70641. * Creates a new instance PostProcess
  70642. * @param scene The scene that the post process is associated with.
  70643. */
  70644. constructor(scene: Scene);
  70645. private _prepareBuffers;
  70646. private _buildIndexBuffer;
  70647. /**
  70648. * Rebuilds the vertex buffers of the manager.
  70649. * @hidden
  70650. */
  70651. _rebuild(): void;
  70652. /**
  70653. * Prepares a frame to be run through a post process.
  70654. * @param sourceTexture The input texture to the post procesess. (default: null)
  70655. * @param postProcesses An array of post processes to be run. (default: null)
  70656. * @returns True if the post processes were able to be run.
  70657. * @hidden
  70658. */
  70659. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  70660. /**
  70661. * Manually render a set of post processes to a texture.
  70662. * @param postProcesses An array of post processes to be run.
  70663. * @param targetTexture The target texture to render to.
  70664. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  70665. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  70666. * @param lodLevel defines which lod of the texture to render to
  70667. */
  70668. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  70669. /**
  70670. * Finalize the result of the output of the postprocesses.
  70671. * @param doNotPresent If true the result will not be displayed to the screen.
  70672. * @param targetTexture The target texture to render to.
  70673. * @param faceIndex The index of the face to bind the target texture to.
  70674. * @param postProcesses The array of post processes to render.
  70675. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  70676. * @hidden
  70677. */
  70678. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  70679. /**
  70680. * Disposes of the post process manager.
  70681. */
  70682. dispose(): void;
  70683. }
  70684. }
  70685. declare module BABYLON {
  70686. interface AbstractScene {
  70687. /**
  70688. * The list of layers (background and foreground) of the scene
  70689. */
  70690. layers: Array<Layer>;
  70691. }
  70692. /**
  70693. * Defines the layer scene component responsible to manage any layers
  70694. * in a given scene.
  70695. */
  70696. export class LayerSceneComponent implements ISceneComponent {
  70697. /**
  70698. * The component name helpfull to identify the component in the list of scene components.
  70699. */
  70700. readonly name: string;
  70701. /**
  70702. * The scene the component belongs to.
  70703. */
  70704. scene: Scene;
  70705. private _engine;
  70706. /**
  70707. * Creates a new instance of the component for the given scene
  70708. * @param scene Defines the scene to register the component in
  70709. */
  70710. constructor(scene: Scene);
  70711. /**
  70712. * Registers the component in a given scene
  70713. */
  70714. register(): void;
  70715. /**
  70716. * Rebuilds the elements related to this component in case of
  70717. * context lost for instance.
  70718. */
  70719. rebuild(): void;
  70720. /**
  70721. * Disposes the component and the associated ressources.
  70722. */
  70723. dispose(): void;
  70724. private _draw;
  70725. private _drawCameraPredicate;
  70726. private _drawCameraBackground;
  70727. private _drawCameraForeground;
  70728. private _drawRenderTargetPredicate;
  70729. private _drawRenderTargetBackground;
  70730. private _drawRenderTargetForeground;
  70731. }
  70732. }
  70733. declare module BABYLON {
  70734. /** @hidden */
  70735. export var layerPixelShader: {
  70736. name: string;
  70737. shader: string;
  70738. };
  70739. }
  70740. declare module BABYLON {
  70741. /** @hidden */
  70742. export var layerVertexShader: {
  70743. name: string;
  70744. shader: string;
  70745. };
  70746. }
  70747. declare module BABYLON {
  70748. /**
  70749. * This represents a full screen 2d layer.
  70750. * This can be useful to display a picture in the background of your scene for instance.
  70751. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70752. */
  70753. export class Layer {
  70754. /**
  70755. * Define the name of the layer.
  70756. */
  70757. name: string;
  70758. /**
  70759. * Define the texture the layer should display.
  70760. */
  70761. texture: Nullable<Texture>;
  70762. /**
  70763. * Is the layer in background or foreground.
  70764. */
  70765. isBackground: boolean;
  70766. /**
  70767. * Define the color of the layer (instead of texture).
  70768. */
  70769. color: Color4;
  70770. /**
  70771. * Define the scale of the layer in order to zoom in out of the texture.
  70772. */
  70773. scale: Vector2;
  70774. /**
  70775. * Define an offset for the layer in order to shift the texture.
  70776. */
  70777. offset: Vector2;
  70778. /**
  70779. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  70780. */
  70781. alphaBlendingMode: number;
  70782. /**
  70783. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  70784. * Alpha test will not mix with the background color in case of transparency.
  70785. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  70786. */
  70787. alphaTest: boolean;
  70788. /**
  70789. * Define a mask to restrict the layer to only some of the scene cameras.
  70790. */
  70791. layerMask: number;
  70792. /**
  70793. * Define the list of render target the layer is visible into.
  70794. */
  70795. renderTargetTextures: RenderTargetTexture[];
  70796. /**
  70797. * Define if the layer is only used in renderTarget or if it also
  70798. * renders in the main frame buffer of the canvas.
  70799. */
  70800. renderOnlyInRenderTargetTextures: boolean;
  70801. private _scene;
  70802. private _vertexBuffers;
  70803. private _indexBuffer;
  70804. private _effect;
  70805. private _alphaTestEffect;
  70806. /**
  70807. * An event triggered when the layer is disposed.
  70808. */
  70809. onDisposeObservable: Observable<Layer>;
  70810. private _onDisposeObserver;
  70811. /**
  70812. * Back compatibility with callback before the onDisposeObservable existed.
  70813. * The set callback will be triggered when the layer has been disposed.
  70814. */
  70815. onDispose: () => void;
  70816. /**
  70817. * An event triggered before rendering the scene
  70818. */
  70819. onBeforeRenderObservable: Observable<Layer>;
  70820. private _onBeforeRenderObserver;
  70821. /**
  70822. * Back compatibility with callback before the onBeforeRenderObservable existed.
  70823. * The set callback will be triggered just before rendering the layer.
  70824. */
  70825. onBeforeRender: () => void;
  70826. /**
  70827. * An event triggered after rendering the scene
  70828. */
  70829. onAfterRenderObservable: Observable<Layer>;
  70830. private _onAfterRenderObserver;
  70831. /**
  70832. * Back compatibility with callback before the onAfterRenderObservable existed.
  70833. * The set callback will be triggered just after rendering the layer.
  70834. */
  70835. onAfterRender: () => void;
  70836. /**
  70837. * Instantiates a new layer.
  70838. * This represents a full screen 2d layer.
  70839. * This can be useful to display a picture in the background of your scene for instance.
  70840. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70841. * @param name Define the name of the layer in the scene
  70842. * @param imgUrl Define the url of the texture to display in the layer
  70843. * @param scene Define the scene the layer belongs to
  70844. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  70845. * @param color Defines a color for the layer
  70846. */
  70847. constructor(
  70848. /**
  70849. * Define the name of the layer.
  70850. */
  70851. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  70852. private _createIndexBuffer;
  70853. /** @hidden */
  70854. _rebuild(): void;
  70855. /**
  70856. * Renders the layer in the scene.
  70857. */
  70858. render(): void;
  70859. /**
  70860. * Disposes and releases the associated ressources.
  70861. */
  70862. dispose(): void;
  70863. }
  70864. }
  70865. declare module BABYLON {
  70866. interface AbstractScene {
  70867. /**
  70868. * The list of procedural textures added to the scene
  70869. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70870. */
  70871. proceduralTextures: Array<ProceduralTexture>;
  70872. }
  70873. /**
  70874. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  70875. * in a given scene.
  70876. */
  70877. export class ProceduralTextureSceneComponent implements ISceneComponent {
  70878. /**
  70879. * The component name helpfull to identify the component in the list of scene components.
  70880. */
  70881. readonly name: string;
  70882. /**
  70883. * The scene the component belongs to.
  70884. */
  70885. scene: Scene;
  70886. /**
  70887. * Creates a new instance of the component for the given scene
  70888. * @param scene Defines the scene to register the component in
  70889. */
  70890. constructor(scene: Scene);
  70891. /**
  70892. * Registers the component in a given scene
  70893. */
  70894. register(): void;
  70895. /**
  70896. * Rebuilds the elements related to this component in case of
  70897. * context lost for instance.
  70898. */
  70899. rebuild(): void;
  70900. /**
  70901. * Disposes the component and the associated ressources.
  70902. */
  70903. dispose(): void;
  70904. private _beforeClear;
  70905. }
  70906. }
  70907. declare module BABYLON {
  70908. /** @hidden */
  70909. export var proceduralVertexShader: {
  70910. name: string;
  70911. shader: string;
  70912. };
  70913. }
  70914. declare module BABYLON {
  70915. /**
  70916. * 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.
  70917. * This is the base class of any Procedural texture and contains most of the shareable code.
  70918. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70919. */
  70920. export class ProceduralTexture extends Texture {
  70921. isCube: boolean;
  70922. /**
  70923. * Define if the texture is enabled or not (disabled texture will not render)
  70924. */
  70925. isEnabled: boolean;
  70926. /**
  70927. * Define if the texture must be cleared before rendering (default is true)
  70928. */
  70929. autoClear: boolean;
  70930. /**
  70931. * Callback called when the texture is generated
  70932. */
  70933. onGenerated: () => void;
  70934. /**
  70935. * Event raised when the texture is generated
  70936. */
  70937. onGeneratedObservable: Observable<ProceduralTexture>;
  70938. /** @hidden */
  70939. _generateMipMaps: boolean;
  70940. /** @hidden **/
  70941. _effect: Effect;
  70942. /** @hidden */
  70943. _textures: {
  70944. [key: string]: Texture;
  70945. };
  70946. private _size;
  70947. private _currentRefreshId;
  70948. private _refreshRate;
  70949. private _vertexBuffers;
  70950. private _indexBuffer;
  70951. private _uniforms;
  70952. private _samplers;
  70953. private _fragment;
  70954. private _floats;
  70955. private _ints;
  70956. private _floatsArrays;
  70957. private _colors3;
  70958. private _colors4;
  70959. private _vectors2;
  70960. private _vectors3;
  70961. private _matrices;
  70962. private _fallbackTexture;
  70963. private _fallbackTextureUsed;
  70964. private _engine;
  70965. private _cachedDefines;
  70966. private _contentUpdateId;
  70967. private _contentData;
  70968. /**
  70969. * Instantiates a new procedural texture.
  70970. * 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.
  70971. * This is the base class of any Procedural texture and contains most of the shareable code.
  70972. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70973. * @param name Define the name of the texture
  70974. * @param size Define the size of the texture to create
  70975. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  70976. * @param scene Define the scene the texture belongs to
  70977. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  70978. * @param generateMipMaps Define if the texture should creates mip maps or not
  70979. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  70980. */
  70981. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  70982. /**
  70983. * The effect that is created when initializing the post process.
  70984. * @returns The created effect corrisponding the the postprocess.
  70985. */
  70986. getEffect(): Effect;
  70987. /**
  70988. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  70989. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  70990. */
  70991. getContent(): Nullable<ArrayBufferView>;
  70992. private _createIndexBuffer;
  70993. /** @hidden */
  70994. _rebuild(): void;
  70995. /**
  70996. * Resets the texture in order to recreate its associated resources.
  70997. * This can be called in case of context loss
  70998. */
  70999. reset(): void;
  71000. protected _getDefines(): string;
  71001. /**
  71002. * Is the texture ready to be used ? (rendered at least once)
  71003. * @returns true if ready, otherwise, false.
  71004. */
  71005. isReady(): boolean;
  71006. /**
  71007. * Resets the refresh counter of the texture and start bak from scratch.
  71008. * Could be useful to regenerate the texture if it is setup to render only once.
  71009. */
  71010. resetRefreshCounter(): void;
  71011. /**
  71012. * Set the fragment shader to use in order to render the texture.
  71013. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  71014. */
  71015. setFragment(fragment: any): void;
  71016. /**
  71017. * Define the refresh rate of the texture or the rendering frequency.
  71018. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  71019. */
  71020. refreshRate: number;
  71021. /** @hidden */
  71022. _shouldRender(): boolean;
  71023. /**
  71024. * Get the size the texture is rendering at.
  71025. * @returns the size (texture is always squared)
  71026. */
  71027. getRenderSize(): number;
  71028. /**
  71029. * Resize the texture to new value.
  71030. * @param size Define the new size the texture should have
  71031. * @param generateMipMaps Define whether the new texture should create mip maps
  71032. */
  71033. resize(size: number, generateMipMaps: boolean): void;
  71034. private _checkUniform;
  71035. /**
  71036. * Set a texture in the shader program used to render.
  71037. * @param name Define the name of the uniform samplers as defined in the shader
  71038. * @param texture Define the texture to bind to this sampler
  71039. * @return the texture itself allowing "fluent" like uniform updates
  71040. */
  71041. setTexture(name: string, texture: Texture): ProceduralTexture;
  71042. /**
  71043. * Set a float in the shader.
  71044. * @param name Define the name of the uniform as defined in the shader
  71045. * @param value Define the value to give to the uniform
  71046. * @return the texture itself allowing "fluent" like uniform updates
  71047. */
  71048. setFloat(name: string, value: number): ProceduralTexture;
  71049. /**
  71050. * Set a int in the shader.
  71051. * @param name Define the name of the uniform as defined in the shader
  71052. * @param value Define the value to give to the uniform
  71053. * @return the texture itself allowing "fluent" like uniform updates
  71054. */
  71055. setInt(name: string, value: number): ProceduralTexture;
  71056. /**
  71057. * Set an array of floats in the shader.
  71058. * @param name Define the name of the uniform as defined in the shader
  71059. * @param value Define the value to give to the uniform
  71060. * @return the texture itself allowing "fluent" like uniform updates
  71061. */
  71062. setFloats(name: string, value: number[]): ProceduralTexture;
  71063. /**
  71064. * Set a vec3 in the shader from a Color3.
  71065. * @param name Define the name of the uniform as defined in the shader
  71066. * @param value Define the value to give to the uniform
  71067. * @return the texture itself allowing "fluent" like uniform updates
  71068. */
  71069. setColor3(name: string, value: Color3): ProceduralTexture;
  71070. /**
  71071. * Set a vec4 in the shader from a Color4.
  71072. * @param name Define the name of the uniform as defined in the shader
  71073. * @param value Define the value to give to the uniform
  71074. * @return the texture itself allowing "fluent" like uniform updates
  71075. */
  71076. setColor4(name: string, value: Color4): ProceduralTexture;
  71077. /**
  71078. * Set a vec2 in the shader from a Vector2.
  71079. * @param name Define the name of the uniform as defined in the shader
  71080. * @param value Define the value to give to the uniform
  71081. * @return the texture itself allowing "fluent" like uniform updates
  71082. */
  71083. setVector2(name: string, value: Vector2): ProceduralTexture;
  71084. /**
  71085. * Set a vec3 in the shader from a Vector3.
  71086. * @param name Define the name of the uniform as defined in the shader
  71087. * @param value Define the value to give to the uniform
  71088. * @return the texture itself allowing "fluent" like uniform updates
  71089. */
  71090. setVector3(name: string, value: Vector3): ProceduralTexture;
  71091. /**
  71092. * Set a mat4 in the shader from a MAtrix.
  71093. * @param name Define the name of the uniform as defined in the shader
  71094. * @param value Define the value to give to the uniform
  71095. * @return the texture itself allowing "fluent" like uniform updates
  71096. */
  71097. setMatrix(name: string, value: Matrix): ProceduralTexture;
  71098. /**
  71099. * Render the texture to its associated render target.
  71100. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  71101. */
  71102. render(useCameraPostProcess?: boolean): void;
  71103. /**
  71104. * Clone the texture.
  71105. * @returns the cloned texture
  71106. */
  71107. clone(): ProceduralTexture;
  71108. /**
  71109. * Dispose the texture and release its asoociated resources.
  71110. */
  71111. dispose(): void;
  71112. }
  71113. }
  71114. declare module BABYLON {
  71115. /**
  71116. * This represents the base class for particle system in Babylon.
  71117. * 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.
  71118. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71119. * @example https://doc.babylonjs.com/babylon101/particles
  71120. */
  71121. export class BaseParticleSystem {
  71122. /**
  71123. * Source color is added to the destination color without alpha affecting the result
  71124. */
  71125. static BLENDMODE_ONEONE: number;
  71126. /**
  71127. * Blend current color and particle color using particle’s alpha
  71128. */
  71129. static BLENDMODE_STANDARD: number;
  71130. /**
  71131. * Add current color and particle color multiplied by particle’s alpha
  71132. */
  71133. static BLENDMODE_ADD: number;
  71134. /**
  71135. * Multiply current color with particle color
  71136. */
  71137. static BLENDMODE_MULTIPLY: number;
  71138. /**
  71139. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  71140. */
  71141. static BLENDMODE_MULTIPLYADD: number;
  71142. /**
  71143. * List of animations used by the particle system.
  71144. */
  71145. animations: Animation[];
  71146. /**
  71147. * The id of the Particle system.
  71148. */
  71149. id: string;
  71150. /**
  71151. * The friendly name of the Particle system.
  71152. */
  71153. name: string;
  71154. /**
  71155. * The rendering group used by the Particle system to chose when to render.
  71156. */
  71157. renderingGroupId: number;
  71158. /**
  71159. * The emitter represents the Mesh or position we are attaching the particle system to.
  71160. */
  71161. emitter: Nullable<AbstractMesh | Vector3>;
  71162. /**
  71163. * The maximum number of particles to emit per frame
  71164. */
  71165. emitRate: number;
  71166. /**
  71167. * If you want to launch only a few particles at once, that can be done, as well.
  71168. */
  71169. manualEmitCount: number;
  71170. /**
  71171. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  71172. */
  71173. updateSpeed: number;
  71174. /**
  71175. * The amount of time the particle system is running (depends of the overall update speed).
  71176. */
  71177. targetStopDuration: number;
  71178. /**
  71179. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  71180. */
  71181. disposeOnStop: boolean;
  71182. /**
  71183. * Minimum power of emitting particles.
  71184. */
  71185. minEmitPower: number;
  71186. /**
  71187. * Maximum power of emitting particles.
  71188. */
  71189. maxEmitPower: number;
  71190. /**
  71191. * Minimum life time of emitting particles.
  71192. */
  71193. minLifeTime: number;
  71194. /**
  71195. * Maximum life time of emitting particles.
  71196. */
  71197. maxLifeTime: number;
  71198. /**
  71199. * Minimum Size of emitting particles.
  71200. */
  71201. minSize: number;
  71202. /**
  71203. * Maximum Size of emitting particles.
  71204. */
  71205. maxSize: number;
  71206. /**
  71207. * Minimum scale of emitting particles on X axis.
  71208. */
  71209. minScaleX: number;
  71210. /**
  71211. * Maximum scale of emitting particles on X axis.
  71212. */
  71213. maxScaleX: number;
  71214. /**
  71215. * Minimum scale of emitting particles on Y axis.
  71216. */
  71217. minScaleY: number;
  71218. /**
  71219. * Maximum scale of emitting particles on Y axis.
  71220. */
  71221. maxScaleY: number;
  71222. /**
  71223. * Gets or sets the minimal initial rotation in radians.
  71224. */
  71225. minInitialRotation: number;
  71226. /**
  71227. * Gets or sets the maximal initial rotation in radians.
  71228. */
  71229. maxInitialRotation: number;
  71230. /**
  71231. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  71232. */
  71233. minAngularSpeed: number;
  71234. /**
  71235. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  71236. */
  71237. maxAngularSpeed: number;
  71238. /**
  71239. * The texture used to render each particle. (this can be a spritesheet)
  71240. */
  71241. particleTexture: Nullable<Texture>;
  71242. /**
  71243. * The layer mask we are rendering the particles through.
  71244. */
  71245. layerMask: number;
  71246. /**
  71247. * This can help using your own shader to render the particle system.
  71248. * The according effect will be created
  71249. */
  71250. customShader: any;
  71251. /**
  71252. * By default particle system starts as soon as they are created. This prevents the
  71253. * automatic start to happen and let you decide when to start emitting particles.
  71254. */
  71255. preventAutoStart: boolean;
  71256. private _noiseTexture;
  71257. /**
  71258. * Gets or sets a texture used to add random noise to particle positions
  71259. */
  71260. noiseTexture: Nullable<ProceduralTexture>;
  71261. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  71262. noiseStrength: Vector3;
  71263. /**
  71264. * Callback triggered when the particle animation is ending.
  71265. */
  71266. onAnimationEnd: Nullable<() => void>;
  71267. /**
  71268. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  71269. */
  71270. blendMode: number;
  71271. /**
  71272. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71273. * to override the particles.
  71274. */
  71275. forceDepthWrite: boolean;
  71276. /** 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 */
  71277. preWarmCycles: number;
  71278. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  71279. preWarmStepOffset: number;
  71280. /**
  71281. * 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)
  71282. */
  71283. spriteCellChangeSpeed: number;
  71284. /**
  71285. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  71286. */
  71287. startSpriteCellID: number;
  71288. /**
  71289. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  71290. */
  71291. endSpriteCellID: number;
  71292. /**
  71293. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  71294. */
  71295. spriteCellWidth: number;
  71296. /**
  71297. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  71298. */
  71299. spriteCellHeight: number;
  71300. /**
  71301. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  71302. */
  71303. spriteRandomStartCell: boolean;
  71304. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  71305. translationPivot: Vector2;
  71306. /** @hidden */
  71307. protected _isAnimationSheetEnabled: boolean;
  71308. /**
  71309. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  71310. */
  71311. beginAnimationOnStart: boolean;
  71312. /**
  71313. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  71314. */
  71315. beginAnimationFrom: number;
  71316. /**
  71317. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  71318. */
  71319. beginAnimationTo: number;
  71320. /**
  71321. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  71322. */
  71323. beginAnimationLoop: boolean;
  71324. /**
  71325. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  71326. */
  71327. isAnimationSheetEnabled: boolean;
  71328. /**
  71329. * Get hosting scene
  71330. * @returns the scene
  71331. */
  71332. getScene(): Scene;
  71333. /**
  71334. * You can use gravity if you want to give an orientation to your particles.
  71335. */
  71336. gravity: Vector3;
  71337. protected _colorGradients: Nullable<Array<ColorGradient>>;
  71338. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  71339. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  71340. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  71341. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  71342. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  71343. protected _dragGradients: Nullable<Array<FactorGradient>>;
  71344. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  71345. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  71346. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  71347. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  71348. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  71349. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  71350. /**
  71351. * Defines the delay in milliseconds before starting the system (0 by default)
  71352. */
  71353. startDelay: number;
  71354. /**
  71355. * Gets the current list of drag gradients.
  71356. * You must use addDragGradient and removeDragGradient to udpate this list
  71357. * @returns the list of drag gradients
  71358. */
  71359. getDragGradients(): Nullable<Array<FactorGradient>>;
  71360. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  71361. limitVelocityDamping: number;
  71362. /**
  71363. * Gets the current list of limit velocity gradients.
  71364. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  71365. * @returns the list of limit velocity gradients
  71366. */
  71367. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  71368. /**
  71369. * Gets the current list of color gradients.
  71370. * You must use addColorGradient and removeColorGradient to udpate this list
  71371. * @returns the list of color gradients
  71372. */
  71373. getColorGradients(): Nullable<Array<ColorGradient>>;
  71374. /**
  71375. * Gets the current list of size gradients.
  71376. * You must use addSizeGradient and removeSizeGradient to udpate this list
  71377. * @returns the list of size gradients
  71378. */
  71379. getSizeGradients(): Nullable<Array<FactorGradient>>;
  71380. /**
  71381. * Gets the current list of color remap gradients.
  71382. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  71383. * @returns the list of color remap gradients
  71384. */
  71385. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  71386. /**
  71387. * Gets the current list of alpha remap gradients.
  71388. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  71389. * @returns the list of alpha remap gradients
  71390. */
  71391. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  71392. /**
  71393. * Gets the current list of life time gradients.
  71394. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  71395. * @returns the list of life time gradients
  71396. */
  71397. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  71398. /**
  71399. * Gets the current list of angular speed gradients.
  71400. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  71401. * @returns the list of angular speed gradients
  71402. */
  71403. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  71404. /**
  71405. * Gets the current list of velocity gradients.
  71406. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  71407. * @returns the list of velocity gradients
  71408. */
  71409. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  71410. /**
  71411. * Gets the current list of start size gradients.
  71412. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  71413. * @returns the list of start size gradients
  71414. */
  71415. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  71416. /**
  71417. * Gets the current list of emit rate gradients.
  71418. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  71419. * @returns the list of emit rate gradients
  71420. */
  71421. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  71422. /**
  71423. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71424. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71425. */
  71426. direction1: Vector3;
  71427. /**
  71428. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71429. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71430. */
  71431. direction2: Vector3;
  71432. /**
  71433. * 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.
  71434. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71435. */
  71436. minEmitBox: Vector3;
  71437. /**
  71438. * 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.
  71439. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71440. */
  71441. maxEmitBox: Vector3;
  71442. /**
  71443. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71444. */
  71445. color1: Color4;
  71446. /**
  71447. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71448. */
  71449. color2: Color4;
  71450. /**
  71451. * Color the particle will have at the end of its lifetime
  71452. */
  71453. colorDead: Color4;
  71454. /**
  71455. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  71456. */
  71457. textureMask: Color4;
  71458. /**
  71459. * The particle emitter type defines the emitter used by the particle system.
  71460. * It can be for example box, sphere, or cone...
  71461. */
  71462. particleEmitterType: IParticleEmitterType;
  71463. /** @hidden */
  71464. _isSubEmitter: boolean;
  71465. /**
  71466. * Gets or sets the billboard mode to use when isBillboardBased = true.
  71467. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  71468. */
  71469. billboardMode: number;
  71470. protected _isBillboardBased: boolean;
  71471. /**
  71472. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  71473. */
  71474. isBillboardBased: boolean;
  71475. /**
  71476. * The scene the particle system belongs to.
  71477. */
  71478. protected _scene: Scene;
  71479. /**
  71480. * Local cache of defines for image processing.
  71481. */
  71482. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  71483. /**
  71484. * Default configuration related to image processing available in the standard Material.
  71485. */
  71486. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  71487. /**
  71488. * Gets the image processing configuration used either in this material.
  71489. */
  71490. /**
  71491. * Sets the Default image processing configuration used either in the this material.
  71492. *
  71493. * If sets to null, the scene one is in use.
  71494. */
  71495. imageProcessingConfiguration: ImageProcessingConfiguration;
  71496. /**
  71497. * Attaches a new image processing configuration to the Standard Material.
  71498. * @param configuration
  71499. */
  71500. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  71501. /** @hidden */
  71502. protected _reset(): void;
  71503. /** @hidden */
  71504. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  71505. /**
  71506. * Instantiates a particle system.
  71507. * 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.
  71508. * @param name The name of the particle system
  71509. */
  71510. constructor(name: string);
  71511. /**
  71512. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  71513. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71514. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71515. * @returns the emitter
  71516. */
  71517. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  71518. /**
  71519. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  71520. * @param radius The radius of the hemisphere to emit from
  71521. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71522. * @returns the emitter
  71523. */
  71524. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  71525. /**
  71526. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  71527. * @param radius The radius of the sphere to emit from
  71528. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71529. * @returns the emitter
  71530. */
  71531. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  71532. /**
  71533. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  71534. * @param radius The radius of the sphere to emit from
  71535. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  71536. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  71537. * @returns the emitter
  71538. */
  71539. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  71540. /**
  71541. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  71542. * @param radius The radius of the emission cylinder
  71543. * @param height The height of the emission cylinder
  71544. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  71545. * @param directionRandomizer How much to randomize the particle direction [0-1]
  71546. * @returns the emitter
  71547. */
  71548. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  71549. /**
  71550. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  71551. * @param radius The radius of the cylinder to emit from
  71552. * @param height The height of the emission cylinder
  71553. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71554. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  71555. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  71556. * @returns the emitter
  71557. */
  71558. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  71559. /**
  71560. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  71561. * @param radius The radius of the cone to emit from
  71562. * @param angle The base angle of the cone
  71563. * @returns the emitter
  71564. */
  71565. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  71566. /**
  71567. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  71568. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71569. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71570. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71571. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71572. * @returns the emitter
  71573. */
  71574. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  71575. }
  71576. }
  71577. declare module BABYLON {
  71578. /**
  71579. * Type of sub emitter
  71580. */
  71581. export enum SubEmitterType {
  71582. /**
  71583. * Attached to the particle over it's lifetime
  71584. */
  71585. ATTACHED = 0,
  71586. /**
  71587. * Created when the particle dies
  71588. */
  71589. END = 1
  71590. }
  71591. /**
  71592. * Sub emitter class used to emit particles from an existing particle
  71593. */
  71594. export class SubEmitter {
  71595. /**
  71596. * the particle system to be used by the sub emitter
  71597. */
  71598. particleSystem: ParticleSystem;
  71599. /**
  71600. * Type of the submitter (Default: END)
  71601. */
  71602. type: SubEmitterType;
  71603. /**
  71604. * 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)
  71605. * Note: This only is supported when using an emitter of type Mesh
  71606. */
  71607. inheritDirection: boolean;
  71608. /**
  71609. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  71610. */
  71611. inheritedVelocityAmount: number;
  71612. /**
  71613. * Creates a sub emitter
  71614. * @param particleSystem the particle system to be used by the sub emitter
  71615. */
  71616. constructor(
  71617. /**
  71618. * the particle system to be used by the sub emitter
  71619. */
  71620. particleSystem: ParticleSystem);
  71621. /**
  71622. * Clones the sub emitter
  71623. * @returns the cloned sub emitter
  71624. */
  71625. clone(): SubEmitter;
  71626. /**
  71627. * Serialize current object to a JSON object
  71628. * @returns the serialized object
  71629. */
  71630. serialize(): any;
  71631. /** @hidden */
  71632. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  71633. /**
  71634. * Creates a new SubEmitter from a serialized JSON version
  71635. * @param serializationObject defines the JSON object to read from
  71636. * @param scene defines the hosting scene
  71637. * @param rootUrl defines the rootUrl for data loading
  71638. * @returns a new SubEmitter
  71639. */
  71640. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  71641. /** Release associated resources */
  71642. dispose(): void;
  71643. }
  71644. }
  71645. declare module BABYLON {
  71646. /** @hidden */
  71647. export var clipPlaneFragmentDeclaration: {
  71648. name: string;
  71649. shader: string;
  71650. };
  71651. }
  71652. declare module BABYLON {
  71653. /** @hidden */
  71654. export var imageProcessingDeclaration: {
  71655. name: string;
  71656. shader: string;
  71657. };
  71658. }
  71659. declare module BABYLON {
  71660. /** @hidden */
  71661. export var imageProcessingFunctions: {
  71662. name: string;
  71663. shader: string;
  71664. };
  71665. }
  71666. declare module BABYLON {
  71667. /** @hidden */
  71668. export var clipPlaneFragment: {
  71669. name: string;
  71670. shader: string;
  71671. };
  71672. }
  71673. declare module BABYLON {
  71674. /** @hidden */
  71675. export var particlesPixelShader: {
  71676. name: string;
  71677. shader: string;
  71678. };
  71679. }
  71680. declare module BABYLON {
  71681. /** @hidden */
  71682. export var clipPlaneVertexDeclaration: {
  71683. name: string;
  71684. shader: string;
  71685. };
  71686. }
  71687. declare module BABYLON {
  71688. /** @hidden */
  71689. export var clipPlaneVertex: {
  71690. name: string;
  71691. shader: string;
  71692. };
  71693. }
  71694. declare module BABYLON {
  71695. /** @hidden */
  71696. export var particlesVertexShader: {
  71697. name: string;
  71698. shader: string;
  71699. };
  71700. }
  71701. declare module BABYLON {
  71702. /**
  71703. * This represents a particle system in Babylon.
  71704. * 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.
  71705. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71706. * @example https://doc.babylonjs.com/babylon101/particles
  71707. */
  71708. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  71709. /**
  71710. * Billboard mode will only apply to Y axis
  71711. */
  71712. static readonly BILLBOARDMODE_Y: number;
  71713. /**
  71714. * Billboard mode will apply to all axes
  71715. */
  71716. static readonly BILLBOARDMODE_ALL: number;
  71717. /**
  71718. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71719. */
  71720. static readonly BILLBOARDMODE_STRETCHED: number;
  71721. /**
  71722. * This function can be defined to provide custom update for active particles.
  71723. * This function will be called instead of regular update (age, position, color, etc.).
  71724. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  71725. */
  71726. updateFunction: (particles: Particle[]) => void;
  71727. private _emitterWorldMatrix;
  71728. /**
  71729. * This function can be defined to specify initial direction for every new particle.
  71730. * It by default use the emitterType defined function
  71731. */
  71732. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  71733. /**
  71734. * This function can be defined to specify initial position for every new particle.
  71735. * It by default use the emitterType defined function
  71736. */
  71737. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  71738. /**
  71739. * @hidden
  71740. */
  71741. _inheritedVelocityOffset: Vector3;
  71742. /**
  71743. * An event triggered when the system is disposed
  71744. */
  71745. onDisposeObservable: Observable<ParticleSystem>;
  71746. private _onDisposeObserver;
  71747. /**
  71748. * Sets a callback that will be triggered when the system is disposed
  71749. */
  71750. onDispose: () => void;
  71751. private _particles;
  71752. private _epsilon;
  71753. private _capacity;
  71754. private _stockParticles;
  71755. private _newPartsExcess;
  71756. private _vertexData;
  71757. private _vertexBuffer;
  71758. private _vertexBuffers;
  71759. private _spriteBuffer;
  71760. private _indexBuffer;
  71761. private _effect;
  71762. private _customEffect;
  71763. private _cachedDefines;
  71764. private _scaledColorStep;
  71765. private _colorDiff;
  71766. private _scaledDirection;
  71767. private _scaledGravity;
  71768. private _currentRenderId;
  71769. private _alive;
  71770. private _useInstancing;
  71771. private _started;
  71772. private _stopped;
  71773. private _actualFrame;
  71774. private _scaledUpdateSpeed;
  71775. private _vertexBufferSize;
  71776. /** @hidden */
  71777. _currentEmitRateGradient: Nullable<FactorGradient>;
  71778. /** @hidden */
  71779. _currentEmitRate1: number;
  71780. /** @hidden */
  71781. _currentEmitRate2: number;
  71782. /** @hidden */
  71783. _currentStartSizeGradient: Nullable<FactorGradient>;
  71784. /** @hidden */
  71785. _currentStartSize1: number;
  71786. /** @hidden */
  71787. _currentStartSize2: number;
  71788. private readonly _rawTextureWidth;
  71789. private _rampGradientsTexture;
  71790. private _useRampGradients;
  71791. /** Gets or sets a boolean indicating that ramp gradients must be used
  71792. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71793. */
  71794. useRampGradients: boolean;
  71795. /**
  71796. * 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.
  71797. * 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: [])
  71798. */
  71799. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  71800. private _subEmitters;
  71801. /**
  71802. * @hidden
  71803. * If the particle systems emitter should be disposed when the particle system is disposed
  71804. */
  71805. _disposeEmitterOnDispose: boolean;
  71806. /**
  71807. * The current active Sub-systems, this property is used by the root particle system only.
  71808. */
  71809. activeSubSystems: Array<ParticleSystem>;
  71810. private _rootParticleSystem;
  71811. /**
  71812. * Gets the current list of active particles
  71813. */
  71814. readonly particles: Particle[];
  71815. /**
  71816. * Returns the string "ParticleSystem"
  71817. * @returns a string containing the class name
  71818. */
  71819. getClassName(): string;
  71820. /**
  71821. * Instantiates a particle system.
  71822. * 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.
  71823. * @param name The name of the particle system
  71824. * @param capacity The max number of particles alive at the same time
  71825. * @param scene The scene the particle system belongs to
  71826. * @param customEffect a custom effect used to change the way particles are rendered by default
  71827. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71828. * @param epsilon Offset used to render the particles
  71829. */
  71830. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  71831. private _addFactorGradient;
  71832. private _removeFactorGradient;
  71833. /**
  71834. * Adds a new life time gradient
  71835. * @param gradient defines the gradient to use (between 0 and 1)
  71836. * @param factor defines the life time factor to affect to the specified gradient
  71837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71838. * @returns the current particle system
  71839. */
  71840. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71841. /**
  71842. * Remove a specific life time gradient
  71843. * @param gradient defines the gradient to remove
  71844. * @returns the current particle system
  71845. */
  71846. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71847. /**
  71848. * Adds a new size gradient
  71849. * @param gradient defines the gradient to use (between 0 and 1)
  71850. * @param factor defines the size factor to affect to the specified gradient
  71851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71852. * @returns the current particle system
  71853. */
  71854. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71855. /**
  71856. * Remove a specific size gradient
  71857. * @param gradient defines the gradient to remove
  71858. * @returns the current particle system
  71859. */
  71860. removeSizeGradient(gradient: number): IParticleSystem;
  71861. /**
  71862. * Adds a new color remap gradient
  71863. * @param gradient defines the gradient to use (between 0 and 1)
  71864. * @param min defines the color remap minimal range
  71865. * @param max defines the color remap maximal range
  71866. * @returns the current particle system
  71867. */
  71868. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71869. /**
  71870. * Remove a specific color remap gradient
  71871. * @param gradient defines the gradient to remove
  71872. * @returns the current particle system
  71873. */
  71874. removeColorRemapGradient(gradient: number): IParticleSystem;
  71875. /**
  71876. * Adds a new alpha remap gradient
  71877. * @param gradient defines the gradient to use (between 0 and 1)
  71878. * @param min defines the alpha remap minimal range
  71879. * @param max defines the alpha remap maximal range
  71880. * @returns the current particle system
  71881. */
  71882. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71883. /**
  71884. * Remove a specific alpha remap gradient
  71885. * @param gradient defines the gradient to remove
  71886. * @returns the current particle system
  71887. */
  71888. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  71889. /**
  71890. * Adds a new angular speed gradient
  71891. * @param gradient defines the gradient to use (between 0 and 1)
  71892. * @param factor defines the angular speed to affect to the specified gradient
  71893. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71894. * @returns the current particle system
  71895. */
  71896. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71897. /**
  71898. * Remove a specific angular speed gradient
  71899. * @param gradient defines the gradient to remove
  71900. * @returns the current particle system
  71901. */
  71902. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  71903. /**
  71904. * Adds a new velocity gradient
  71905. * @param gradient defines the gradient to use (between 0 and 1)
  71906. * @param factor defines the velocity to affect to the specified gradient
  71907. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71908. * @returns the current particle system
  71909. */
  71910. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71911. /**
  71912. * Remove a specific velocity gradient
  71913. * @param gradient defines the gradient to remove
  71914. * @returns the current particle system
  71915. */
  71916. removeVelocityGradient(gradient: number): IParticleSystem;
  71917. /**
  71918. * Adds a new limit velocity gradient
  71919. * @param gradient defines the gradient to use (between 0 and 1)
  71920. * @param factor defines the limit velocity value to affect to the specified gradient
  71921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71922. * @returns the current particle system
  71923. */
  71924. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71925. /**
  71926. * Remove a specific limit velocity gradient
  71927. * @param gradient defines the gradient to remove
  71928. * @returns the current particle system
  71929. */
  71930. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  71931. /**
  71932. * Adds a new drag gradient
  71933. * @param gradient defines the gradient to use (between 0 and 1)
  71934. * @param factor defines the drag value to affect to the specified gradient
  71935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71936. * @returns the current particle system
  71937. */
  71938. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71939. /**
  71940. * Remove a specific drag gradient
  71941. * @param gradient defines the gradient to remove
  71942. * @returns the current particle system
  71943. */
  71944. removeDragGradient(gradient: number): IParticleSystem;
  71945. /**
  71946. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  71947. * @param gradient defines the gradient to use (between 0 and 1)
  71948. * @param factor defines the emit rate value to affect to the specified gradient
  71949. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71950. * @returns the current particle system
  71951. */
  71952. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71953. /**
  71954. * Remove a specific emit rate gradient
  71955. * @param gradient defines the gradient to remove
  71956. * @returns the current particle system
  71957. */
  71958. removeEmitRateGradient(gradient: number): IParticleSystem;
  71959. /**
  71960. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  71961. * @param gradient defines the gradient to use (between 0 and 1)
  71962. * @param factor defines the start size value to affect to the specified gradient
  71963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71964. * @returns the current particle system
  71965. */
  71966. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71967. /**
  71968. * Remove a specific start size gradient
  71969. * @param gradient defines the gradient to remove
  71970. * @returns the current particle system
  71971. */
  71972. removeStartSizeGradient(gradient: number): IParticleSystem;
  71973. private _createRampGradientTexture;
  71974. /**
  71975. * Gets the current list of ramp gradients.
  71976. * You must use addRampGradient and removeRampGradient to udpate this list
  71977. * @returns the list of ramp gradients
  71978. */
  71979. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71980. /**
  71981. * Adds a new ramp gradient used to remap particle colors
  71982. * @param gradient defines the gradient to use (between 0 and 1)
  71983. * @param color defines the color to affect to the specified gradient
  71984. * @returns the current particle system
  71985. */
  71986. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  71987. /**
  71988. * Remove a specific ramp gradient
  71989. * @param gradient defines the gradient to remove
  71990. * @returns the current particle system
  71991. */
  71992. removeRampGradient(gradient: number): ParticleSystem;
  71993. /**
  71994. * Adds a new color gradient
  71995. * @param gradient defines the gradient to use (between 0 and 1)
  71996. * @param color1 defines the color to affect to the specified gradient
  71997. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71998. * @returns this particle system
  71999. */
  72000. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72001. /**
  72002. * Remove a specific color gradient
  72003. * @param gradient defines the gradient to remove
  72004. * @returns this particle system
  72005. */
  72006. removeColorGradient(gradient: number): IParticleSystem;
  72007. private _fetchR;
  72008. protected _reset(): void;
  72009. private _resetEffect;
  72010. private _createVertexBuffers;
  72011. private _createIndexBuffer;
  72012. /**
  72013. * Gets the maximum number of particles active at the same time.
  72014. * @returns The max number of active particles.
  72015. */
  72016. getCapacity(): number;
  72017. /**
  72018. * Gets whether there are still active particles in the system.
  72019. * @returns True if it is alive, otherwise false.
  72020. */
  72021. isAlive(): boolean;
  72022. /**
  72023. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72024. * @returns True if it has been started, otherwise false.
  72025. */
  72026. isStarted(): boolean;
  72027. private _prepareSubEmitterInternalArray;
  72028. /**
  72029. * Starts the particle system and begins to emit
  72030. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72031. */
  72032. start(delay?: number): void;
  72033. /**
  72034. * Stops the particle system.
  72035. * @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.
  72036. */
  72037. stop(stopSubEmitters?: boolean): void;
  72038. /**
  72039. * Remove all active particles
  72040. */
  72041. reset(): void;
  72042. /**
  72043. * @hidden (for internal use only)
  72044. */
  72045. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  72046. /**
  72047. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  72048. * Its lifetime will start back at 0.
  72049. */
  72050. recycleParticle: (particle: Particle) => void;
  72051. private _stopSubEmitters;
  72052. private _createParticle;
  72053. private _removeFromRoot;
  72054. private _emitFromParticle;
  72055. private _update;
  72056. /** @hidden */
  72057. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  72058. /** @hidden */
  72059. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  72060. /** @hidden */
  72061. private _getEffect;
  72062. /**
  72063. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72064. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  72065. */
  72066. animate(preWarmOnly?: boolean): void;
  72067. private _appendParticleVertices;
  72068. /**
  72069. * Rebuilds the particle system.
  72070. */
  72071. rebuild(): void;
  72072. /**
  72073. * Is this system ready to be used/rendered
  72074. * @return true if the system is ready
  72075. */
  72076. isReady(): boolean;
  72077. private _render;
  72078. /**
  72079. * Renders the particle system in its current state.
  72080. * @returns the current number of particles
  72081. */
  72082. render(): number;
  72083. /**
  72084. * Disposes the particle system and free the associated resources
  72085. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72086. */
  72087. dispose(disposeTexture?: boolean): void;
  72088. /**
  72089. * Clones the particle system.
  72090. * @param name The name of the cloned object
  72091. * @param newEmitter The new emitter to use
  72092. * @returns the cloned particle system
  72093. */
  72094. clone(name: string, newEmitter: any): ParticleSystem;
  72095. /**
  72096. * Serializes the particle system to a JSON object.
  72097. * @returns the JSON object
  72098. */
  72099. serialize(): any;
  72100. /** @hidden */
  72101. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  72102. /** @hidden */
  72103. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  72104. /**
  72105. * Parses a JSON object to create a particle system.
  72106. * @param parsedParticleSystem The JSON object to parse
  72107. * @param scene The scene to create the particle system in
  72108. * @param rootUrl The root url to use to load external dependencies like texture
  72109. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72110. * @returns the Parsed particle system
  72111. */
  72112. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  72113. }
  72114. }
  72115. declare module BABYLON {
  72116. /**
  72117. * A particle represents one of the element emitted by a particle system.
  72118. * This is mainly define by its coordinates, direction, velocity and age.
  72119. */
  72120. export class Particle {
  72121. /**
  72122. * The particle system the particle belongs to.
  72123. */
  72124. particleSystem: ParticleSystem;
  72125. private static _Count;
  72126. /**
  72127. * Unique ID of the particle
  72128. */
  72129. id: number;
  72130. /**
  72131. * The world position of the particle in the scene.
  72132. */
  72133. position: Vector3;
  72134. /**
  72135. * The world direction of the particle in the scene.
  72136. */
  72137. direction: Vector3;
  72138. /**
  72139. * The color of the particle.
  72140. */
  72141. color: Color4;
  72142. /**
  72143. * The color change of the particle per step.
  72144. */
  72145. colorStep: Color4;
  72146. /**
  72147. * Defines how long will the life of the particle be.
  72148. */
  72149. lifeTime: number;
  72150. /**
  72151. * The current age of the particle.
  72152. */
  72153. age: number;
  72154. /**
  72155. * The current size of the particle.
  72156. */
  72157. size: number;
  72158. /**
  72159. * The current scale of the particle.
  72160. */
  72161. scale: Vector2;
  72162. /**
  72163. * The current angle of the particle.
  72164. */
  72165. angle: number;
  72166. /**
  72167. * Defines how fast is the angle changing.
  72168. */
  72169. angularSpeed: number;
  72170. /**
  72171. * Defines the cell index used by the particle to be rendered from a sprite.
  72172. */
  72173. cellIndex: number;
  72174. /**
  72175. * The information required to support color remapping
  72176. */
  72177. remapData: Vector4;
  72178. /** @hidden */
  72179. _randomCellOffset?: number;
  72180. /** @hidden */
  72181. _initialDirection: Nullable<Vector3>;
  72182. /** @hidden */
  72183. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  72184. /** @hidden */
  72185. _initialStartSpriteCellID: number;
  72186. /** @hidden */
  72187. _initialEndSpriteCellID: number;
  72188. /** @hidden */
  72189. _currentColorGradient: Nullable<ColorGradient>;
  72190. /** @hidden */
  72191. _currentColor1: Color4;
  72192. /** @hidden */
  72193. _currentColor2: Color4;
  72194. /** @hidden */
  72195. _currentSizeGradient: Nullable<FactorGradient>;
  72196. /** @hidden */
  72197. _currentSize1: number;
  72198. /** @hidden */
  72199. _currentSize2: number;
  72200. /** @hidden */
  72201. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  72202. /** @hidden */
  72203. _currentAngularSpeed1: number;
  72204. /** @hidden */
  72205. _currentAngularSpeed2: number;
  72206. /** @hidden */
  72207. _currentVelocityGradient: Nullable<FactorGradient>;
  72208. /** @hidden */
  72209. _currentVelocity1: number;
  72210. /** @hidden */
  72211. _currentVelocity2: number;
  72212. /** @hidden */
  72213. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  72214. /** @hidden */
  72215. _currentLimitVelocity1: number;
  72216. /** @hidden */
  72217. _currentLimitVelocity2: number;
  72218. /** @hidden */
  72219. _currentDragGradient: Nullable<FactorGradient>;
  72220. /** @hidden */
  72221. _currentDrag1: number;
  72222. /** @hidden */
  72223. _currentDrag2: number;
  72224. /** @hidden */
  72225. _randomNoiseCoordinates1: Vector3;
  72226. /** @hidden */
  72227. _randomNoiseCoordinates2: Vector3;
  72228. /**
  72229. * Creates a new instance Particle
  72230. * @param particleSystem the particle system the particle belongs to
  72231. */
  72232. constructor(
  72233. /**
  72234. * The particle system the particle belongs to.
  72235. */
  72236. particleSystem: ParticleSystem);
  72237. private updateCellInfoFromSystem;
  72238. /**
  72239. * Defines how the sprite cell index is updated for the particle
  72240. */
  72241. updateCellIndex(): void;
  72242. /** @hidden */
  72243. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  72244. /** @hidden */
  72245. _inheritParticleInfoToSubEmitters(): void;
  72246. /** @hidden */
  72247. _reset(): void;
  72248. /**
  72249. * Copy the properties of particle to another one.
  72250. * @param other the particle to copy the information to.
  72251. */
  72252. copyTo(other: Particle): void;
  72253. }
  72254. }
  72255. declare module BABYLON {
  72256. /**
  72257. * Particle emitter represents a volume emitting particles.
  72258. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  72259. */
  72260. export interface IParticleEmitterType {
  72261. /**
  72262. * Called by the particle System when the direction is computed for the created particle.
  72263. * @param worldMatrix is the world matrix of the particle system
  72264. * @param directionToUpdate is the direction vector to update with the result
  72265. * @param particle is the particle we are computed the direction for
  72266. */
  72267. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72268. /**
  72269. * Called by the particle System when the position is computed for the created particle.
  72270. * @param worldMatrix is the world matrix of the particle system
  72271. * @param positionToUpdate is the position vector to update with the result
  72272. * @param particle is the particle we are computed the position for
  72273. */
  72274. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72275. /**
  72276. * Clones the current emitter and returns a copy of it
  72277. * @returns the new emitter
  72278. */
  72279. clone(): IParticleEmitterType;
  72280. /**
  72281. * Called by the GPUParticleSystem to setup the update shader
  72282. * @param effect defines the update shader
  72283. */
  72284. applyToShader(effect: Effect): void;
  72285. /**
  72286. * Returns a string to use to update the GPU particles update shader
  72287. * @returns the effect defines string
  72288. */
  72289. getEffectDefines(): string;
  72290. /**
  72291. * Returns a string representing the class name
  72292. * @returns a string containing the class name
  72293. */
  72294. getClassName(): string;
  72295. /**
  72296. * Serializes the particle system to a JSON object.
  72297. * @returns the JSON object
  72298. */
  72299. serialize(): any;
  72300. /**
  72301. * Parse properties from a JSON object
  72302. * @param serializationObject defines the JSON object
  72303. */
  72304. parse(serializationObject: any): void;
  72305. }
  72306. }
  72307. declare module BABYLON {
  72308. /**
  72309. * Particle emitter emitting particles from the inside of a box.
  72310. * It emits the particles randomly between 2 given directions.
  72311. */
  72312. export class BoxParticleEmitter implements IParticleEmitterType {
  72313. /**
  72314. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72315. */
  72316. direction1: Vector3;
  72317. /**
  72318. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72319. */
  72320. direction2: Vector3;
  72321. /**
  72322. * 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.
  72323. */
  72324. minEmitBox: Vector3;
  72325. /**
  72326. * 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.
  72327. */
  72328. maxEmitBox: Vector3;
  72329. /**
  72330. * Creates a new instance BoxParticleEmitter
  72331. */
  72332. constructor();
  72333. /**
  72334. * Called by the particle System when the direction is computed for the created particle.
  72335. * @param worldMatrix is the world matrix of the particle system
  72336. * @param directionToUpdate is the direction vector to update with the result
  72337. * @param particle is the particle we are computed the direction for
  72338. */
  72339. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72340. /**
  72341. * Called by the particle System when the position is computed for the created particle.
  72342. * @param worldMatrix is the world matrix of the particle system
  72343. * @param positionToUpdate is the position vector to update with the result
  72344. * @param particle is the particle we are computed the position for
  72345. */
  72346. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72347. /**
  72348. * Clones the current emitter and returns a copy of it
  72349. * @returns the new emitter
  72350. */
  72351. clone(): BoxParticleEmitter;
  72352. /**
  72353. * Called by the GPUParticleSystem to setup the update shader
  72354. * @param effect defines the update shader
  72355. */
  72356. applyToShader(effect: Effect): void;
  72357. /**
  72358. * Returns a string to use to update the GPU particles update shader
  72359. * @returns a string containng the defines string
  72360. */
  72361. getEffectDefines(): string;
  72362. /**
  72363. * Returns the string "BoxParticleEmitter"
  72364. * @returns a string containing the class name
  72365. */
  72366. getClassName(): string;
  72367. /**
  72368. * Serializes the particle system to a JSON object.
  72369. * @returns the JSON object
  72370. */
  72371. serialize(): any;
  72372. /**
  72373. * Parse properties from a JSON object
  72374. * @param serializationObject defines the JSON object
  72375. */
  72376. parse(serializationObject: any): void;
  72377. }
  72378. }
  72379. declare module BABYLON {
  72380. /**
  72381. * Particle emitter emitting particles from the inside of a cone.
  72382. * It emits the particles alongside the cone volume from the base to the particle.
  72383. * The emission direction might be randomized.
  72384. */
  72385. export class ConeParticleEmitter implements IParticleEmitterType {
  72386. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72387. directionRandomizer: number;
  72388. private _radius;
  72389. private _angle;
  72390. private _height;
  72391. /**
  72392. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  72393. */
  72394. radiusRange: number;
  72395. /**
  72396. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  72397. */
  72398. heightRange: number;
  72399. /**
  72400. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  72401. */
  72402. emitFromSpawnPointOnly: boolean;
  72403. /**
  72404. * Gets or sets the radius of the emission cone
  72405. */
  72406. radius: number;
  72407. /**
  72408. * Gets or sets the angle of the emission cone
  72409. */
  72410. angle: number;
  72411. private _buildHeight;
  72412. /**
  72413. * Creates a new instance ConeParticleEmitter
  72414. * @param radius the radius of the emission cone (1 by default)
  72415. * @param angle the cone base angle (PI by default)
  72416. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  72417. */
  72418. constructor(radius?: number, angle?: number,
  72419. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72420. directionRandomizer?: number);
  72421. /**
  72422. * Called by the particle System when the direction is computed for the created particle.
  72423. * @param worldMatrix is the world matrix of the particle system
  72424. * @param directionToUpdate is the direction vector to update with the result
  72425. * @param particle is the particle we are computed the direction for
  72426. */
  72427. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72428. /**
  72429. * Called by the particle System when the position is computed for the created particle.
  72430. * @param worldMatrix is the world matrix of the particle system
  72431. * @param positionToUpdate is the position vector to update with the result
  72432. * @param particle is the particle we are computed the position for
  72433. */
  72434. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72435. /**
  72436. * Clones the current emitter and returns a copy of it
  72437. * @returns the new emitter
  72438. */
  72439. clone(): ConeParticleEmitter;
  72440. /**
  72441. * Called by the GPUParticleSystem to setup the update shader
  72442. * @param effect defines the update shader
  72443. */
  72444. applyToShader(effect: Effect): void;
  72445. /**
  72446. * Returns a string to use to update the GPU particles update shader
  72447. * @returns a string containng the defines string
  72448. */
  72449. getEffectDefines(): string;
  72450. /**
  72451. * Returns the string "ConeParticleEmitter"
  72452. * @returns a string containing the class name
  72453. */
  72454. getClassName(): string;
  72455. /**
  72456. * Serializes the particle system to a JSON object.
  72457. * @returns the JSON object
  72458. */
  72459. serialize(): any;
  72460. /**
  72461. * Parse properties from a JSON object
  72462. * @param serializationObject defines the JSON object
  72463. */
  72464. parse(serializationObject: any): void;
  72465. }
  72466. }
  72467. declare module BABYLON {
  72468. /**
  72469. * Particle emitter emitting particles from the inside of a cylinder.
  72470. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  72471. */
  72472. export class CylinderParticleEmitter implements IParticleEmitterType {
  72473. /**
  72474. * The radius of the emission cylinder.
  72475. */
  72476. radius: number;
  72477. /**
  72478. * The height of the emission cylinder.
  72479. */
  72480. height: number;
  72481. /**
  72482. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72483. */
  72484. radiusRange: number;
  72485. /**
  72486. * How much to randomize the particle direction [0-1].
  72487. */
  72488. directionRandomizer: number;
  72489. /**
  72490. * Creates a new instance CylinderParticleEmitter
  72491. * @param radius the radius of the emission cylinder (1 by default)
  72492. * @param height the height of the emission cylinder (1 by default)
  72493. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72494. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72495. */
  72496. constructor(
  72497. /**
  72498. * The radius of the emission cylinder.
  72499. */
  72500. radius?: number,
  72501. /**
  72502. * The height of the emission cylinder.
  72503. */
  72504. height?: number,
  72505. /**
  72506. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72507. */
  72508. radiusRange?: number,
  72509. /**
  72510. * How much to randomize the particle direction [0-1].
  72511. */
  72512. directionRandomizer?: number);
  72513. /**
  72514. * Called by the particle System when the direction is computed for the created particle.
  72515. * @param worldMatrix is the world matrix of the particle system
  72516. * @param directionToUpdate is the direction vector to update with the result
  72517. * @param particle is the particle we are computed the direction for
  72518. */
  72519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72520. /**
  72521. * Called by the particle System when the position is computed for the created particle.
  72522. * @param worldMatrix is the world matrix of the particle system
  72523. * @param positionToUpdate is the position vector to update with the result
  72524. * @param particle is the particle we are computed the position for
  72525. */
  72526. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72527. /**
  72528. * Clones the current emitter and returns a copy of it
  72529. * @returns the new emitter
  72530. */
  72531. clone(): CylinderParticleEmitter;
  72532. /**
  72533. * Called by the GPUParticleSystem to setup the update shader
  72534. * @param effect defines the update shader
  72535. */
  72536. applyToShader(effect: Effect): void;
  72537. /**
  72538. * Returns a string to use to update the GPU particles update shader
  72539. * @returns a string containng the defines string
  72540. */
  72541. getEffectDefines(): string;
  72542. /**
  72543. * Returns the string "CylinderParticleEmitter"
  72544. * @returns a string containing the class name
  72545. */
  72546. getClassName(): string;
  72547. /**
  72548. * Serializes the particle system to a JSON object.
  72549. * @returns the JSON object
  72550. */
  72551. serialize(): any;
  72552. /**
  72553. * Parse properties from a JSON object
  72554. * @param serializationObject defines the JSON object
  72555. */
  72556. parse(serializationObject: any): void;
  72557. }
  72558. /**
  72559. * Particle emitter emitting particles from the inside of a cylinder.
  72560. * It emits the particles randomly between two vectors.
  72561. */
  72562. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  72563. /**
  72564. * The min limit of the emission direction.
  72565. */
  72566. direction1: Vector3;
  72567. /**
  72568. * The max limit of the emission direction.
  72569. */
  72570. direction2: Vector3;
  72571. /**
  72572. * Creates a new instance CylinderDirectedParticleEmitter
  72573. * @param radius the radius of the emission cylinder (1 by default)
  72574. * @param height the height of the emission cylinder (1 by default)
  72575. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72576. * @param direction1 the min limit of the emission direction (up vector by default)
  72577. * @param direction2 the max limit of the emission direction (up vector by default)
  72578. */
  72579. constructor(radius?: number, height?: number, radiusRange?: number,
  72580. /**
  72581. * The min limit of the emission direction.
  72582. */
  72583. direction1?: Vector3,
  72584. /**
  72585. * The max limit of the emission direction.
  72586. */
  72587. direction2?: Vector3);
  72588. /**
  72589. * Called by the particle System when the direction is computed for the created particle.
  72590. * @param worldMatrix is the world matrix of the particle system
  72591. * @param directionToUpdate is the direction vector to update with the result
  72592. * @param particle is the particle we are computed the direction for
  72593. */
  72594. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72595. /**
  72596. * Clones the current emitter and returns a copy of it
  72597. * @returns the new emitter
  72598. */
  72599. clone(): CylinderDirectedParticleEmitter;
  72600. /**
  72601. * Called by the GPUParticleSystem to setup the update shader
  72602. * @param effect defines the update shader
  72603. */
  72604. applyToShader(effect: Effect): void;
  72605. /**
  72606. * Returns a string to use to update the GPU particles update shader
  72607. * @returns a string containng the defines string
  72608. */
  72609. getEffectDefines(): string;
  72610. /**
  72611. * Returns the string "CylinderDirectedParticleEmitter"
  72612. * @returns a string containing the class name
  72613. */
  72614. getClassName(): string;
  72615. /**
  72616. * Serializes the particle system to a JSON object.
  72617. * @returns the JSON object
  72618. */
  72619. serialize(): any;
  72620. /**
  72621. * Parse properties from a JSON object
  72622. * @param serializationObject defines the JSON object
  72623. */
  72624. parse(serializationObject: any): void;
  72625. }
  72626. }
  72627. declare module BABYLON {
  72628. /**
  72629. * Particle emitter emitting particles from the inside of a hemisphere.
  72630. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  72631. */
  72632. export class HemisphericParticleEmitter implements IParticleEmitterType {
  72633. /**
  72634. * The radius of the emission hemisphere.
  72635. */
  72636. radius: number;
  72637. /**
  72638. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72639. */
  72640. radiusRange: number;
  72641. /**
  72642. * How much to randomize the particle direction [0-1].
  72643. */
  72644. directionRandomizer: number;
  72645. /**
  72646. * Creates a new instance HemisphericParticleEmitter
  72647. * @param radius the radius of the emission hemisphere (1 by default)
  72648. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72649. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72650. */
  72651. constructor(
  72652. /**
  72653. * The radius of the emission hemisphere.
  72654. */
  72655. radius?: number,
  72656. /**
  72657. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72658. */
  72659. radiusRange?: number,
  72660. /**
  72661. * How much to randomize the particle direction [0-1].
  72662. */
  72663. directionRandomizer?: number);
  72664. /**
  72665. * Called by the particle System when the direction is computed for the created particle.
  72666. * @param worldMatrix is the world matrix of the particle system
  72667. * @param directionToUpdate is the direction vector to update with the result
  72668. * @param particle is the particle we are computed the direction for
  72669. */
  72670. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72671. /**
  72672. * Called by the particle System when the position is computed for the created particle.
  72673. * @param worldMatrix is the world matrix of the particle system
  72674. * @param positionToUpdate is the position vector to update with the result
  72675. * @param particle is the particle we are computed the position for
  72676. */
  72677. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72678. /**
  72679. * Clones the current emitter and returns a copy of it
  72680. * @returns the new emitter
  72681. */
  72682. clone(): HemisphericParticleEmitter;
  72683. /**
  72684. * Called by the GPUParticleSystem to setup the update shader
  72685. * @param effect defines the update shader
  72686. */
  72687. applyToShader(effect: Effect): void;
  72688. /**
  72689. * Returns a string to use to update the GPU particles update shader
  72690. * @returns a string containng the defines string
  72691. */
  72692. getEffectDefines(): string;
  72693. /**
  72694. * Returns the string "HemisphericParticleEmitter"
  72695. * @returns a string containing the class name
  72696. */
  72697. getClassName(): string;
  72698. /**
  72699. * Serializes the particle system to a JSON object.
  72700. * @returns the JSON object
  72701. */
  72702. serialize(): any;
  72703. /**
  72704. * Parse properties from a JSON object
  72705. * @param serializationObject defines the JSON object
  72706. */
  72707. parse(serializationObject: any): void;
  72708. }
  72709. }
  72710. declare module BABYLON {
  72711. /**
  72712. * Particle emitter emitting particles from a point.
  72713. * It emits the particles randomly between 2 given directions.
  72714. */
  72715. export class PointParticleEmitter implements IParticleEmitterType {
  72716. /**
  72717. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72718. */
  72719. direction1: Vector3;
  72720. /**
  72721. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72722. */
  72723. direction2: Vector3;
  72724. /**
  72725. * Creates a new instance PointParticleEmitter
  72726. */
  72727. constructor();
  72728. /**
  72729. * Called by the particle System when the direction is computed for the created particle.
  72730. * @param worldMatrix is the world matrix of the particle system
  72731. * @param directionToUpdate is the direction vector to update with the result
  72732. * @param particle is the particle we are computed the direction for
  72733. */
  72734. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72735. /**
  72736. * Called by the particle System when the position is computed for the created particle.
  72737. * @param worldMatrix is the world matrix of the particle system
  72738. * @param positionToUpdate is the position vector to update with the result
  72739. * @param particle is the particle we are computed the position for
  72740. */
  72741. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72742. /**
  72743. * Clones the current emitter and returns a copy of it
  72744. * @returns the new emitter
  72745. */
  72746. clone(): PointParticleEmitter;
  72747. /**
  72748. * Called by the GPUParticleSystem to setup the update shader
  72749. * @param effect defines the update shader
  72750. */
  72751. applyToShader(effect: Effect): void;
  72752. /**
  72753. * Returns a string to use to update the GPU particles update shader
  72754. * @returns a string containng the defines string
  72755. */
  72756. getEffectDefines(): string;
  72757. /**
  72758. * Returns the string "PointParticleEmitter"
  72759. * @returns a string containing the class name
  72760. */
  72761. getClassName(): string;
  72762. /**
  72763. * Serializes the particle system to a JSON object.
  72764. * @returns the JSON object
  72765. */
  72766. serialize(): any;
  72767. /**
  72768. * Parse properties from a JSON object
  72769. * @param serializationObject defines the JSON object
  72770. */
  72771. parse(serializationObject: any): void;
  72772. }
  72773. }
  72774. declare module BABYLON {
  72775. /**
  72776. * Particle emitter emitting particles from the inside of a sphere.
  72777. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  72778. */
  72779. export class SphereParticleEmitter implements IParticleEmitterType {
  72780. /**
  72781. * The radius of the emission sphere.
  72782. */
  72783. radius: number;
  72784. /**
  72785. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72786. */
  72787. radiusRange: number;
  72788. /**
  72789. * How much to randomize the particle direction [0-1].
  72790. */
  72791. directionRandomizer: number;
  72792. /**
  72793. * Creates a new instance SphereParticleEmitter
  72794. * @param radius the radius of the emission sphere (1 by default)
  72795. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72796. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72797. */
  72798. constructor(
  72799. /**
  72800. * The radius of the emission sphere.
  72801. */
  72802. radius?: number,
  72803. /**
  72804. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72805. */
  72806. radiusRange?: number,
  72807. /**
  72808. * How much to randomize the particle direction [0-1].
  72809. */
  72810. directionRandomizer?: number);
  72811. /**
  72812. * Called by the particle System when the direction is computed for the created particle.
  72813. * @param worldMatrix is the world matrix of the particle system
  72814. * @param directionToUpdate is the direction vector to update with the result
  72815. * @param particle is the particle we are computed the direction for
  72816. */
  72817. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72818. /**
  72819. * Called by the particle System when the position is computed for the created particle.
  72820. * @param worldMatrix is the world matrix of the particle system
  72821. * @param positionToUpdate is the position vector to update with the result
  72822. * @param particle is the particle we are computed the position for
  72823. */
  72824. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72825. /**
  72826. * Clones the current emitter and returns a copy of it
  72827. * @returns the new emitter
  72828. */
  72829. clone(): SphereParticleEmitter;
  72830. /**
  72831. * Called by the GPUParticleSystem to setup the update shader
  72832. * @param effect defines the update shader
  72833. */
  72834. applyToShader(effect: Effect): void;
  72835. /**
  72836. * Returns a string to use to update the GPU particles update shader
  72837. * @returns a string containng the defines string
  72838. */
  72839. getEffectDefines(): string;
  72840. /**
  72841. * Returns the string "SphereParticleEmitter"
  72842. * @returns a string containing the class name
  72843. */
  72844. getClassName(): string;
  72845. /**
  72846. * Serializes the particle system to a JSON object.
  72847. * @returns the JSON object
  72848. */
  72849. serialize(): any;
  72850. /**
  72851. * Parse properties from a JSON object
  72852. * @param serializationObject defines the JSON object
  72853. */
  72854. parse(serializationObject: any): void;
  72855. }
  72856. /**
  72857. * Particle emitter emitting particles from the inside of a sphere.
  72858. * It emits the particles randomly between two vectors.
  72859. */
  72860. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  72861. /**
  72862. * The min limit of the emission direction.
  72863. */
  72864. direction1: Vector3;
  72865. /**
  72866. * The max limit of the emission direction.
  72867. */
  72868. direction2: Vector3;
  72869. /**
  72870. * Creates a new instance SphereDirectedParticleEmitter
  72871. * @param radius the radius of the emission sphere (1 by default)
  72872. * @param direction1 the min limit of the emission direction (up vector by default)
  72873. * @param direction2 the max limit of the emission direction (up vector by default)
  72874. */
  72875. constructor(radius?: number,
  72876. /**
  72877. * The min limit of the emission direction.
  72878. */
  72879. direction1?: Vector3,
  72880. /**
  72881. * The max limit of the emission direction.
  72882. */
  72883. direction2?: Vector3);
  72884. /**
  72885. * Called by the particle System when the direction is computed for the created particle.
  72886. * @param worldMatrix is the world matrix of the particle system
  72887. * @param directionToUpdate is the direction vector to update with the result
  72888. * @param particle is the particle we are computed the direction for
  72889. */
  72890. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72891. /**
  72892. * Clones the current emitter and returns a copy of it
  72893. * @returns the new emitter
  72894. */
  72895. clone(): SphereDirectedParticleEmitter;
  72896. /**
  72897. * Called by the GPUParticleSystem to setup the update shader
  72898. * @param effect defines the update shader
  72899. */
  72900. applyToShader(effect: Effect): void;
  72901. /**
  72902. * Returns a string to use to update the GPU particles update shader
  72903. * @returns a string containng the defines string
  72904. */
  72905. getEffectDefines(): string;
  72906. /**
  72907. * Returns the string "SphereDirectedParticleEmitter"
  72908. * @returns a string containing the class name
  72909. */
  72910. getClassName(): string;
  72911. /**
  72912. * Serializes the particle system to a JSON object.
  72913. * @returns the JSON object
  72914. */
  72915. serialize(): any;
  72916. /**
  72917. * Parse properties from a JSON object
  72918. * @param serializationObject defines the JSON object
  72919. */
  72920. parse(serializationObject: any): void;
  72921. }
  72922. }
  72923. declare module BABYLON {
  72924. /**
  72925. * Interface representing a particle system in Babylon.js.
  72926. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  72927. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  72928. */
  72929. export interface IParticleSystem {
  72930. /**
  72931. * List of animations used by the particle system.
  72932. */
  72933. animations: Animation[];
  72934. /**
  72935. * The id of the Particle system.
  72936. */
  72937. id: string;
  72938. /**
  72939. * The name of the Particle system.
  72940. */
  72941. name: string;
  72942. /**
  72943. * The emitter represents the Mesh or position we are attaching the particle system to.
  72944. */
  72945. emitter: Nullable<AbstractMesh | Vector3>;
  72946. /**
  72947. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  72948. */
  72949. isBillboardBased: boolean;
  72950. /**
  72951. * The rendering group used by the Particle system to chose when to render.
  72952. */
  72953. renderingGroupId: number;
  72954. /**
  72955. * The layer mask we are rendering the particles through.
  72956. */
  72957. layerMask: number;
  72958. /**
  72959. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  72960. */
  72961. updateSpeed: number;
  72962. /**
  72963. * The amount of time the particle system is running (depends of the overall update speed).
  72964. */
  72965. targetStopDuration: number;
  72966. /**
  72967. * The texture used to render each particle. (this can be a spritesheet)
  72968. */
  72969. particleTexture: Nullable<Texture>;
  72970. /**
  72971. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  72972. */
  72973. blendMode: number;
  72974. /**
  72975. * Minimum life time of emitting particles.
  72976. */
  72977. minLifeTime: number;
  72978. /**
  72979. * Maximum life time of emitting particles.
  72980. */
  72981. maxLifeTime: number;
  72982. /**
  72983. * Minimum Size of emitting particles.
  72984. */
  72985. minSize: number;
  72986. /**
  72987. * Maximum Size of emitting particles.
  72988. */
  72989. maxSize: number;
  72990. /**
  72991. * Minimum scale of emitting particles on X axis.
  72992. */
  72993. minScaleX: number;
  72994. /**
  72995. * Maximum scale of emitting particles on X axis.
  72996. */
  72997. maxScaleX: number;
  72998. /**
  72999. * Minimum scale of emitting particles on Y axis.
  73000. */
  73001. minScaleY: number;
  73002. /**
  73003. * Maximum scale of emitting particles on Y axis.
  73004. */
  73005. maxScaleY: number;
  73006. /**
  73007. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73008. */
  73009. color1: Color4;
  73010. /**
  73011. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73012. */
  73013. color2: Color4;
  73014. /**
  73015. * Color the particle will have at the end of its lifetime.
  73016. */
  73017. colorDead: Color4;
  73018. /**
  73019. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  73020. */
  73021. emitRate: number;
  73022. /**
  73023. * You can use gravity if you want to give an orientation to your particles.
  73024. */
  73025. gravity: Vector3;
  73026. /**
  73027. * Minimum power of emitting particles.
  73028. */
  73029. minEmitPower: number;
  73030. /**
  73031. * Maximum power of emitting particles.
  73032. */
  73033. maxEmitPower: number;
  73034. /**
  73035. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73036. */
  73037. minAngularSpeed: number;
  73038. /**
  73039. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73040. */
  73041. maxAngularSpeed: number;
  73042. /**
  73043. * Gets or sets the minimal initial rotation in radians.
  73044. */
  73045. minInitialRotation: number;
  73046. /**
  73047. * Gets or sets the maximal initial rotation in radians.
  73048. */
  73049. maxInitialRotation: number;
  73050. /**
  73051. * The particle emitter type defines the emitter used by the particle system.
  73052. * It can be for example box, sphere, or cone...
  73053. */
  73054. particleEmitterType: Nullable<IParticleEmitterType>;
  73055. /**
  73056. * Defines the delay in milliseconds before starting the system (0 by default)
  73057. */
  73058. startDelay: number;
  73059. /**
  73060. * 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
  73061. */
  73062. preWarmCycles: number;
  73063. /**
  73064. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  73065. */
  73066. preWarmStepOffset: number;
  73067. /**
  73068. * 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)
  73069. */
  73070. spriteCellChangeSpeed: number;
  73071. /**
  73072. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73073. */
  73074. startSpriteCellID: number;
  73075. /**
  73076. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73077. */
  73078. endSpriteCellID: number;
  73079. /**
  73080. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73081. */
  73082. spriteCellWidth: number;
  73083. /**
  73084. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73085. */
  73086. spriteCellHeight: number;
  73087. /**
  73088. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73089. */
  73090. spriteRandomStartCell: boolean;
  73091. /**
  73092. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  73093. */
  73094. isAnimationSheetEnabled: boolean;
  73095. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73096. translationPivot: Vector2;
  73097. /**
  73098. * Gets or sets a texture used to add random noise to particle positions
  73099. */
  73100. noiseTexture: Nullable<BaseTexture>;
  73101. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73102. noiseStrength: Vector3;
  73103. /**
  73104. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73105. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73106. */
  73107. billboardMode: number;
  73108. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73109. limitVelocityDamping: number;
  73110. /**
  73111. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73112. */
  73113. beginAnimationOnStart: boolean;
  73114. /**
  73115. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73116. */
  73117. beginAnimationFrom: number;
  73118. /**
  73119. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73120. */
  73121. beginAnimationTo: number;
  73122. /**
  73123. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73124. */
  73125. beginAnimationLoop: boolean;
  73126. /**
  73127. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73128. */
  73129. disposeOnStop: boolean;
  73130. /**
  73131. * Gets the maximum number of particles active at the same time.
  73132. * @returns The max number of active particles.
  73133. */
  73134. getCapacity(): number;
  73135. /**
  73136. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73137. * @returns True if it has been started, otherwise false.
  73138. */
  73139. isStarted(): boolean;
  73140. /**
  73141. * Animates the particle system for this frame.
  73142. */
  73143. animate(): void;
  73144. /**
  73145. * Renders the particle system in its current state.
  73146. * @returns the current number of particles
  73147. */
  73148. render(): number;
  73149. /**
  73150. * Dispose the particle system and frees its associated resources.
  73151. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73152. */
  73153. dispose(disposeTexture?: boolean): void;
  73154. /**
  73155. * Clones the particle system.
  73156. * @param name The name of the cloned object
  73157. * @param newEmitter The new emitter to use
  73158. * @returns the cloned particle system
  73159. */
  73160. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  73161. /**
  73162. * Serializes the particle system to a JSON object.
  73163. * @returns the JSON object
  73164. */
  73165. serialize(): any;
  73166. /**
  73167. * Rebuild the particle system
  73168. */
  73169. rebuild(): void;
  73170. /**
  73171. * Starts the particle system and begins to emit
  73172. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  73173. */
  73174. start(delay?: number): void;
  73175. /**
  73176. * Stops the particle system.
  73177. */
  73178. stop(): void;
  73179. /**
  73180. * Remove all active particles
  73181. */
  73182. reset(): void;
  73183. /**
  73184. * Is this system ready to be used/rendered
  73185. * @return true if the system is ready
  73186. */
  73187. isReady(): boolean;
  73188. /**
  73189. * Adds a new color gradient
  73190. * @param gradient defines the gradient to use (between 0 and 1)
  73191. * @param color1 defines the color to affect to the specified gradient
  73192. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73193. * @returns the current particle system
  73194. */
  73195. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73196. /**
  73197. * Remove a specific color gradient
  73198. * @param gradient defines the gradient to remove
  73199. * @returns the current particle system
  73200. */
  73201. removeColorGradient(gradient: number): IParticleSystem;
  73202. /**
  73203. * Adds a new size gradient
  73204. * @param gradient defines the gradient to use (between 0 and 1)
  73205. * @param factor defines the size factor to affect to the specified gradient
  73206. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73207. * @returns the current particle system
  73208. */
  73209. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73210. /**
  73211. * Remove a specific size gradient
  73212. * @param gradient defines the gradient to remove
  73213. * @returns the current particle system
  73214. */
  73215. removeSizeGradient(gradient: number): IParticleSystem;
  73216. /**
  73217. * Gets the current list of color gradients.
  73218. * You must use addColorGradient and removeColorGradient to udpate this list
  73219. * @returns the list of color gradients
  73220. */
  73221. getColorGradients(): Nullable<Array<ColorGradient>>;
  73222. /**
  73223. * Gets the current list of size gradients.
  73224. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73225. * @returns the list of size gradients
  73226. */
  73227. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73228. /**
  73229. * Gets the current list of angular speed gradients.
  73230. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73231. * @returns the list of angular speed gradients
  73232. */
  73233. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73234. /**
  73235. * Adds a new angular speed gradient
  73236. * @param gradient defines the gradient to use (between 0 and 1)
  73237. * @param factor defines the angular speed to affect to the specified gradient
  73238. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73239. * @returns the current particle system
  73240. */
  73241. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73242. /**
  73243. * Remove a specific angular speed gradient
  73244. * @param gradient defines the gradient to remove
  73245. * @returns the current particle system
  73246. */
  73247. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73248. /**
  73249. * Gets the current list of velocity gradients.
  73250. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73251. * @returns the list of velocity gradients
  73252. */
  73253. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73254. /**
  73255. * Adds a new velocity gradient
  73256. * @param gradient defines the gradient to use (between 0 and 1)
  73257. * @param factor defines the velocity to affect to the specified gradient
  73258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73259. * @returns the current particle system
  73260. */
  73261. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73262. /**
  73263. * Remove a specific velocity gradient
  73264. * @param gradient defines the gradient to remove
  73265. * @returns the current particle system
  73266. */
  73267. removeVelocityGradient(gradient: number): IParticleSystem;
  73268. /**
  73269. * Gets the current list of limit velocity gradients.
  73270. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73271. * @returns the list of limit velocity gradients
  73272. */
  73273. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73274. /**
  73275. * Adds a new limit velocity gradient
  73276. * @param gradient defines the gradient to use (between 0 and 1)
  73277. * @param factor defines the limit velocity to affect to the specified gradient
  73278. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73279. * @returns the current particle system
  73280. */
  73281. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73282. /**
  73283. * Remove a specific limit velocity gradient
  73284. * @param gradient defines the gradient to remove
  73285. * @returns the current particle system
  73286. */
  73287. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73288. /**
  73289. * Adds a new drag gradient
  73290. * @param gradient defines the gradient to use (between 0 and 1)
  73291. * @param factor defines the drag to affect to the specified gradient
  73292. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73293. * @returns the current particle system
  73294. */
  73295. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73296. /**
  73297. * Remove a specific drag gradient
  73298. * @param gradient defines the gradient to remove
  73299. * @returns the current particle system
  73300. */
  73301. removeDragGradient(gradient: number): IParticleSystem;
  73302. /**
  73303. * Gets the current list of drag gradients.
  73304. * You must use addDragGradient and removeDragGradient to udpate this list
  73305. * @returns the list of drag gradients
  73306. */
  73307. getDragGradients(): Nullable<Array<FactorGradient>>;
  73308. /**
  73309. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73310. * @param gradient defines the gradient to use (between 0 and 1)
  73311. * @param factor defines the emit rate to affect to the specified gradient
  73312. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73313. * @returns the current particle system
  73314. */
  73315. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73316. /**
  73317. * Remove a specific emit rate gradient
  73318. * @param gradient defines the gradient to remove
  73319. * @returns the current particle system
  73320. */
  73321. removeEmitRateGradient(gradient: number): IParticleSystem;
  73322. /**
  73323. * Gets the current list of emit rate gradients.
  73324. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73325. * @returns the list of emit rate gradients
  73326. */
  73327. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73328. /**
  73329. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73330. * @param gradient defines the gradient to use (between 0 and 1)
  73331. * @param factor defines the start size to affect to the specified gradient
  73332. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73333. * @returns the current particle system
  73334. */
  73335. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73336. /**
  73337. * Remove a specific start size gradient
  73338. * @param gradient defines the gradient to remove
  73339. * @returns the current particle system
  73340. */
  73341. removeStartSizeGradient(gradient: number): IParticleSystem;
  73342. /**
  73343. * Gets the current list of start size gradients.
  73344. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73345. * @returns the list of start size gradients
  73346. */
  73347. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73348. /**
  73349. * Adds a new life time gradient
  73350. * @param gradient defines the gradient to use (between 0 and 1)
  73351. * @param factor defines the life time factor to affect to the specified gradient
  73352. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73353. * @returns the current particle system
  73354. */
  73355. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73356. /**
  73357. * Remove a specific life time gradient
  73358. * @param gradient defines the gradient to remove
  73359. * @returns the current particle system
  73360. */
  73361. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73362. /**
  73363. * Gets the current list of life time gradients.
  73364. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73365. * @returns the list of life time gradients
  73366. */
  73367. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73368. /**
  73369. * Gets the current list of color gradients.
  73370. * You must use addColorGradient and removeColorGradient to udpate this list
  73371. * @returns the list of color gradients
  73372. */
  73373. getColorGradients(): Nullable<Array<ColorGradient>>;
  73374. /**
  73375. * Adds a new ramp gradient used to remap particle colors
  73376. * @param gradient defines the gradient to use (between 0 and 1)
  73377. * @param color defines the color to affect to the specified gradient
  73378. * @returns the current particle system
  73379. */
  73380. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  73381. /**
  73382. * Gets the current list of ramp gradients.
  73383. * You must use addRampGradient and removeRampGradient to udpate this list
  73384. * @returns the list of ramp gradients
  73385. */
  73386. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73387. /** Gets or sets a boolean indicating that ramp gradients must be used
  73388. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73389. */
  73390. useRampGradients: boolean;
  73391. /**
  73392. * Adds a new color remap gradient
  73393. * @param gradient defines the gradient to use (between 0 and 1)
  73394. * @param min defines the color remap minimal range
  73395. * @param max defines the color remap maximal range
  73396. * @returns the current particle system
  73397. */
  73398. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73399. /**
  73400. * Gets the current list of color remap gradients.
  73401. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73402. * @returns the list of color remap gradients
  73403. */
  73404. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73405. /**
  73406. * Adds a new alpha remap gradient
  73407. * @param gradient defines the gradient to use (between 0 and 1)
  73408. * @param min defines the alpha remap minimal range
  73409. * @param max defines the alpha remap maximal range
  73410. * @returns the current particle system
  73411. */
  73412. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73413. /**
  73414. * Gets the current list of alpha remap gradients.
  73415. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73416. * @returns the list of alpha remap gradients
  73417. */
  73418. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73419. /**
  73420. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73421. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73422. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73423. * @returns the emitter
  73424. */
  73425. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73426. /**
  73427. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73428. * @param radius The radius of the hemisphere to emit from
  73429. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73430. * @returns the emitter
  73431. */
  73432. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  73433. /**
  73434. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73435. * @param radius The radius of the sphere to emit from
  73436. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73437. * @returns the emitter
  73438. */
  73439. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  73440. /**
  73441. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73442. * @param radius The radius of the sphere to emit from
  73443. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73444. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73445. * @returns the emitter
  73446. */
  73447. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73448. /**
  73449. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73450. * @param radius The radius of the emission cylinder
  73451. * @param height The height of the emission cylinder
  73452. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73453. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73454. * @returns the emitter
  73455. */
  73456. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  73457. /**
  73458. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73459. * @param radius The radius of the cylinder to emit from
  73460. * @param height The height of the emission cylinder
  73461. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73462. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73463. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73464. * @returns the emitter
  73465. */
  73466. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73467. /**
  73468. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73469. * @param radius The radius of the cone to emit from
  73470. * @param angle The base angle of the cone
  73471. * @returns the emitter
  73472. */
  73473. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  73474. /**
  73475. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73476. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73477. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73478. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73479. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73480. * @returns the emitter
  73481. */
  73482. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73483. /**
  73484. * Get hosting scene
  73485. * @returns the scene
  73486. */
  73487. getScene(): Scene;
  73488. }
  73489. }
  73490. declare module BABYLON {
  73491. /**
  73492. * Creates an instance based on a source mesh.
  73493. */
  73494. export class InstancedMesh extends AbstractMesh {
  73495. private _sourceMesh;
  73496. private _currentLOD;
  73497. /** @hidden */
  73498. _indexInSourceMeshInstanceArray: number;
  73499. constructor(name: string, source: Mesh);
  73500. /**
  73501. * Returns the string "InstancedMesh".
  73502. */
  73503. getClassName(): string;
  73504. /**
  73505. * If the source mesh receives shadows
  73506. */
  73507. readonly receiveShadows: boolean;
  73508. /**
  73509. * The material of the source mesh
  73510. */
  73511. readonly material: Nullable<Material>;
  73512. /**
  73513. * Visibility of the source mesh
  73514. */
  73515. readonly visibility: number;
  73516. /**
  73517. * Skeleton of the source mesh
  73518. */
  73519. readonly skeleton: Nullable<Skeleton>;
  73520. /**
  73521. * Rendering ground id of the source mesh
  73522. */
  73523. renderingGroupId: number;
  73524. /**
  73525. * Returns the total number of vertices (integer).
  73526. */
  73527. getTotalVertices(): number;
  73528. /**
  73529. * Returns a positive integer : the total number of indices in this mesh geometry.
  73530. * @returns the numner of indices or zero if the mesh has no geometry.
  73531. */
  73532. getTotalIndices(): number;
  73533. /**
  73534. * The source mesh of the instance
  73535. */
  73536. readonly sourceMesh: Mesh;
  73537. /**
  73538. * Is this node ready to be used/rendered
  73539. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  73540. * @return {boolean} is it ready
  73541. */
  73542. isReady(completeCheck?: boolean): boolean;
  73543. /**
  73544. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  73545. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  73546. * @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.
  73547. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  73548. */
  73549. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  73550. /**
  73551. * Sets the vertex data of the mesh geometry for the requested `kind`.
  73552. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  73553. * The `data` are either a numeric array either a Float32Array.
  73554. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  73555. * 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).
  73556. * Note that a new underlying VertexBuffer object is created each call.
  73557. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  73558. *
  73559. * Possible `kind` values :
  73560. * - VertexBuffer.PositionKind
  73561. * - VertexBuffer.UVKind
  73562. * - VertexBuffer.UV2Kind
  73563. * - VertexBuffer.UV3Kind
  73564. * - VertexBuffer.UV4Kind
  73565. * - VertexBuffer.UV5Kind
  73566. * - VertexBuffer.UV6Kind
  73567. * - VertexBuffer.ColorKind
  73568. * - VertexBuffer.MatricesIndicesKind
  73569. * - VertexBuffer.MatricesIndicesExtraKind
  73570. * - VertexBuffer.MatricesWeightsKind
  73571. * - VertexBuffer.MatricesWeightsExtraKind
  73572. *
  73573. * Returns the Mesh.
  73574. */
  73575. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  73576. /**
  73577. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  73578. * If the mesh has no geometry, it is simply returned as it is.
  73579. * The `data` are either a numeric array either a Float32Array.
  73580. * No new underlying VertexBuffer object is created.
  73581. * 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.
  73582. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  73583. *
  73584. * Possible `kind` values :
  73585. * - VertexBuffer.PositionKind
  73586. * - VertexBuffer.UVKind
  73587. * - VertexBuffer.UV2Kind
  73588. * - VertexBuffer.UV3Kind
  73589. * - VertexBuffer.UV4Kind
  73590. * - VertexBuffer.UV5Kind
  73591. * - VertexBuffer.UV6Kind
  73592. * - VertexBuffer.ColorKind
  73593. * - VertexBuffer.MatricesIndicesKind
  73594. * - VertexBuffer.MatricesIndicesExtraKind
  73595. * - VertexBuffer.MatricesWeightsKind
  73596. * - VertexBuffer.MatricesWeightsExtraKind
  73597. *
  73598. * Returns the Mesh.
  73599. */
  73600. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  73601. /**
  73602. * Sets the mesh indices.
  73603. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  73604. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  73605. * This method creates a new index buffer each call.
  73606. * Returns the Mesh.
  73607. */
  73608. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  73609. /**
  73610. * Boolean : True if the mesh owns the requested kind of data.
  73611. */
  73612. isVerticesDataPresent(kind: string): boolean;
  73613. /**
  73614. * Returns an array of indices (IndicesArray).
  73615. */
  73616. getIndices(): Nullable<IndicesArray>;
  73617. readonly _positions: Nullable<Vector3[]>;
  73618. /**
  73619. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  73620. * This means the mesh underlying bounding box and sphere are recomputed.
  73621. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  73622. * @returns the current mesh
  73623. */
  73624. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  73625. /** @hidden */
  73626. _preActivate(): InstancedMesh;
  73627. /** @hidden */
  73628. _activate(renderId: number): InstancedMesh;
  73629. /**
  73630. * Returns the current associated LOD AbstractMesh.
  73631. */
  73632. getLOD(camera: Camera): AbstractMesh;
  73633. /** @hidden */
  73634. _syncSubMeshes(): InstancedMesh;
  73635. /** @hidden */
  73636. _generatePointsArray(): boolean;
  73637. /**
  73638. * Creates a new InstancedMesh from the current mesh.
  73639. * - name (string) : the cloned mesh name
  73640. * - newParent (optional Node) : the optional Node to parent the clone to.
  73641. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  73642. *
  73643. * Returns the clone.
  73644. */
  73645. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  73646. /**
  73647. * Disposes the InstancedMesh.
  73648. * Returns nothing.
  73649. */
  73650. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73651. }
  73652. }
  73653. declare module BABYLON {
  73654. /**
  73655. * Defines the options associated with the creation of a shader material.
  73656. */
  73657. export interface IShaderMaterialOptions {
  73658. /**
  73659. * Does the material work in alpha blend mode
  73660. */
  73661. needAlphaBlending: boolean;
  73662. /**
  73663. * Does the material work in alpha test mode
  73664. */
  73665. needAlphaTesting: boolean;
  73666. /**
  73667. * The list of attribute names used in the shader
  73668. */
  73669. attributes: string[];
  73670. /**
  73671. * The list of unifrom names used in the shader
  73672. */
  73673. uniforms: string[];
  73674. /**
  73675. * The list of UBO names used in the shader
  73676. */
  73677. uniformBuffers: string[];
  73678. /**
  73679. * The list of sampler names used in the shader
  73680. */
  73681. samplers: string[];
  73682. /**
  73683. * The list of defines used in the shader
  73684. */
  73685. defines: string[];
  73686. }
  73687. /**
  73688. * 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.
  73689. *
  73690. * This returned material effects how the mesh will look based on the code in the shaders.
  73691. *
  73692. * @see http://doc.babylonjs.com/how_to/shader_material
  73693. */
  73694. export class ShaderMaterial extends Material {
  73695. private _shaderPath;
  73696. private _options;
  73697. private _textures;
  73698. private _textureArrays;
  73699. private _floats;
  73700. private _ints;
  73701. private _floatsArrays;
  73702. private _colors3;
  73703. private _colors3Arrays;
  73704. private _colors4;
  73705. private _vectors2;
  73706. private _vectors3;
  73707. private _vectors4;
  73708. private _matrices;
  73709. private _matrices3x3;
  73710. private _matrices2x2;
  73711. private _vectors2Arrays;
  73712. private _vectors3Arrays;
  73713. private _cachedWorldViewMatrix;
  73714. private _renderId;
  73715. /**
  73716. * Instantiate a new shader material.
  73717. * 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.
  73718. * This returned material effects how the mesh will look based on the code in the shaders.
  73719. * @see http://doc.babylonjs.com/how_to/shader_material
  73720. * @param name Define the name of the material in the scene
  73721. * @param scene Define the scene the material belongs to
  73722. * @param shaderPath Defines the route to the shader code in one of three ways:
  73723. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  73724. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  73725. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  73726. * @param options Define the options used to create the shader
  73727. */
  73728. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  73729. /**
  73730. * Gets the current class name of the material e.g. "ShaderMaterial"
  73731. * Mainly use in serialization.
  73732. * @returns the class name
  73733. */
  73734. getClassName(): string;
  73735. /**
  73736. * Specifies if the material will require alpha blending
  73737. * @returns a boolean specifying if alpha blending is needed
  73738. */
  73739. needAlphaBlending(): boolean;
  73740. /**
  73741. * Specifies if this material should be rendered in alpha test mode
  73742. * @returns a boolean specifying if an alpha test is needed.
  73743. */
  73744. needAlphaTesting(): boolean;
  73745. private _checkUniform;
  73746. /**
  73747. * Set a texture in the shader.
  73748. * @param name Define the name of the uniform samplers as defined in the shader
  73749. * @param texture Define the texture to bind to this sampler
  73750. * @return the material itself allowing "fluent" like uniform updates
  73751. */
  73752. setTexture(name: string, texture: Texture): ShaderMaterial;
  73753. /**
  73754. * Set a texture array in the shader.
  73755. * @param name Define the name of the uniform sampler array as defined in the shader
  73756. * @param textures Define the list of textures to bind to this sampler
  73757. * @return the material itself allowing "fluent" like uniform updates
  73758. */
  73759. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  73760. /**
  73761. * Set a float in the shader.
  73762. * @param name Define the name of the uniform as defined in the shader
  73763. * @param value Define the value to give to the uniform
  73764. * @return the material itself allowing "fluent" like uniform updates
  73765. */
  73766. setFloat(name: string, value: number): ShaderMaterial;
  73767. /**
  73768. * Set a int in the shader.
  73769. * @param name Define the name of the uniform as defined in the shader
  73770. * @param value Define the value to give to the uniform
  73771. * @return the material itself allowing "fluent" like uniform updates
  73772. */
  73773. setInt(name: string, value: number): ShaderMaterial;
  73774. /**
  73775. * Set an array of floats in the shader.
  73776. * @param name Define the name of the uniform as defined in the shader
  73777. * @param value Define the value to give to the uniform
  73778. * @return the material itself allowing "fluent" like uniform updates
  73779. */
  73780. setFloats(name: string, value: number[]): ShaderMaterial;
  73781. /**
  73782. * Set a vec3 in the shader from a Color3.
  73783. * @param name Define the name of the uniform as defined in the shader
  73784. * @param value Define the value to give to the uniform
  73785. * @return the material itself allowing "fluent" like uniform updates
  73786. */
  73787. setColor3(name: string, value: Color3): ShaderMaterial;
  73788. /**
  73789. * Set a vec3 array in the shader from a Color3 array.
  73790. * @param name Define the name of the uniform as defined in the shader
  73791. * @param value Define the value to give to the uniform
  73792. * @return the material itself allowing "fluent" like uniform updates
  73793. */
  73794. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  73795. /**
  73796. * Set a vec4 in the shader from a Color4.
  73797. * @param name Define the name of the uniform as defined in the shader
  73798. * @param value Define the value to give to the uniform
  73799. * @return the material itself allowing "fluent" like uniform updates
  73800. */
  73801. setColor4(name: string, value: Color4): ShaderMaterial;
  73802. /**
  73803. * Set a vec2 in the shader from a Vector2.
  73804. * @param name Define the name of the uniform as defined in the shader
  73805. * @param value Define the value to give to the uniform
  73806. * @return the material itself allowing "fluent" like uniform updates
  73807. */
  73808. setVector2(name: string, value: Vector2): ShaderMaterial;
  73809. /**
  73810. * Set a vec3 in the shader from a Vector3.
  73811. * @param name Define the name of the uniform as defined in the shader
  73812. * @param value Define the value to give to the uniform
  73813. * @return the material itself allowing "fluent" like uniform updates
  73814. */
  73815. setVector3(name: string, value: Vector3): ShaderMaterial;
  73816. /**
  73817. * Set a vec4 in the shader from a Vector4.
  73818. * @param name Define the name of the uniform as defined in the shader
  73819. * @param value Define the value to give to the uniform
  73820. * @return the material itself allowing "fluent" like uniform updates
  73821. */
  73822. setVector4(name: string, value: Vector4): ShaderMaterial;
  73823. /**
  73824. * Set a mat4 in the shader from a Matrix.
  73825. * @param name Define the name of the uniform as defined in the shader
  73826. * @param value Define the value to give to the uniform
  73827. * @return the material itself allowing "fluent" like uniform updates
  73828. */
  73829. setMatrix(name: string, value: Matrix): ShaderMaterial;
  73830. /**
  73831. * Set a mat3 in the shader from a Float32Array.
  73832. * @param name Define the name of the uniform as defined in the shader
  73833. * @param value Define the value to give to the uniform
  73834. * @return the material itself allowing "fluent" like uniform updates
  73835. */
  73836. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  73837. /**
  73838. * Set a mat2 in the shader from a Float32Array.
  73839. * @param name Define the name of the uniform as defined in the shader
  73840. * @param value Define the value to give to the uniform
  73841. * @return the material itself allowing "fluent" like uniform updates
  73842. */
  73843. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  73844. /**
  73845. * Set a vec2 array in the shader from a number array.
  73846. * @param name Define the name of the uniform as defined in the shader
  73847. * @param value Define the value to give to the uniform
  73848. * @return the material itself allowing "fluent" like uniform updates
  73849. */
  73850. setArray2(name: string, value: number[]): ShaderMaterial;
  73851. /**
  73852. * Set a vec3 array in the shader from a number array.
  73853. * @param name Define the name of the uniform as defined in the shader
  73854. * @param value Define the value to give to the uniform
  73855. * @return the material itself allowing "fluent" like uniform updates
  73856. */
  73857. setArray3(name: string, value: number[]): ShaderMaterial;
  73858. private _checkCache;
  73859. /**
  73860. * Checks if the material is ready to render the requested mesh
  73861. * @param mesh Define the mesh to render
  73862. * @param useInstances Define whether or not the material is used with instances
  73863. * @returns true if ready, otherwise false
  73864. */
  73865. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  73866. /**
  73867. * Binds the world matrix to the material
  73868. * @param world defines the world transformation matrix
  73869. */
  73870. bindOnlyWorldMatrix(world: Matrix): void;
  73871. /**
  73872. * Binds the material to the mesh
  73873. * @param world defines the world transformation matrix
  73874. * @param mesh defines the mesh to bind the material to
  73875. */
  73876. bind(world: Matrix, mesh?: Mesh): void;
  73877. /**
  73878. * Gets the active textures from the material
  73879. * @returns an array of textures
  73880. */
  73881. getActiveTextures(): BaseTexture[];
  73882. /**
  73883. * Specifies if the material uses a texture
  73884. * @param texture defines the texture to check against the material
  73885. * @returns a boolean specifying if the material uses the texture
  73886. */
  73887. hasTexture(texture: BaseTexture): boolean;
  73888. /**
  73889. * Makes a duplicate of the material, and gives it a new name
  73890. * @param name defines the new name for the duplicated material
  73891. * @returns the cloned material
  73892. */
  73893. clone(name: string): ShaderMaterial;
  73894. /**
  73895. * Disposes the material
  73896. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  73897. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  73898. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  73899. */
  73900. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  73901. /**
  73902. * Serializes this material in a JSON representation
  73903. * @returns the serialized material object
  73904. */
  73905. serialize(): any;
  73906. /**
  73907. * Creates a shader material from parsed shader material data
  73908. * @param source defines the JSON represnetation of the material
  73909. * @param scene defines the hosting scene
  73910. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73911. * @returns a new material
  73912. */
  73913. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  73914. }
  73915. }
  73916. declare module BABYLON {
  73917. /** @hidden */
  73918. export var colorPixelShader: {
  73919. name: string;
  73920. shader: string;
  73921. };
  73922. }
  73923. declare module BABYLON {
  73924. /** @hidden */
  73925. export var colorVertexShader: {
  73926. name: string;
  73927. shader: string;
  73928. };
  73929. }
  73930. declare module BABYLON {
  73931. /**
  73932. * Line mesh
  73933. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  73934. */
  73935. export class LinesMesh extends Mesh {
  73936. /**
  73937. * If vertex color should be applied to the mesh
  73938. */
  73939. useVertexColor?: boolean | undefined;
  73940. /**
  73941. * If vertex alpha should be applied to the mesh
  73942. */
  73943. useVertexAlpha?: boolean | undefined;
  73944. /**
  73945. * Color of the line (Default: White)
  73946. */
  73947. color: Color3;
  73948. /**
  73949. * Alpha of the line (Default: 1)
  73950. */
  73951. alpha: number;
  73952. /**
  73953. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  73954. * This margin is expressed in world space coordinates, so its value may vary.
  73955. * Default value is 0.1
  73956. */
  73957. intersectionThreshold: number;
  73958. private _colorShader;
  73959. /**
  73960. * Creates a new LinesMesh
  73961. * @param name defines the name
  73962. * @param scene defines the hosting scene
  73963. * @param parent defines the parent mesh if any
  73964. * @param source defines the optional source LinesMesh used to clone data from
  73965. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  73966. * When false, achieved by calling a clone(), also passing False.
  73967. * This will make creation of children, recursive.
  73968. * @param useVertexColor defines if this LinesMesh supports vertex color
  73969. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  73970. */
  73971. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  73972. /**
  73973. * If vertex color should be applied to the mesh
  73974. */
  73975. useVertexColor?: boolean | undefined,
  73976. /**
  73977. * If vertex alpha should be applied to the mesh
  73978. */
  73979. useVertexAlpha?: boolean | undefined);
  73980. /**
  73981. * Returns the string "LineMesh"
  73982. */
  73983. getClassName(): string;
  73984. /**
  73985. * @hidden
  73986. */
  73987. /**
  73988. * @hidden
  73989. */
  73990. material: Material;
  73991. /**
  73992. * @hidden
  73993. */
  73994. readonly checkCollisions: boolean;
  73995. /** @hidden */
  73996. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  73997. /** @hidden */
  73998. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  73999. /**
  74000. * Disposes of the line mesh
  74001. * @param doNotRecurse If children should be disposed
  74002. */
  74003. dispose(doNotRecurse?: boolean): void;
  74004. /**
  74005. * Returns a new LineMesh object cloned from the current one.
  74006. */
  74007. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  74008. /**
  74009. * Creates a new InstancedLinesMesh object from the mesh model.
  74010. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74011. * @param name defines the name of the new instance
  74012. * @returns a new InstancedLinesMesh
  74013. */
  74014. createInstance(name: string): InstancedLinesMesh;
  74015. }
  74016. /**
  74017. * Creates an instance based on a source LinesMesh
  74018. */
  74019. export class InstancedLinesMesh extends InstancedMesh {
  74020. /**
  74021. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74022. * This margin is expressed in world space coordinates, so its value may vary.
  74023. * Initilized with the intersectionThreshold value of the source LinesMesh
  74024. */
  74025. intersectionThreshold: number;
  74026. constructor(name: string, source: LinesMesh);
  74027. /**
  74028. * Returns the string "InstancedLinesMesh".
  74029. */
  74030. getClassName(): string;
  74031. }
  74032. }
  74033. declare module BABYLON {
  74034. /** @hidden */
  74035. export var linePixelShader: {
  74036. name: string;
  74037. shader: string;
  74038. };
  74039. }
  74040. declare module BABYLON {
  74041. /** @hidden */
  74042. export var lineVertexShader: {
  74043. name: string;
  74044. shader: string;
  74045. };
  74046. }
  74047. declare module BABYLON {
  74048. interface AbstractMesh {
  74049. /**
  74050. * Disables the mesh edge rendering mode
  74051. * @returns the currentAbstractMesh
  74052. */
  74053. disableEdgesRendering(): AbstractMesh;
  74054. /**
  74055. * Enables the edge rendering mode on the mesh.
  74056. * This mode makes the mesh edges visible
  74057. * @param epsilon defines the maximal distance between two angles to detect a face
  74058. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74059. * @returns the currentAbstractMesh
  74060. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74061. */
  74062. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74063. /**
  74064. * Gets the edgesRenderer associated with the mesh
  74065. */
  74066. edgesRenderer: Nullable<EdgesRenderer>;
  74067. }
  74068. interface LinesMesh {
  74069. /**
  74070. * Enables the edge rendering mode on the mesh.
  74071. * This mode makes the mesh edges visible
  74072. * @param epsilon defines the maximal distance between two angles to detect a face
  74073. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74074. * @returns the currentAbstractMesh
  74075. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74076. */
  74077. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74078. }
  74079. interface InstancedLinesMesh {
  74080. /**
  74081. * Enables the edge rendering mode on the mesh.
  74082. * This mode makes the mesh edges visible
  74083. * @param epsilon defines the maximal distance between two angles to detect a face
  74084. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74085. * @returns the current InstancedLinesMesh
  74086. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74087. */
  74088. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  74089. }
  74090. /**
  74091. * Defines the minimum contract an Edges renderer should follow.
  74092. */
  74093. export interface IEdgesRenderer extends IDisposable {
  74094. /**
  74095. * Gets or sets a boolean indicating if the edgesRenderer is active
  74096. */
  74097. isEnabled: boolean;
  74098. /**
  74099. * Renders the edges of the attached mesh,
  74100. */
  74101. render(): void;
  74102. /**
  74103. * Checks wether or not the edges renderer is ready to render.
  74104. * @return true if ready, otherwise false.
  74105. */
  74106. isReady(): boolean;
  74107. }
  74108. /**
  74109. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  74110. */
  74111. export class EdgesRenderer implements IEdgesRenderer {
  74112. /**
  74113. * Define the size of the edges with an orthographic camera
  74114. */
  74115. edgesWidthScalerForOrthographic: number;
  74116. /**
  74117. * Define the size of the edges with a perspective camera
  74118. */
  74119. edgesWidthScalerForPerspective: number;
  74120. protected _source: AbstractMesh;
  74121. protected _linesPositions: number[];
  74122. protected _linesNormals: number[];
  74123. protected _linesIndices: number[];
  74124. protected _epsilon: number;
  74125. protected _indicesCount: number;
  74126. protected _lineShader: ShaderMaterial;
  74127. protected _ib: WebGLBuffer;
  74128. protected _buffers: {
  74129. [key: string]: Nullable<VertexBuffer>;
  74130. };
  74131. protected _checkVerticesInsteadOfIndices: boolean;
  74132. private _meshRebuildObserver;
  74133. private _meshDisposeObserver;
  74134. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  74135. isEnabled: boolean;
  74136. /**
  74137. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  74138. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  74139. * @param source Mesh used to create edges
  74140. * @param epsilon sum of angles in adjacency to check for edge
  74141. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  74142. * @param generateEdgesLines - should generate Lines or only prepare resources.
  74143. */
  74144. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  74145. protected _prepareRessources(): void;
  74146. /** @hidden */
  74147. _rebuild(): void;
  74148. /**
  74149. * Releases the required resources for the edges renderer
  74150. */
  74151. dispose(): void;
  74152. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  74153. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  74154. /**
  74155. * Checks if the pair of p0 and p1 is en edge
  74156. * @param faceIndex
  74157. * @param edge
  74158. * @param faceNormals
  74159. * @param p0
  74160. * @param p1
  74161. * @private
  74162. */
  74163. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  74164. /**
  74165. * push line into the position, normal and index buffer
  74166. * @protected
  74167. */
  74168. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  74169. /**
  74170. * Generates lines edges from adjacencjes
  74171. * @private
  74172. */
  74173. _generateEdgesLines(): void;
  74174. /**
  74175. * Checks wether or not the edges renderer is ready to render.
  74176. * @return true if ready, otherwise false.
  74177. */
  74178. isReady(): boolean;
  74179. /**
  74180. * Renders the edges of the attached mesh,
  74181. */
  74182. render(): void;
  74183. }
  74184. /**
  74185. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  74186. */
  74187. export class LineEdgesRenderer extends EdgesRenderer {
  74188. /**
  74189. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  74190. * @param source LineMesh used to generate edges
  74191. * @param epsilon not important (specified angle for edge detection)
  74192. * @param checkVerticesInsteadOfIndices not important for LineMesh
  74193. */
  74194. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  74195. /**
  74196. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  74197. */
  74198. _generateEdgesLines(): void;
  74199. }
  74200. }
  74201. declare module BABYLON {
  74202. /**
  74203. * This represents the object necessary to create a rendering group.
  74204. * This is exclusively used and created by the rendering manager.
  74205. * To modify the behavior, you use the available helpers in your scene or meshes.
  74206. * @hidden
  74207. */
  74208. export class RenderingGroup {
  74209. index: number;
  74210. private _scene;
  74211. private _opaqueSubMeshes;
  74212. private _transparentSubMeshes;
  74213. private _alphaTestSubMeshes;
  74214. private _depthOnlySubMeshes;
  74215. private _particleSystems;
  74216. private _spriteManagers;
  74217. private _opaqueSortCompareFn;
  74218. private _alphaTestSortCompareFn;
  74219. private _transparentSortCompareFn;
  74220. private _renderOpaque;
  74221. private _renderAlphaTest;
  74222. private _renderTransparent;
  74223. private _edgesRenderers;
  74224. onBeforeTransparentRendering: () => void;
  74225. /**
  74226. * Set the opaque sort comparison function.
  74227. * If null the sub meshes will be render in the order they were created
  74228. */
  74229. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74230. /**
  74231. * Set the alpha test sort comparison function.
  74232. * If null the sub meshes will be render in the order they were created
  74233. */
  74234. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74235. /**
  74236. * Set the transparent sort comparison function.
  74237. * If null the sub meshes will be render in the order they were created
  74238. */
  74239. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74240. /**
  74241. * Creates a new rendering group.
  74242. * @param index The rendering group index
  74243. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  74244. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  74245. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  74246. */
  74247. 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>);
  74248. /**
  74249. * Render all the sub meshes contained in the group.
  74250. * @param customRenderFunction Used to override the default render behaviour of the group.
  74251. * @returns true if rendered some submeshes.
  74252. */
  74253. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  74254. /**
  74255. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  74256. * @param subMeshes The submeshes to render
  74257. */
  74258. private renderOpaqueSorted;
  74259. /**
  74260. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  74261. * @param subMeshes The submeshes to render
  74262. */
  74263. private renderAlphaTestSorted;
  74264. /**
  74265. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  74266. * @param subMeshes The submeshes to render
  74267. */
  74268. private renderTransparentSorted;
  74269. /**
  74270. * Renders the submeshes in a specified order.
  74271. * @param subMeshes The submeshes to sort before render
  74272. * @param sortCompareFn The comparison function use to sort
  74273. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  74274. * @param transparent Specifies to activate blending if true
  74275. */
  74276. private static renderSorted;
  74277. /**
  74278. * Renders the submeshes in the order they were dispatched (no sort applied).
  74279. * @param subMeshes The submeshes to render
  74280. */
  74281. private static renderUnsorted;
  74282. /**
  74283. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74284. * are rendered back to front if in the same alpha index.
  74285. *
  74286. * @param a The first submesh
  74287. * @param b The second submesh
  74288. * @returns The result of the comparison
  74289. */
  74290. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  74291. /**
  74292. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74293. * are rendered back to front.
  74294. *
  74295. * @param a The first submesh
  74296. * @param b The second submesh
  74297. * @returns The result of the comparison
  74298. */
  74299. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  74300. /**
  74301. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74302. * are rendered front to back (prevent overdraw).
  74303. *
  74304. * @param a The first submesh
  74305. * @param b The second submesh
  74306. * @returns The result of the comparison
  74307. */
  74308. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  74309. /**
  74310. * Resets the different lists of submeshes to prepare a new frame.
  74311. */
  74312. prepare(): void;
  74313. dispose(): void;
  74314. /**
  74315. * Inserts the submesh in its correct queue depending on its material.
  74316. * @param subMesh The submesh to dispatch
  74317. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74318. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74319. */
  74320. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74321. dispatchSprites(spriteManager: ISpriteManager): void;
  74322. dispatchParticles(particleSystem: IParticleSystem): void;
  74323. private _renderParticles;
  74324. private _renderSprites;
  74325. }
  74326. }
  74327. declare module BABYLON {
  74328. /**
  74329. * Interface describing the different options available in the rendering manager
  74330. * regarding Auto Clear between groups.
  74331. */
  74332. export interface IRenderingManagerAutoClearSetup {
  74333. /**
  74334. * Defines whether or not autoclear is enable.
  74335. */
  74336. autoClear: boolean;
  74337. /**
  74338. * Defines whether or not to autoclear the depth buffer.
  74339. */
  74340. depth: boolean;
  74341. /**
  74342. * Defines whether or not to autoclear the stencil buffer.
  74343. */
  74344. stencil: boolean;
  74345. }
  74346. /**
  74347. * This class is used by the onRenderingGroupObservable
  74348. */
  74349. export class RenderingGroupInfo {
  74350. /**
  74351. * The Scene that being rendered
  74352. */
  74353. scene: Scene;
  74354. /**
  74355. * The camera currently used for the rendering pass
  74356. */
  74357. camera: Nullable<Camera>;
  74358. /**
  74359. * The ID of the renderingGroup being processed
  74360. */
  74361. renderingGroupId: number;
  74362. }
  74363. /**
  74364. * This is the manager responsible of all the rendering for meshes sprites and particles.
  74365. * It is enable to manage the different groups as well as the different necessary sort functions.
  74366. * This should not be used directly aside of the few static configurations
  74367. */
  74368. export class RenderingManager {
  74369. /**
  74370. * The max id used for rendering groups (not included)
  74371. */
  74372. static MAX_RENDERINGGROUPS: number;
  74373. /**
  74374. * The min id used for rendering groups (included)
  74375. */
  74376. static MIN_RENDERINGGROUPS: number;
  74377. /**
  74378. * Used to globally prevent autoclearing scenes.
  74379. */
  74380. static AUTOCLEAR: boolean;
  74381. /**
  74382. * @hidden
  74383. */
  74384. _useSceneAutoClearSetup: boolean;
  74385. private _scene;
  74386. private _renderingGroups;
  74387. private _depthStencilBufferAlreadyCleaned;
  74388. private _autoClearDepthStencil;
  74389. private _customOpaqueSortCompareFn;
  74390. private _customAlphaTestSortCompareFn;
  74391. private _customTransparentSortCompareFn;
  74392. private _renderingGroupInfo;
  74393. /**
  74394. * Instantiates a new rendering group for a particular scene
  74395. * @param scene Defines the scene the groups belongs to
  74396. */
  74397. constructor(scene: Scene);
  74398. private _clearDepthStencilBuffer;
  74399. /**
  74400. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  74401. * @hidden
  74402. */
  74403. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  74404. /**
  74405. * Resets the different information of the group to prepare a new frame
  74406. * @hidden
  74407. */
  74408. reset(): void;
  74409. /**
  74410. * Dispose and release the group and its associated resources.
  74411. * @hidden
  74412. */
  74413. dispose(): void;
  74414. /**
  74415. * Clear the info related to rendering groups preventing retention points during dispose.
  74416. */
  74417. freeRenderingGroups(): void;
  74418. private _prepareRenderingGroup;
  74419. /**
  74420. * Add a sprite manager to the rendering manager in order to render it this frame.
  74421. * @param spriteManager Define the sprite manager to render
  74422. */
  74423. dispatchSprites(spriteManager: ISpriteManager): void;
  74424. /**
  74425. * Add a particle system to the rendering manager in order to render it this frame.
  74426. * @param particleSystem Define the particle system to render
  74427. */
  74428. dispatchParticles(particleSystem: IParticleSystem): void;
  74429. /**
  74430. * Add a submesh to the manager in order to render it this frame
  74431. * @param subMesh The submesh to dispatch
  74432. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74433. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74434. */
  74435. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74436. /**
  74437. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74438. * This allowed control for front to back rendering or reversly depending of the special needs.
  74439. *
  74440. * @param renderingGroupId The rendering group id corresponding to its index
  74441. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74442. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74443. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74444. */
  74445. 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;
  74446. /**
  74447. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74448. *
  74449. * @param renderingGroupId The rendering group id corresponding to its index
  74450. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74451. * @param depth Automatically clears depth between groups if true and autoClear is true.
  74452. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  74453. */
  74454. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  74455. /**
  74456. * Gets the current auto clear configuration for one rendering group of the rendering
  74457. * manager.
  74458. * @param index the rendering group index to get the information for
  74459. * @returns The auto clear setup for the requested rendering group
  74460. */
  74461. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  74462. }
  74463. }
  74464. declare module BABYLON {
  74465. /**
  74466. * This Helps creating a texture that will be created from a camera in your scene.
  74467. * It is basically a dynamic texture that could be used to create special effects for instance.
  74468. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  74469. */
  74470. export class RenderTargetTexture extends Texture {
  74471. isCube: boolean;
  74472. /**
  74473. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  74474. */
  74475. static readonly REFRESHRATE_RENDER_ONCE: number;
  74476. /**
  74477. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  74478. */
  74479. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  74480. /**
  74481. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  74482. * the central point of your effect and can save a lot of performances.
  74483. */
  74484. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  74485. /**
  74486. * Use this predicate to dynamically define the list of mesh you want to render.
  74487. * If set, the renderList property will be overwritten.
  74488. */
  74489. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  74490. private _renderList;
  74491. /**
  74492. * Use this list to define the list of mesh you want to render.
  74493. */
  74494. renderList: Nullable<Array<AbstractMesh>>;
  74495. private _hookArray;
  74496. /**
  74497. * Define if particles should be rendered in your texture.
  74498. */
  74499. renderParticles: boolean;
  74500. /**
  74501. * Define if sprites should be rendered in your texture.
  74502. */
  74503. renderSprites: boolean;
  74504. /**
  74505. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  74506. */
  74507. coordinatesMode: number;
  74508. /**
  74509. * Define the camera used to render the texture.
  74510. */
  74511. activeCamera: Nullable<Camera>;
  74512. /**
  74513. * Override the render function of the texture with your own one.
  74514. */
  74515. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  74516. /**
  74517. * Define if camera post processes should be use while rendering the texture.
  74518. */
  74519. useCameraPostProcesses: boolean;
  74520. /**
  74521. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  74522. */
  74523. ignoreCameraViewport: boolean;
  74524. private _postProcessManager;
  74525. private _postProcesses;
  74526. private _resizeObserver;
  74527. /**
  74528. * An event triggered when the texture is unbind.
  74529. */
  74530. onBeforeBindObservable: Observable<RenderTargetTexture>;
  74531. /**
  74532. * An event triggered when the texture is unbind.
  74533. */
  74534. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  74535. private _onAfterUnbindObserver;
  74536. /**
  74537. * Set a after unbind callback in the texture.
  74538. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  74539. */
  74540. onAfterUnbind: () => void;
  74541. /**
  74542. * An event triggered before rendering the texture
  74543. */
  74544. onBeforeRenderObservable: Observable<number>;
  74545. private _onBeforeRenderObserver;
  74546. /**
  74547. * Set a before render callback in the texture.
  74548. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  74549. */
  74550. onBeforeRender: (faceIndex: number) => void;
  74551. /**
  74552. * An event triggered after rendering the texture
  74553. */
  74554. onAfterRenderObservable: Observable<number>;
  74555. private _onAfterRenderObserver;
  74556. /**
  74557. * Set a after render callback in the texture.
  74558. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  74559. */
  74560. onAfterRender: (faceIndex: number) => void;
  74561. /**
  74562. * An event triggered after the texture clear
  74563. */
  74564. onClearObservable: Observable<Engine>;
  74565. private _onClearObserver;
  74566. /**
  74567. * Set a clear callback in the texture.
  74568. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  74569. */
  74570. onClear: (Engine: Engine) => void;
  74571. /**
  74572. * Define the clear color of the Render Target if it should be different from the scene.
  74573. */
  74574. clearColor: Color4;
  74575. protected _size: number | {
  74576. width: number;
  74577. height: number;
  74578. };
  74579. protected _initialSizeParameter: number | {
  74580. width: number;
  74581. height: number;
  74582. } | {
  74583. ratio: number;
  74584. };
  74585. protected _sizeRatio: Nullable<number>;
  74586. /** @hidden */
  74587. _generateMipMaps: boolean;
  74588. protected _renderingManager: RenderingManager;
  74589. /** @hidden */
  74590. _waitingRenderList: string[];
  74591. protected _doNotChangeAspectRatio: boolean;
  74592. protected _currentRefreshId: number;
  74593. protected _refreshRate: number;
  74594. protected _textureMatrix: Matrix;
  74595. protected _samples: number;
  74596. protected _renderTargetOptions: RenderTargetCreationOptions;
  74597. /**
  74598. * Gets render target creation options that were used.
  74599. */
  74600. readonly renderTargetOptions: RenderTargetCreationOptions;
  74601. protected _engine: Engine;
  74602. protected _onRatioRescale(): void;
  74603. /**
  74604. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  74605. * It must define where the camera used to render the texture is set
  74606. */
  74607. boundingBoxPosition: Vector3;
  74608. private _boundingBoxSize;
  74609. /**
  74610. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  74611. * When defined, the cubemap will switch to local mode
  74612. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74613. * @example https://www.babylonjs-playground.com/#RNASML
  74614. */
  74615. boundingBoxSize: Vector3;
  74616. /**
  74617. * In case the RTT has been created with a depth texture, get the associated
  74618. * depth texture.
  74619. * Otherwise, return null.
  74620. */
  74621. depthStencilTexture: Nullable<InternalTexture>;
  74622. /**
  74623. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  74624. * or used a shadow, depth texture...
  74625. * @param name The friendly name of the texture
  74626. * @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)
  74627. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  74628. * @param generateMipMaps True if mip maps need to be generated after render.
  74629. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  74630. * @param type The type of the buffer in the RTT (int, half float, float...)
  74631. * @param isCube True if a cube texture needs to be created
  74632. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  74633. * @param generateDepthBuffer True to generate a depth buffer
  74634. * @param generateStencilBuffer True to generate a stencil buffer
  74635. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  74636. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  74637. * @param delayAllocation if the texture allocation should be delayed (default: false)
  74638. */
  74639. constructor(name: string, size: number | {
  74640. width: number;
  74641. height: number;
  74642. } | {
  74643. ratio: number;
  74644. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  74645. /**
  74646. * Creates a depth stencil texture.
  74647. * This is only available in WebGL 2 or with the depth texture extension available.
  74648. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  74649. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  74650. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  74651. */
  74652. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  74653. private _processSizeParameter;
  74654. /**
  74655. * Define the number of samples to use in case of MSAA.
  74656. * It defaults to one meaning no MSAA has been enabled.
  74657. */
  74658. samples: number;
  74659. /**
  74660. * Resets the refresh counter of the texture and start bak from scratch.
  74661. * Could be useful to regenerate the texture if it is setup to render only once.
  74662. */
  74663. resetRefreshCounter(): void;
  74664. /**
  74665. * Define the refresh rate of the texture or the rendering frequency.
  74666. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74667. */
  74668. refreshRate: number;
  74669. /**
  74670. * Adds a post process to the render target rendering passes.
  74671. * @param postProcess define the post process to add
  74672. */
  74673. addPostProcess(postProcess: PostProcess): void;
  74674. /**
  74675. * Clear all the post processes attached to the render target
  74676. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  74677. */
  74678. clearPostProcesses(dispose?: boolean): void;
  74679. /**
  74680. * Remove one of the post process from the list of attached post processes to the texture
  74681. * @param postProcess define the post process to remove from the list
  74682. */
  74683. removePostProcess(postProcess: PostProcess): void;
  74684. /** @hidden */
  74685. _shouldRender(): boolean;
  74686. /**
  74687. * Gets the actual render size of the texture.
  74688. * @returns the width of the render size
  74689. */
  74690. getRenderSize(): number;
  74691. /**
  74692. * Gets the actual render width of the texture.
  74693. * @returns the width of the render size
  74694. */
  74695. getRenderWidth(): number;
  74696. /**
  74697. * Gets the actual render height of the texture.
  74698. * @returns the height of the render size
  74699. */
  74700. getRenderHeight(): number;
  74701. /**
  74702. * Get if the texture can be rescaled or not.
  74703. */
  74704. readonly canRescale: boolean;
  74705. /**
  74706. * Resize the texture using a ratio.
  74707. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  74708. */
  74709. scale(ratio: number): void;
  74710. /**
  74711. * Get the texture reflection matrix used to rotate/transform the reflection.
  74712. * @returns the reflection matrix
  74713. */
  74714. getReflectionTextureMatrix(): Matrix;
  74715. /**
  74716. * Resize the texture to a new desired size.
  74717. * Be carrefull as it will recreate all the data in the new texture.
  74718. * @param size Define the new size. It can be:
  74719. * - a number for squared texture,
  74720. * - an object containing { width: number, height: number }
  74721. * - or an object containing a ratio { ratio: number }
  74722. */
  74723. resize(size: number | {
  74724. width: number;
  74725. height: number;
  74726. } | {
  74727. ratio: number;
  74728. }): void;
  74729. /**
  74730. * Renders all the objects from the render list into the texture.
  74731. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  74732. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  74733. */
  74734. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  74735. private _bestReflectionRenderTargetDimension;
  74736. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  74737. private renderToTarget;
  74738. /**
  74739. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74740. * This allowed control for front to back rendering or reversly depending of the special needs.
  74741. *
  74742. * @param renderingGroupId The rendering group id corresponding to its index
  74743. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74744. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74745. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74746. */
  74747. 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;
  74748. /**
  74749. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74750. *
  74751. * @param renderingGroupId The rendering group id corresponding to its index
  74752. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74753. */
  74754. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  74755. /**
  74756. * Clones the texture.
  74757. * @returns the cloned texture
  74758. */
  74759. clone(): RenderTargetTexture;
  74760. /**
  74761. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  74762. * @returns The JSON representation of the texture
  74763. */
  74764. serialize(): any;
  74765. /**
  74766. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  74767. */
  74768. disposeFramebufferObjects(): void;
  74769. /**
  74770. * Dispose the texture and release its associated resources.
  74771. */
  74772. dispose(): void;
  74773. /** @hidden */
  74774. _rebuild(): void;
  74775. /**
  74776. * Clear the info related to rendering groups preventing retention point in material dispose.
  74777. */
  74778. freeRenderingGroups(): void;
  74779. }
  74780. }
  74781. declare module BABYLON {
  74782. /**
  74783. * Mirror texture can be used to simulate the view from a mirror in a scene.
  74784. * It will dynamically be rendered every frame to adapt to the camera point of view.
  74785. * You can then easily use it as a reflectionTexture on a flat surface.
  74786. * In case the surface is not a plane, please consider relying on reflection probes.
  74787. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74788. */
  74789. export class MirrorTexture extends RenderTargetTexture {
  74790. private scene;
  74791. /**
  74792. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  74793. * 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.
  74794. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74795. */
  74796. mirrorPlane: Plane;
  74797. /**
  74798. * Define the blur ratio used to blur the reflection if needed.
  74799. */
  74800. blurRatio: number;
  74801. /**
  74802. * Define the adaptive blur kernel used to blur the reflection if needed.
  74803. * This will autocompute the closest best match for the `blurKernel`
  74804. */
  74805. adaptiveBlurKernel: number;
  74806. /**
  74807. * Define the blur kernel used to blur the reflection if needed.
  74808. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74809. */
  74810. blurKernel: number;
  74811. /**
  74812. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  74813. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74814. */
  74815. blurKernelX: number;
  74816. /**
  74817. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  74818. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74819. */
  74820. blurKernelY: number;
  74821. private _autoComputeBlurKernel;
  74822. protected _onRatioRescale(): void;
  74823. private _updateGammaSpace;
  74824. private _imageProcessingConfigChangeObserver;
  74825. private _transformMatrix;
  74826. private _mirrorMatrix;
  74827. private _savedViewMatrix;
  74828. private _blurX;
  74829. private _blurY;
  74830. private _adaptiveBlurKernel;
  74831. private _blurKernelX;
  74832. private _blurKernelY;
  74833. private _blurRatio;
  74834. /**
  74835. * Instantiates a Mirror Texture.
  74836. * Mirror texture can be used to simulate the view from a mirror in a scene.
  74837. * It will dynamically be rendered every frame to adapt to the camera point of view.
  74838. * You can then easily use it as a reflectionTexture on a flat surface.
  74839. * In case the surface is not a plane, please consider relying on reflection probes.
  74840. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74841. * @param name
  74842. * @param size
  74843. * @param scene
  74844. * @param generateMipMaps
  74845. * @param type
  74846. * @param samplingMode
  74847. * @param generateDepthBuffer
  74848. */
  74849. constructor(name: string, size: number | {
  74850. width: number;
  74851. height: number;
  74852. } | {
  74853. ratio: number;
  74854. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  74855. private _preparePostProcesses;
  74856. /**
  74857. * Clone the mirror texture.
  74858. * @returns the cloned texture
  74859. */
  74860. clone(): MirrorTexture;
  74861. /**
  74862. * Serialize the texture to a JSON representation you could use in Parse later on
  74863. * @returns the serialized JSON representation
  74864. */
  74865. serialize(): any;
  74866. /**
  74867. * Dispose the texture and release its associated resources.
  74868. */
  74869. dispose(): void;
  74870. }
  74871. }
  74872. declare module BABYLON {
  74873. /**
  74874. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  74875. * @see http://doc.babylonjs.com/babylon101/materials#texture
  74876. */
  74877. export class Texture extends BaseTexture {
  74878. /** @hidden */
  74879. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  74880. /** @hidden */
  74881. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  74882. /** @hidden */
  74883. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  74884. /** nearest is mag = nearest and min = nearest and mip = linear */
  74885. static readonly NEAREST_SAMPLINGMODE: number;
  74886. /** nearest is mag = nearest and min = nearest and mip = linear */
  74887. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  74888. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74889. static readonly BILINEAR_SAMPLINGMODE: number;
  74890. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74891. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  74892. /** Trilinear is mag = linear and min = linear and mip = linear */
  74893. static readonly TRILINEAR_SAMPLINGMODE: number;
  74894. /** Trilinear is mag = linear and min = linear and mip = linear */
  74895. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  74896. /** mag = nearest and min = nearest and mip = nearest */
  74897. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  74898. /** mag = nearest and min = linear and mip = nearest */
  74899. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  74900. /** mag = nearest and min = linear and mip = linear */
  74901. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  74902. /** mag = nearest and min = linear and mip = none */
  74903. static readonly NEAREST_LINEAR: number;
  74904. /** mag = nearest and min = nearest and mip = none */
  74905. static readonly NEAREST_NEAREST: number;
  74906. /** mag = linear and min = nearest and mip = nearest */
  74907. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  74908. /** mag = linear and min = nearest and mip = linear */
  74909. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  74910. /** mag = linear and min = linear and mip = none */
  74911. static readonly LINEAR_LINEAR: number;
  74912. /** mag = linear and min = nearest and mip = none */
  74913. static readonly LINEAR_NEAREST: number;
  74914. /** Explicit coordinates mode */
  74915. static readonly EXPLICIT_MODE: number;
  74916. /** Spherical coordinates mode */
  74917. static readonly SPHERICAL_MODE: number;
  74918. /** Planar coordinates mode */
  74919. static readonly PLANAR_MODE: number;
  74920. /** Cubic coordinates mode */
  74921. static readonly CUBIC_MODE: number;
  74922. /** Projection coordinates mode */
  74923. static readonly PROJECTION_MODE: number;
  74924. /** Inverse Cubic coordinates mode */
  74925. static readonly SKYBOX_MODE: number;
  74926. /** Inverse Cubic coordinates mode */
  74927. static readonly INVCUBIC_MODE: number;
  74928. /** Equirectangular coordinates mode */
  74929. static readonly EQUIRECTANGULAR_MODE: number;
  74930. /** Equirectangular Fixed coordinates mode */
  74931. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  74932. /** Equirectangular Fixed Mirrored coordinates mode */
  74933. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74934. /** Texture is not repeating outside of 0..1 UVs */
  74935. static readonly CLAMP_ADDRESSMODE: number;
  74936. /** Texture is repeating outside of 0..1 UVs */
  74937. static readonly WRAP_ADDRESSMODE: number;
  74938. /** Texture is repeating and mirrored */
  74939. static readonly MIRROR_ADDRESSMODE: number;
  74940. /**
  74941. * 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
  74942. */
  74943. static UseSerializedUrlIfAny: boolean;
  74944. /**
  74945. * Define the url of the texture.
  74946. */
  74947. url: Nullable<string>;
  74948. /**
  74949. * Define an offset on the texture to offset the u coordinates of the UVs
  74950. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  74951. */
  74952. uOffset: number;
  74953. /**
  74954. * Define an offset on the texture to offset the v coordinates of the UVs
  74955. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  74956. */
  74957. vOffset: number;
  74958. /**
  74959. * Define an offset on the texture to scale the u coordinates of the UVs
  74960. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  74961. */
  74962. uScale: number;
  74963. /**
  74964. * Define an offset on the texture to scale the v coordinates of the UVs
  74965. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  74966. */
  74967. vScale: number;
  74968. /**
  74969. * Define an offset on the texture to rotate around the u coordinates of the UVs
  74970. * @see http://doc.babylonjs.com/how_to/more_materials
  74971. */
  74972. uAng: number;
  74973. /**
  74974. * Define an offset on the texture to rotate around the v coordinates of the UVs
  74975. * @see http://doc.babylonjs.com/how_to/more_materials
  74976. */
  74977. vAng: number;
  74978. /**
  74979. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  74980. * @see http://doc.babylonjs.com/how_to/more_materials
  74981. */
  74982. wAng: number;
  74983. /**
  74984. * Defines the center of rotation (U)
  74985. */
  74986. uRotationCenter: number;
  74987. /**
  74988. * Defines the center of rotation (V)
  74989. */
  74990. vRotationCenter: number;
  74991. /**
  74992. * Defines the center of rotation (W)
  74993. */
  74994. wRotationCenter: number;
  74995. /**
  74996. * Are mip maps generated for this texture or not.
  74997. */
  74998. readonly noMipmap: boolean;
  74999. private _noMipmap;
  75000. /** @hidden */
  75001. _invertY: boolean;
  75002. private _rowGenerationMatrix;
  75003. private _cachedTextureMatrix;
  75004. private _projectionModeMatrix;
  75005. private _t0;
  75006. private _t1;
  75007. private _t2;
  75008. private _cachedUOffset;
  75009. private _cachedVOffset;
  75010. private _cachedUScale;
  75011. private _cachedVScale;
  75012. private _cachedUAng;
  75013. private _cachedVAng;
  75014. private _cachedWAng;
  75015. private _cachedProjectionMatrixId;
  75016. private _cachedCoordinatesMode;
  75017. /** @hidden */
  75018. protected _initialSamplingMode: number;
  75019. /** @hidden */
  75020. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  75021. private _deleteBuffer;
  75022. protected _format: Nullable<number>;
  75023. private _delayedOnLoad;
  75024. private _delayedOnError;
  75025. /**
  75026. * Observable triggered once the texture has been loaded.
  75027. */
  75028. onLoadObservable: Observable<Texture>;
  75029. protected _isBlocking: boolean;
  75030. /**
  75031. * Is the texture preventing material to render while loading.
  75032. * If false, a default texture will be used instead of the loading one during the preparation step.
  75033. */
  75034. isBlocking: boolean;
  75035. /**
  75036. * Get the current sampling mode associated with the texture.
  75037. */
  75038. readonly samplingMode: number;
  75039. /**
  75040. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  75041. */
  75042. readonly invertY: boolean;
  75043. /**
  75044. * Instantiates a new texture.
  75045. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75046. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75047. * @param url define the url of the picture to load as a texture
  75048. * @param scene define the scene the texture will belong to
  75049. * @param noMipmap define if the texture will require mip maps or not
  75050. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75051. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75052. * @param onLoad define a callback triggered when the texture has been loaded
  75053. * @param onError define a callback triggered when an error occurred during the loading session
  75054. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75055. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75056. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75057. */
  75058. 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);
  75059. /**
  75060. * Update the url (and optional buffer) of this texture if url was null during construction.
  75061. * @param url the url of the texture
  75062. * @param buffer the buffer of the texture (defaults to null)
  75063. * @param onLoad callback called when the texture is loaded (defaults to null)
  75064. */
  75065. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  75066. /**
  75067. * Finish the loading sequence of a texture flagged as delayed load.
  75068. * @hidden
  75069. */
  75070. delayLoad(): void;
  75071. private _prepareRowForTextureGeneration;
  75072. /**
  75073. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  75074. * @returns the transform matrix of the texture.
  75075. */
  75076. getTextureMatrix(): Matrix;
  75077. /**
  75078. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  75079. * @returns The reflection texture transform
  75080. */
  75081. getReflectionTextureMatrix(): Matrix;
  75082. /**
  75083. * Clones the texture.
  75084. * @returns the cloned texture
  75085. */
  75086. clone(): Texture;
  75087. /**
  75088. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75089. * @returns The JSON representation of the texture
  75090. */
  75091. serialize(): any;
  75092. /**
  75093. * Get the current class name of the texture useful for serialization or dynamic coding.
  75094. * @returns "Texture"
  75095. */
  75096. getClassName(): string;
  75097. /**
  75098. * Dispose the texture and release its associated resources.
  75099. */
  75100. dispose(): void;
  75101. /**
  75102. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  75103. * @param parsedTexture Define the JSON representation of the texture
  75104. * @param scene Define the scene the parsed texture should be instantiated in
  75105. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  75106. * @returns The parsed texture if successful
  75107. */
  75108. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  75109. /**
  75110. * Creates a texture from its base 64 representation.
  75111. * @param data Define the base64 payload without the data: prefix
  75112. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75113. * @param scene Define the scene the texture should belong to
  75114. * @param noMipmap Forces the texture to not create mip map information if true
  75115. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75116. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75117. * @param onLoad define a callback triggered when the texture has been loaded
  75118. * @param onError define a callback triggered when an error occurred during the loading session
  75119. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75120. * @returns the created texture
  75121. */
  75122. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  75123. /**
  75124. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  75125. * @param data Define the base64 payload without the data: prefix
  75126. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75127. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75128. * @param scene Define the scene the texture should belong to
  75129. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75130. * @param noMipmap Forces the texture to not create mip map information if true
  75131. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75132. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75133. * @param onLoad define a callback triggered when the texture has been loaded
  75134. * @param onError define a callback triggered when an error occurred during the loading session
  75135. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75136. * @returns the created texture
  75137. */
  75138. 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;
  75139. }
  75140. }
  75141. declare module BABYLON {
  75142. /**
  75143. * Raw texture can help creating a texture directly from an array of data.
  75144. * This can be super useful if you either get the data from an uncompressed source or
  75145. * if you wish to create your texture pixel by pixel.
  75146. */
  75147. export class RawTexture extends Texture {
  75148. /**
  75149. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75150. */
  75151. format: number;
  75152. private _engine;
  75153. /**
  75154. * Instantiates a new RawTexture.
  75155. * Raw texture can help creating a texture directly from an array of data.
  75156. * This can be super useful if you either get the data from an uncompressed source or
  75157. * if you wish to create your texture pixel by pixel.
  75158. * @param data define the array of data to use to create the texture
  75159. * @param width define the width of the texture
  75160. * @param height define the height of the texture
  75161. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75162. * @param scene define the scene the texture belongs to
  75163. * @param generateMipMaps define whether mip maps should be generated or not
  75164. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75165. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75166. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75167. */
  75168. constructor(data: ArrayBufferView, width: number, height: number,
  75169. /**
  75170. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75171. */
  75172. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  75173. /**
  75174. * Updates the texture underlying data.
  75175. * @param data Define the new data of the texture
  75176. */
  75177. update(data: ArrayBufferView): void;
  75178. /**
  75179. * Creates a luminance texture from some data.
  75180. * @param data Define the texture data
  75181. * @param width Define the width of the texture
  75182. * @param height Define the height of the texture
  75183. * @param scene Define the scene the texture belongs to
  75184. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75185. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75186. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75187. * @returns the luminance texture
  75188. */
  75189. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75190. /**
  75191. * Creates a luminance alpha texture from some data.
  75192. * @param data Define the texture data
  75193. * @param width Define the width of the texture
  75194. * @param height Define the height of the texture
  75195. * @param scene Define the scene the texture belongs to
  75196. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75197. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75198. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75199. * @returns the luminance alpha texture
  75200. */
  75201. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75202. /**
  75203. * Creates an alpha texture from some data.
  75204. * @param data Define the texture data
  75205. * @param width Define the width of the texture
  75206. * @param height Define the height of the texture
  75207. * @param scene Define the scene the texture belongs to
  75208. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75209. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75210. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75211. * @returns the alpha texture
  75212. */
  75213. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75214. /**
  75215. * Creates a RGB texture from some data.
  75216. * @param data Define the texture data
  75217. * @param width Define the width of the texture
  75218. * @param height Define the height of the texture
  75219. * @param scene Define the scene the texture belongs to
  75220. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75221. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75222. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75223. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75224. * @returns the RGB alpha texture
  75225. */
  75226. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75227. /**
  75228. * Creates a RGBA texture from some data.
  75229. * @param data Define the texture data
  75230. * @param width Define the width of the texture
  75231. * @param height Define the height of the texture
  75232. * @param scene Define the scene the texture belongs to
  75233. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75234. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75235. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75236. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75237. * @returns the RGBA texture
  75238. */
  75239. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75240. /**
  75241. * Creates a R texture from some data.
  75242. * @param data Define the texture data
  75243. * @param width Define the width of the texture
  75244. * @param height Define the height of the texture
  75245. * @param scene Define the scene the texture belongs to
  75246. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75247. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75248. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75249. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75250. * @returns the R texture
  75251. */
  75252. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75253. }
  75254. }
  75255. declare module BABYLON {
  75256. /**
  75257. * Defines a runtime animation
  75258. */
  75259. export class RuntimeAnimation {
  75260. private _events;
  75261. /**
  75262. * The current frame of the runtime animation
  75263. */
  75264. private _currentFrame;
  75265. /**
  75266. * The animation used by the runtime animation
  75267. */
  75268. private _animation;
  75269. /**
  75270. * The target of the runtime animation
  75271. */
  75272. private _target;
  75273. /**
  75274. * The initiating animatable
  75275. */
  75276. private _host;
  75277. /**
  75278. * The original value of the runtime animation
  75279. */
  75280. private _originalValue;
  75281. /**
  75282. * The original blend value of the runtime animation
  75283. */
  75284. private _originalBlendValue;
  75285. /**
  75286. * The offsets cache of the runtime animation
  75287. */
  75288. private _offsetsCache;
  75289. /**
  75290. * The high limits cache of the runtime animation
  75291. */
  75292. private _highLimitsCache;
  75293. /**
  75294. * Specifies if the runtime animation has been stopped
  75295. */
  75296. private _stopped;
  75297. /**
  75298. * The blending factor of the runtime animation
  75299. */
  75300. private _blendingFactor;
  75301. /**
  75302. * The BabylonJS scene
  75303. */
  75304. private _scene;
  75305. /**
  75306. * The current value of the runtime animation
  75307. */
  75308. private _currentValue;
  75309. /** @hidden */
  75310. _workValue: any;
  75311. /**
  75312. * The active target of the runtime animation
  75313. */
  75314. private _activeTarget;
  75315. /**
  75316. * The target path of the runtime animation
  75317. */
  75318. private _targetPath;
  75319. /**
  75320. * The weight of the runtime animation
  75321. */
  75322. private _weight;
  75323. /**
  75324. * The ratio offset of the runtime animation
  75325. */
  75326. private _ratioOffset;
  75327. /**
  75328. * The previous delay of the runtime animation
  75329. */
  75330. private _previousDelay;
  75331. /**
  75332. * The previous ratio of the runtime animation
  75333. */
  75334. private _previousRatio;
  75335. /**
  75336. * Gets the current frame of the runtime animation
  75337. */
  75338. readonly currentFrame: number;
  75339. /**
  75340. * Gets the weight of the runtime animation
  75341. */
  75342. readonly weight: number;
  75343. /**
  75344. * Gets the current value of the runtime animation
  75345. */
  75346. readonly currentValue: any;
  75347. /**
  75348. * Gets the target path of the runtime animation
  75349. */
  75350. readonly targetPath: string;
  75351. /**
  75352. * Gets the actual target of the runtime animation
  75353. */
  75354. readonly target: any;
  75355. /**
  75356. * Create a new RuntimeAnimation object
  75357. * @param target defines the target of the animation
  75358. * @param animation defines the source animation object
  75359. * @param scene defines the hosting scene
  75360. * @param host defines the initiating Animatable
  75361. */
  75362. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  75363. /**
  75364. * Gets the animation from the runtime animation
  75365. */
  75366. readonly animation: Animation;
  75367. /**
  75368. * Resets the runtime animation to the beginning
  75369. * @param restoreOriginal defines whether to restore the target property to the original value
  75370. */
  75371. reset(restoreOriginal?: boolean): void;
  75372. /**
  75373. * Specifies if the runtime animation is stopped
  75374. * @returns Boolean specifying if the runtime animation is stopped
  75375. */
  75376. isStopped(): boolean;
  75377. /**
  75378. * Disposes of the runtime animation
  75379. */
  75380. dispose(): void;
  75381. /**
  75382. * Interpolates the animation from the current frame
  75383. * @param currentFrame The frame to interpolate the animation to
  75384. * @param repeatCount The number of times that the animation should loop
  75385. * @param loopMode The type of looping mode to use
  75386. * @param offsetValue Animation offset value
  75387. * @param highLimitValue The high limit value
  75388. * @returns The interpolated value
  75389. */
  75390. private _interpolate;
  75391. /**
  75392. * Apply the interpolated value to the target
  75393. * @param currentValue defines the value computed by the animation
  75394. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  75395. */
  75396. setValue(currentValue: any, weight?: number): void;
  75397. private _setValue;
  75398. /**
  75399. * Gets the loop pmode of the runtime animation
  75400. * @returns Loop Mode
  75401. */
  75402. private _getCorrectLoopMode;
  75403. /**
  75404. * Move the current animation to a given frame
  75405. * @param frame defines the frame to move to
  75406. */
  75407. goToFrame(frame: number): void;
  75408. /**
  75409. * @hidden Internal use only
  75410. */
  75411. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  75412. /**
  75413. * Execute the current animation
  75414. * @param delay defines the delay to add to the current frame
  75415. * @param from defines the lower bound of the animation range
  75416. * @param to defines the upper bound of the animation range
  75417. * @param loop defines if the current animation must loop
  75418. * @param speedRatio defines the current speed ratio
  75419. * @param weight defines the weight of the animation (default is -1 so no weight)
  75420. * @param onLoop optional callback called when animation loops
  75421. * @returns a boolean indicating if the animation is running
  75422. */
  75423. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  75424. }
  75425. }
  75426. declare module BABYLON {
  75427. /**
  75428. * Class used to store an actual running animation
  75429. */
  75430. export class Animatable {
  75431. /** defines the target object */
  75432. target: any;
  75433. /** defines the starting frame number (default is 0) */
  75434. fromFrame: number;
  75435. /** defines the ending frame number (default is 100) */
  75436. toFrame: number;
  75437. /** defines if the animation must loop (default is false) */
  75438. loopAnimation: boolean;
  75439. /** defines a callback to call when animation ends if it is not looping */
  75440. onAnimationEnd?: (() => void) | null | undefined;
  75441. /** defines a callback to call when animation loops */
  75442. onAnimationLoop?: (() => void) | null | undefined;
  75443. private _localDelayOffset;
  75444. private _pausedDelay;
  75445. private _runtimeAnimations;
  75446. private _paused;
  75447. private _scene;
  75448. private _speedRatio;
  75449. private _weight;
  75450. private _syncRoot;
  75451. /**
  75452. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  75453. * This will only apply for non looping animation (default is true)
  75454. */
  75455. disposeOnEnd: boolean;
  75456. /**
  75457. * Gets a boolean indicating if the animation has started
  75458. */
  75459. animationStarted: boolean;
  75460. /**
  75461. * Observer raised when the animation ends
  75462. */
  75463. onAnimationEndObservable: Observable<Animatable>;
  75464. /**
  75465. * Observer raised when the animation loops
  75466. */
  75467. onAnimationLoopObservable: Observable<Animatable>;
  75468. /**
  75469. * Gets the root Animatable used to synchronize and normalize animations
  75470. */
  75471. readonly syncRoot: Animatable;
  75472. /**
  75473. * Gets the current frame of the first RuntimeAnimation
  75474. * Used to synchronize Animatables
  75475. */
  75476. readonly masterFrame: number;
  75477. /**
  75478. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  75479. */
  75480. weight: number;
  75481. /**
  75482. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  75483. */
  75484. speedRatio: number;
  75485. /**
  75486. * Creates a new Animatable
  75487. * @param scene defines the hosting scene
  75488. * @param target defines the target object
  75489. * @param fromFrame defines the starting frame number (default is 0)
  75490. * @param toFrame defines the ending frame number (default is 100)
  75491. * @param loopAnimation defines if the animation must loop (default is false)
  75492. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  75493. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  75494. * @param animations defines a group of animation to add to the new Animatable
  75495. * @param onAnimationLoop defines a callback to call when animation loops
  75496. */
  75497. constructor(scene: Scene,
  75498. /** defines the target object */
  75499. target: any,
  75500. /** defines the starting frame number (default is 0) */
  75501. fromFrame?: number,
  75502. /** defines the ending frame number (default is 100) */
  75503. toFrame?: number,
  75504. /** defines if the animation must loop (default is false) */
  75505. loopAnimation?: boolean, speedRatio?: number,
  75506. /** defines a callback to call when animation ends if it is not looping */
  75507. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  75508. /** defines a callback to call when animation loops */
  75509. onAnimationLoop?: (() => void) | null | undefined);
  75510. /**
  75511. * Synchronize and normalize current Animatable with a source Animatable
  75512. * This is useful when using animation weights and when animations are not of the same length
  75513. * @param root defines the root Animatable to synchronize with
  75514. * @returns the current Animatable
  75515. */
  75516. syncWith(root: Animatable): Animatable;
  75517. /**
  75518. * Gets the list of runtime animations
  75519. * @returns an array of RuntimeAnimation
  75520. */
  75521. getAnimations(): RuntimeAnimation[];
  75522. /**
  75523. * Adds more animations to the current animatable
  75524. * @param target defines the target of the animations
  75525. * @param animations defines the new animations to add
  75526. */
  75527. appendAnimations(target: any, animations: Animation[]): void;
  75528. /**
  75529. * Gets the source animation for a specific property
  75530. * @param property defines the propertyu to look for
  75531. * @returns null or the source animation for the given property
  75532. */
  75533. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  75534. /**
  75535. * Gets the runtime animation for a specific property
  75536. * @param property defines the propertyu to look for
  75537. * @returns null or the runtime animation for the given property
  75538. */
  75539. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  75540. /**
  75541. * Resets the animatable to its original state
  75542. */
  75543. reset(): void;
  75544. /**
  75545. * Allows the animatable to blend with current running animations
  75546. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75547. * @param blendingSpeed defines the blending speed to use
  75548. */
  75549. enableBlending(blendingSpeed: number): void;
  75550. /**
  75551. * Disable animation blending
  75552. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75553. */
  75554. disableBlending(): void;
  75555. /**
  75556. * Jump directly to a given frame
  75557. * @param frame defines the frame to jump to
  75558. */
  75559. goToFrame(frame: number): void;
  75560. /**
  75561. * Pause the animation
  75562. */
  75563. pause(): void;
  75564. /**
  75565. * Restart the animation
  75566. */
  75567. restart(): void;
  75568. private _raiseOnAnimationEnd;
  75569. /**
  75570. * Stop and delete the current animation
  75571. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  75572. * @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)
  75573. */
  75574. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  75575. /**
  75576. * Wait asynchronously for the animation to end
  75577. * @returns a promise which will be fullfilled when the animation ends
  75578. */
  75579. waitAsync(): Promise<Animatable>;
  75580. /** @hidden */
  75581. _animate(delay: number): boolean;
  75582. }
  75583. interface Scene {
  75584. /** @hidden */
  75585. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  75586. /** @hidden */
  75587. _processLateAnimationBindingsForMatrices(holder: {
  75588. totalWeight: number;
  75589. animations: RuntimeAnimation[];
  75590. originalValue: Matrix;
  75591. }): any;
  75592. /** @hidden */
  75593. _processLateAnimationBindingsForQuaternions(holder: {
  75594. totalWeight: number;
  75595. animations: RuntimeAnimation[];
  75596. originalValue: Quaternion;
  75597. }, refQuaternion: Quaternion): Quaternion;
  75598. /** @hidden */
  75599. _processLateAnimationBindings(): void;
  75600. /**
  75601. * Will start the animation sequence of a given target
  75602. * @param target defines the target
  75603. * @param from defines from which frame should animation start
  75604. * @param to defines until which frame should animation run.
  75605. * @param weight defines the weight to apply to the animation (1.0 by default)
  75606. * @param loop defines if the animation loops
  75607. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75608. * @param onAnimationEnd defines the function to be executed when the animation ends
  75609. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75610. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75611. * @param onAnimationLoop defines the callback to call when an animation loops
  75612. * @returns the animatable object created for this animation
  75613. */
  75614. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75615. /**
  75616. * Will start the animation sequence of a given target
  75617. * @param target defines the target
  75618. * @param from defines from which frame should animation start
  75619. * @param to defines until which frame should animation run.
  75620. * @param loop defines if the animation loops
  75621. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75622. * @param onAnimationEnd defines the function to be executed when the animation ends
  75623. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75624. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75625. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  75626. * @param onAnimationLoop defines the callback to call when an animation loops
  75627. * @returns the animatable object created for this animation
  75628. */
  75629. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75630. /**
  75631. * Will start the animation sequence of a given target and its hierarchy
  75632. * @param target defines the target
  75633. * @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.
  75634. * @param from defines from which frame should animation start
  75635. * @param to defines until which frame should animation run.
  75636. * @param loop defines if the animation loops
  75637. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75638. * @param onAnimationEnd defines the function to be executed when the animation ends
  75639. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75640. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75641. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75642. * @param onAnimationLoop defines the callback to call when an animation loops
  75643. * @returns the list of created animatables
  75644. */
  75645. 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[];
  75646. /**
  75647. * Begin a new animation on a given node
  75648. * @param target defines the target where the animation will take place
  75649. * @param animations defines the list of animations to start
  75650. * @param from defines the initial value
  75651. * @param to defines the final value
  75652. * @param loop defines if you want animation to loop (off by default)
  75653. * @param speedRatio defines the speed ratio to apply to all animations
  75654. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75655. * @param onAnimationLoop defines the callback to call when an animation loops
  75656. * @returns the list of created animatables
  75657. */
  75658. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  75659. /**
  75660. * Begin a new animation on a given node and its hierarchy
  75661. * @param target defines the root node where the animation will take place
  75662. * @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.
  75663. * @param animations defines the list of animations to start
  75664. * @param from defines the initial value
  75665. * @param to defines the final value
  75666. * @param loop defines if you want animation to loop (off by default)
  75667. * @param speedRatio defines the speed ratio to apply to all animations
  75668. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75669. * @param onAnimationLoop defines the callback to call when an animation loops
  75670. * @returns the list of animatables created for all nodes
  75671. */
  75672. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  75673. /**
  75674. * Gets the animatable associated with a specific target
  75675. * @param target defines the target of the animatable
  75676. * @returns the required animatable if found
  75677. */
  75678. getAnimatableByTarget(target: any): Nullable<Animatable>;
  75679. /**
  75680. * Gets all animatables associated with a given target
  75681. * @param target defines the target to look animatables for
  75682. * @returns an array of Animatables
  75683. */
  75684. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  75685. /**
  75686. * Will stop the animation of the given target
  75687. * @param target - the target
  75688. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  75689. * @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)
  75690. */
  75691. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  75692. /**
  75693. * Stops and removes all animations that have been applied to the scene
  75694. */
  75695. stopAllAnimations(): void;
  75696. }
  75697. interface Bone {
  75698. /**
  75699. * Copy an animation range from another bone
  75700. * @param source defines the source bone
  75701. * @param rangeName defines the range name to copy
  75702. * @param frameOffset defines the frame offset
  75703. * @param rescaleAsRequired defines if rescaling must be applied if required
  75704. * @param skelDimensionsRatio defines the scaling ratio
  75705. * @returns true if operation was successful
  75706. */
  75707. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  75708. }
  75709. }
  75710. declare module BABYLON {
  75711. /**
  75712. * Class used to handle skinning animations
  75713. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  75714. */
  75715. export class Skeleton implements IAnimatable {
  75716. /** defines the skeleton name */
  75717. name: string;
  75718. /** defines the skeleton Id */
  75719. id: string;
  75720. /**
  75721. * Defines the list of child bones
  75722. */
  75723. bones: Bone[];
  75724. /**
  75725. * Defines an estimate of the dimension of the skeleton at rest
  75726. */
  75727. dimensionsAtRest: Vector3;
  75728. /**
  75729. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  75730. */
  75731. needInitialSkinMatrix: boolean;
  75732. /**
  75733. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  75734. */
  75735. overrideMesh: Nullable<AbstractMesh>;
  75736. /**
  75737. * Gets the list of animations attached to this skeleton
  75738. */
  75739. animations: Array<Animation>;
  75740. private _scene;
  75741. private _isDirty;
  75742. private _transformMatrices;
  75743. private _transformMatrixTexture;
  75744. private _meshesWithPoseMatrix;
  75745. private _animatables;
  75746. private _identity;
  75747. private _synchronizedWithMesh;
  75748. private _ranges;
  75749. private _lastAbsoluteTransformsUpdateId;
  75750. private _canUseTextureForBones;
  75751. /** @hidden */
  75752. _numBonesWithLinkedTransformNode: number;
  75753. /**
  75754. * Specifies if the skeleton should be serialized
  75755. */
  75756. doNotSerialize: boolean;
  75757. /**
  75758. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  75759. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  75760. */
  75761. useTextureToStoreBoneMatrices: boolean;
  75762. private _animationPropertiesOverride;
  75763. /**
  75764. * Gets or sets the animation properties override
  75765. */
  75766. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  75767. /**
  75768. * An observable triggered before computing the skeleton's matrices
  75769. */
  75770. onBeforeComputeObservable: Observable<Skeleton>;
  75771. /**
  75772. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  75773. */
  75774. readonly isUsingTextureForMatrices: boolean;
  75775. /**
  75776. * Creates a new skeleton
  75777. * @param name defines the skeleton name
  75778. * @param id defines the skeleton Id
  75779. * @param scene defines the hosting scene
  75780. */
  75781. constructor(
  75782. /** defines the skeleton name */
  75783. name: string,
  75784. /** defines the skeleton Id */
  75785. id: string, scene: Scene);
  75786. /**
  75787. * Gets the current object class name.
  75788. * @return the class name
  75789. */
  75790. getClassName(): string;
  75791. /**
  75792. * Returns an array containing the root bones
  75793. * @returns an array containing the root bones
  75794. */
  75795. getChildren(): Array<Bone>;
  75796. /**
  75797. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  75798. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  75799. * @returns a Float32Array containing matrices data
  75800. */
  75801. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  75802. /**
  75803. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  75804. * @returns a raw texture containing the data
  75805. */
  75806. getTransformMatrixTexture(): Nullable<RawTexture>;
  75807. /**
  75808. * Gets the current hosting scene
  75809. * @returns a scene object
  75810. */
  75811. getScene(): Scene;
  75812. /**
  75813. * Gets a string representing the current skeleton data
  75814. * @param fullDetails defines a boolean indicating if we want a verbose version
  75815. * @returns a string representing the current skeleton data
  75816. */
  75817. toString(fullDetails?: boolean): string;
  75818. /**
  75819. * Get bone's index searching by name
  75820. * @param name defines bone's name to search for
  75821. * @return the indice of the bone. Returns -1 if not found
  75822. */
  75823. getBoneIndexByName(name: string): number;
  75824. /**
  75825. * Creater a new animation range
  75826. * @param name defines the name of the range
  75827. * @param from defines the start key
  75828. * @param to defines the end key
  75829. */
  75830. createAnimationRange(name: string, from: number, to: number): void;
  75831. /**
  75832. * Delete a specific animation range
  75833. * @param name defines the name of the range
  75834. * @param deleteFrames defines if frames must be removed as well
  75835. */
  75836. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  75837. /**
  75838. * Gets a specific animation range
  75839. * @param name defines the name of the range to look for
  75840. * @returns the requested animation range or null if not found
  75841. */
  75842. getAnimationRange(name: string): Nullable<AnimationRange>;
  75843. /**
  75844. * Gets the list of all animation ranges defined on this skeleton
  75845. * @returns an array
  75846. */
  75847. getAnimationRanges(): Nullable<AnimationRange>[];
  75848. /**
  75849. * Copy animation range from a source skeleton.
  75850. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  75851. * @param source defines the source skeleton
  75852. * @param name defines the name of the range to copy
  75853. * @param rescaleAsRequired defines if rescaling must be applied if required
  75854. * @returns true if operation was successful
  75855. */
  75856. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  75857. /**
  75858. * Forces the skeleton to go to rest pose
  75859. */
  75860. returnToRest(): void;
  75861. private _getHighestAnimationFrame;
  75862. /**
  75863. * Begin a specific animation range
  75864. * @param name defines the name of the range to start
  75865. * @param loop defines if looping must be turned on (false by default)
  75866. * @param speedRatio defines the speed ratio to apply (1 by default)
  75867. * @param onAnimationEnd defines a callback which will be called when animation will end
  75868. * @returns a new animatable
  75869. */
  75870. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  75871. /** @hidden */
  75872. _markAsDirty(): void;
  75873. /** @hidden */
  75874. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  75875. /** @hidden */
  75876. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  75877. private _computeTransformMatrices;
  75878. /**
  75879. * Build all resources required to render a skeleton
  75880. */
  75881. prepare(): void;
  75882. /**
  75883. * Gets the list of animatables currently running for this skeleton
  75884. * @returns an array of animatables
  75885. */
  75886. getAnimatables(): IAnimatable[];
  75887. /**
  75888. * Clone the current skeleton
  75889. * @param name defines the name of the new skeleton
  75890. * @param id defines the id of the enw skeleton
  75891. * @returns the new skeleton
  75892. */
  75893. clone(name: string, id: string): Skeleton;
  75894. /**
  75895. * Enable animation blending for this skeleton
  75896. * @param blendingSpeed defines the blending speed to apply
  75897. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75898. */
  75899. enableBlending(blendingSpeed?: number): void;
  75900. /**
  75901. * Releases all resources associated with the current skeleton
  75902. */
  75903. dispose(): void;
  75904. /**
  75905. * Serialize the skeleton in a JSON object
  75906. * @returns a JSON object
  75907. */
  75908. serialize(): any;
  75909. /**
  75910. * Creates a new skeleton from serialized data
  75911. * @param parsedSkeleton defines the serialized data
  75912. * @param scene defines the hosting scene
  75913. * @returns a new skeleton
  75914. */
  75915. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  75916. /**
  75917. * Compute all node absolute transforms
  75918. * @param forceUpdate defines if computation must be done even if cache is up to date
  75919. */
  75920. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  75921. /**
  75922. * Gets the root pose matrix
  75923. * @returns a matrix
  75924. */
  75925. getPoseMatrix(): Nullable<Matrix>;
  75926. /**
  75927. * Sorts bones per internal index
  75928. */
  75929. sortBones(): void;
  75930. private _sortBones;
  75931. }
  75932. }
  75933. declare module BABYLON {
  75934. /**
  75935. * Defines a target to use with MorphTargetManager
  75936. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  75937. */
  75938. export class MorphTarget implements IAnimatable {
  75939. /** defines the name of the target */
  75940. name: string;
  75941. /**
  75942. * Gets or sets the list of animations
  75943. */
  75944. animations: Animation[];
  75945. private _scene;
  75946. private _positions;
  75947. private _normals;
  75948. private _tangents;
  75949. private _influence;
  75950. /**
  75951. * Observable raised when the influence changes
  75952. */
  75953. onInfluenceChanged: Observable<boolean>;
  75954. /** @hidden */
  75955. _onDataLayoutChanged: Observable<void>;
  75956. /**
  75957. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  75958. */
  75959. influence: number;
  75960. /**
  75961. * Gets or sets the id of the morph Target
  75962. */
  75963. id: string;
  75964. private _animationPropertiesOverride;
  75965. /**
  75966. * Gets or sets the animation properties override
  75967. */
  75968. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  75969. /**
  75970. * Creates a new MorphTarget
  75971. * @param name defines the name of the target
  75972. * @param influence defines the influence to use
  75973. * @param scene defines the scene the morphtarget belongs to
  75974. */
  75975. constructor(
  75976. /** defines the name of the target */
  75977. name: string, influence?: number, scene?: Nullable<Scene>);
  75978. /**
  75979. * Gets a boolean defining if the target contains position data
  75980. */
  75981. readonly hasPositions: boolean;
  75982. /**
  75983. * Gets a boolean defining if the target contains normal data
  75984. */
  75985. readonly hasNormals: boolean;
  75986. /**
  75987. * Gets a boolean defining if the target contains tangent data
  75988. */
  75989. readonly hasTangents: boolean;
  75990. /**
  75991. * Affects position data to this target
  75992. * @param data defines the position data to use
  75993. */
  75994. setPositions(data: Nullable<FloatArray>): void;
  75995. /**
  75996. * Gets the position data stored in this target
  75997. * @returns a FloatArray containing the position data (or null if not present)
  75998. */
  75999. getPositions(): Nullable<FloatArray>;
  76000. /**
  76001. * Affects normal data to this target
  76002. * @param data defines the normal data to use
  76003. */
  76004. setNormals(data: Nullable<FloatArray>): void;
  76005. /**
  76006. * Gets the normal data stored in this target
  76007. * @returns a FloatArray containing the normal data (or null if not present)
  76008. */
  76009. getNormals(): Nullable<FloatArray>;
  76010. /**
  76011. * Affects tangent data to this target
  76012. * @param data defines the tangent data to use
  76013. */
  76014. setTangents(data: Nullable<FloatArray>): void;
  76015. /**
  76016. * Gets the tangent data stored in this target
  76017. * @returns a FloatArray containing the tangent data (or null if not present)
  76018. */
  76019. getTangents(): Nullable<FloatArray>;
  76020. /**
  76021. * Serializes the current target into a Serialization object
  76022. * @returns the serialized object
  76023. */
  76024. serialize(): any;
  76025. /**
  76026. * Returns the string "MorphTarget"
  76027. * @returns "MorphTarget"
  76028. */
  76029. getClassName(): string;
  76030. /**
  76031. * Creates a new target from serialized data
  76032. * @param serializationObject defines the serialized data to use
  76033. * @returns a new MorphTarget
  76034. */
  76035. static Parse(serializationObject: any): MorphTarget;
  76036. /**
  76037. * Creates a MorphTarget from mesh data
  76038. * @param mesh defines the source mesh
  76039. * @param name defines the name to use for the new target
  76040. * @param influence defines the influence to attach to the target
  76041. * @returns a new MorphTarget
  76042. */
  76043. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  76044. }
  76045. }
  76046. declare module BABYLON {
  76047. /**
  76048. * This class is used to deform meshes using morphing between different targets
  76049. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76050. */
  76051. export class MorphTargetManager {
  76052. private _targets;
  76053. private _targetInfluenceChangedObservers;
  76054. private _targetDataLayoutChangedObservers;
  76055. private _activeTargets;
  76056. private _scene;
  76057. private _influences;
  76058. private _supportsNormals;
  76059. private _supportsTangents;
  76060. private _vertexCount;
  76061. private _uniqueId;
  76062. private _tempInfluences;
  76063. /**
  76064. * Creates a new MorphTargetManager
  76065. * @param scene defines the current scene
  76066. */
  76067. constructor(scene?: Nullable<Scene>);
  76068. /**
  76069. * Gets the unique ID of this manager
  76070. */
  76071. readonly uniqueId: number;
  76072. /**
  76073. * Gets the number of vertices handled by this manager
  76074. */
  76075. readonly vertexCount: number;
  76076. /**
  76077. * Gets a boolean indicating if this manager supports morphing of normals
  76078. */
  76079. readonly supportsNormals: boolean;
  76080. /**
  76081. * Gets a boolean indicating if this manager supports morphing of tangents
  76082. */
  76083. readonly supportsTangents: boolean;
  76084. /**
  76085. * Gets the number of targets stored in this manager
  76086. */
  76087. readonly numTargets: number;
  76088. /**
  76089. * Gets the number of influencers (ie. the number of targets with influences > 0)
  76090. */
  76091. readonly numInfluencers: number;
  76092. /**
  76093. * Gets the list of influences (one per target)
  76094. */
  76095. readonly influences: Float32Array;
  76096. /**
  76097. * Gets the active target at specified index. An active target is a target with an influence > 0
  76098. * @param index defines the index to check
  76099. * @returns the requested target
  76100. */
  76101. getActiveTarget(index: number): MorphTarget;
  76102. /**
  76103. * Gets the target at specified index
  76104. * @param index defines the index to check
  76105. * @returns the requested target
  76106. */
  76107. getTarget(index: number): MorphTarget;
  76108. /**
  76109. * Add a new target to this manager
  76110. * @param target defines the target to add
  76111. */
  76112. addTarget(target: MorphTarget): void;
  76113. /**
  76114. * Removes a target from the manager
  76115. * @param target defines the target to remove
  76116. */
  76117. removeTarget(target: MorphTarget): void;
  76118. /**
  76119. * Serializes the current manager into a Serialization object
  76120. * @returns the serialized object
  76121. */
  76122. serialize(): any;
  76123. private _syncActiveTargets;
  76124. /**
  76125. * Syncrhonize the targets with all the meshes using this morph target manager
  76126. */
  76127. synchronize(): void;
  76128. /**
  76129. * Creates a new MorphTargetManager from serialized data
  76130. * @param serializationObject defines the serialized data
  76131. * @param scene defines the hosting scene
  76132. * @returns the new MorphTargetManager
  76133. */
  76134. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  76135. }
  76136. }
  76137. declare module BABYLON {
  76138. /**
  76139. * Mesh representing the gorund
  76140. */
  76141. export class GroundMesh extends Mesh {
  76142. /** If octree should be generated */
  76143. generateOctree: boolean;
  76144. private _heightQuads;
  76145. /** @hidden */
  76146. _subdivisionsX: number;
  76147. /** @hidden */
  76148. _subdivisionsY: number;
  76149. /** @hidden */
  76150. _width: number;
  76151. /** @hidden */
  76152. _height: number;
  76153. /** @hidden */
  76154. _minX: number;
  76155. /** @hidden */
  76156. _maxX: number;
  76157. /** @hidden */
  76158. _minZ: number;
  76159. /** @hidden */
  76160. _maxZ: number;
  76161. constructor(name: string, scene: Scene);
  76162. /**
  76163. * "GroundMesh"
  76164. * @returns "GroundMesh"
  76165. */
  76166. getClassName(): string;
  76167. /**
  76168. * The minimum of x and y subdivisions
  76169. */
  76170. readonly subdivisions: number;
  76171. /**
  76172. * X subdivisions
  76173. */
  76174. readonly subdivisionsX: number;
  76175. /**
  76176. * Y subdivisions
  76177. */
  76178. readonly subdivisionsY: number;
  76179. /**
  76180. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  76181. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  76182. * @param chunksCount the number of subdivisions for x and y
  76183. * @param octreeBlocksSize (Default: 32)
  76184. */
  76185. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  76186. /**
  76187. * Returns a height (y) value in the Worl system :
  76188. * the ground altitude at the coordinates (x, z) expressed in the World system.
  76189. * @param x x coordinate
  76190. * @param z z coordinate
  76191. * @returns the ground y position if (x, z) are outside the ground surface.
  76192. */
  76193. getHeightAtCoordinates(x: number, z: number): number;
  76194. /**
  76195. * Returns a normalized vector (Vector3) orthogonal to the ground
  76196. * at the ground coordinates (x, z) expressed in the World system.
  76197. * @param x x coordinate
  76198. * @param z z coordinate
  76199. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  76200. */
  76201. getNormalAtCoordinates(x: number, z: number): Vector3;
  76202. /**
  76203. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  76204. * at the ground coordinates (x, z) expressed in the World system.
  76205. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  76206. * @param x x coordinate
  76207. * @param z z coordinate
  76208. * @param ref vector to store the result
  76209. * @returns the GroundMesh.
  76210. */
  76211. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  76212. /**
  76213. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  76214. * if the ground has been updated.
  76215. * This can be used in the render loop.
  76216. * @returns the GroundMesh.
  76217. */
  76218. updateCoordinateHeights(): GroundMesh;
  76219. private _getFacetAt;
  76220. private _initHeightQuads;
  76221. private _computeHeightQuads;
  76222. /**
  76223. * Serializes this ground mesh
  76224. * @param serializationObject object to write serialization to
  76225. */
  76226. serialize(serializationObject: any): void;
  76227. /**
  76228. * Parses a serialized ground mesh
  76229. * @param parsedMesh the serialized mesh
  76230. * @param scene the scene to create the ground mesh in
  76231. * @returns the created ground mesh
  76232. */
  76233. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  76234. }
  76235. }
  76236. declare module BABYLON {
  76237. /**
  76238. * Interface for Physics-Joint data
  76239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76240. */
  76241. export interface PhysicsJointData {
  76242. /**
  76243. * The main pivot of the joint
  76244. */
  76245. mainPivot?: Vector3;
  76246. /**
  76247. * The connected pivot of the joint
  76248. */
  76249. connectedPivot?: Vector3;
  76250. /**
  76251. * The main axis of the joint
  76252. */
  76253. mainAxis?: Vector3;
  76254. /**
  76255. * The connected axis of the joint
  76256. */
  76257. connectedAxis?: Vector3;
  76258. /**
  76259. * The collision of the joint
  76260. */
  76261. collision?: boolean;
  76262. /**
  76263. * Native Oimo/Cannon/Energy data
  76264. */
  76265. nativeParams?: any;
  76266. }
  76267. /**
  76268. * This is a holder class for the physics joint created by the physics plugin
  76269. * It holds a set of functions to control the underlying joint
  76270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76271. */
  76272. export class PhysicsJoint {
  76273. /**
  76274. * The type of the physics joint
  76275. */
  76276. type: number;
  76277. /**
  76278. * The data for the physics joint
  76279. */
  76280. jointData: PhysicsJointData;
  76281. private _physicsJoint;
  76282. protected _physicsPlugin: IPhysicsEnginePlugin;
  76283. /**
  76284. * Initializes the physics joint
  76285. * @param type The type of the physics joint
  76286. * @param jointData The data for the physics joint
  76287. */
  76288. constructor(
  76289. /**
  76290. * The type of the physics joint
  76291. */
  76292. type: number,
  76293. /**
  76294. * The data for the physics joint
  76295. */
  76296. jointData: PhysicsJointData);
  76297. /**
  76298. * Gets the physics joint
  76299. */
  76300. /**
  76301. * Sets the physics joint
  76302. */
  76303. physicsJoint: any;
  76304. /**
  76305. * Sets the physics plugin
  76306. */
  76307. physicsPlugin: IPhysicsEnginePlugin;
  76308. /**
  76309. * Execute a function that is physics-plugin specific.
  76310. * @param {Function} func the function that will be executed.
  76311. * It accepts two parameters: the physics world and the physics joint
  76312. */
  76313. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  76314. /**
  76315. * Distance-Joint type
  76316. */
  76317. static DistanceJoint: number;
  76318. /**
  76319. * Hinge-Joint type
  76320. */
  76321. static HingeJoint: number;
  76322. /**
  76323. * Ball-and-Socket joint type
  76324. */
  76325. static BallAndSocketJoint: number;
  76326. /**
  76327. * Wheel-Joint type
  76328. */
  76329. static WheelJoint: number;
  76330. /**
  76331. * Slider-Joint type
  76332. */
  76333. static SliderJoint: number;
  76334. /**
  76335. * Prismatic-Joint type
  76336. */
  76337. static PrismaticJoint: number;
  76338. /**
  76339. * Universal-Joint type
  76340. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  76341. */
  76342. static UniversalJoint: number;
  76343. /**
  76344. * Hinge-Joint 2 type
  76345. */
  76346. static Hinge2Joint: number;
  76347. /**
  76348. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  76349. */
  76350. static PointToPointJoint: number;
  76351. /**
  76352. * Spring-Joint type
  76353. */
  76354. static SpringJoint: number;
  76355. /**
  76356. * Lock-Joint type
  76357. */
  76358. static LockJoint: number;
  76359. }
  76360. /**
  76361. * A class representing a physics distance joint
  76362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76363. */
  76364. export class DistanceJoint extends PhysicsJoint {
  76365. /**
  76366. *
  76367. * @param jointData The data for the Distance-Joint
  76368. */
  76369. constructor(jointData: DistanceJointData);
  76370. /**
  76371. * Update the predefined distance.
  76372. * @param maxDistance The maximum preferred distance
  76373. * @param minDistance The minimum preferred distance
  76374. */
  76375. updateDistance(maxDistance: number, minDistance?: number): void;
  76376. }
  76377. /**
  76378. * Represents a Motor-Enabled Joint
  76379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76380. */
  76381. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  76382. /**
  76383. * Initializes the Motor-Enabled Joint
  76384. * @param type The type of the joint
  76385. * @param jointData The physica joint data for the joint
  76386. */
  76387. constructor(type: number, jointData: PhysicsJointData);
  76388. /**
  76389. * Set the motor values.
  76390. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76391. * @param force the force to apply
  76392. * @param maxForce max force for this motor.
  76393. */
  76394. setMotor(force?: number, maxForce?: number): void;
  76395. /**
  76396. * Set the motor's limits.
  76397. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76398. * @param upperLimit The upper limit of the motor
  76399. * @param lowerLimit The lower limit of the motor
  76400. */
  76401. setLimit(upperLimit: number, lowerLimit?: number): void;
  76402. }
  76403. /**
  76404. * This class represents a single physics Hinge-Joint
  76405. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76406. */
  76407. export class HingeJoint extends MotorEnabledJoint {
  76408. /**
  76409. * Initializes the Hinge-Joint
  76410. * @param jointData The joint data for the Hinge-Joint
  76411. */
  76412. constructor(jointData: PhysicsJointData);
  76413. /**
  76414. * Set the motor values.
  76415. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76416. * @param {number} force the force to apply
  76417. * @param {number} maxForce max force for this motor.
  76418. */
  76419. setMotor(force?: number, maxForce?: number): void;
  76420. /**
  76421. * Set the motor's limits.
  76422. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76423. * @param upperLimit The upper limit of the motor
  76424. * @param lowerLimit The lower limit of the motor
  76425. */
  76426. setLimit(upperLimit: number, lowerLimit?: number): void;
  76427. }
  76428. /**
  76429. * This class represents a dual hinge physics joint (same as wheel joint)
  76430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76431. */
  76432. export class Hinge2Joint extends MotorEnabledJoint {
  76433. /**
  76434. * Initializes the Hinge2-Joint
  76435. * @param jointData The joint data for the Hinge2-Joint
  76436. */
  76437. constructor(jointData: PhysicsJointData);
  76438. /**
  76439. * Set the motor values.
  76440. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76441. * @param {number} targetSpeed the speed the motor is to reach
  76442. * @param {number} maxForce max force for this motor.
  76443. * @param {motorIndex} the motor's index, 0 or 1.
  76444. */
  76445. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  76446. /**
  76447. * Set the motor limits.
  76448. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76449. * @param {number} upperLimit the upper limit
  76450. * @param {number} lowerLimit lower limit
  76451. * @param {motorIndex} the motor's index, 0 or 1.
  76452. */
  76453. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76454. }
  76455. /**
  76456. * Interface for a motor enabled joint
  76457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76458. */
  76459. export interface IMotorEnabledJoint {
  76460. /**
  76461. * Physics joint
  76462. */
  76463. physicsJoint: any;
  76464. /**
  76465. * Sets the motor of the motor-enabled joint
  76466. * @param force The force of the motor
  76467. * @param maxForce The maximum force of the motor
  76468. * @param motorIndex The index of the motor
  76469. */
  76470. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  76471. /**
  76472. * Sets the limit of the motor
  76473. * @param upperLimit The upper limit of the motor
  76474. * @param lowerLimit The lower limit of the motor
  76475. * @param motorIndex The index of the motor
  76476. */
  76477. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76478. }
  76479. /**
  76480. * Joint data for a Distance-Joint
  76481. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76482. */
  76483. export interface DistanceJointData extends PhysicsJointData {
  76484. /**
  76485. * Max distance the 2 joint objects can be apart
  76486. */
  76487. maxDistance: number;
  76488. }
  76489. /**
  76490. * Joint data from a spring joint
  76491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76492. */
  76493. export interface SpringJointData extends PhysicsJointData {
  76494. /**
  76495. * Length of the spring
  76496. */
  76497. length: number;
  76498. /**
  76499. * Stiffness of the spring
  76500. */
  76501. stiffness: number;
  76502. /**
  76503. * Damping of the spring
  76504. */
  76505. damping: number;
  76506. /** this callback will be called when applying the force to the impostors. */
  76507. forceApplicationCallback: () => void;
  76508. }
  76509. }
  76510. declare module BABYLON {
  76511. /**
  76512. * Interface used to describe a physics joint
  76513. */
  76514. export interface PhysicsImpostorJoint {
  76515. /** Defines the main impostor to which the joint is linked */
  76516. mainImpostor: PhysicsImpostor;
  76517. /** Defines the impostor that is connected to the main impostor using this joint */
  76518. connectedImpostor: PhysicsImpostor;
  76519. /** Defines the joint itself */
  76520. joint: PhysicsJoint;
  76521. }
  76522. /** @hidden */
  76523. export interface IPhysicsEnginePlugin {
  76524. world: any;
  76525. name: string;
  76526. setGravity(gravity: Vector3): void;
  76527. setTimeStep(timeStep: number): void;
  76528. getTimeStep(): number;
  76529. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  76530. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76531. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76532. generatePhysicsBody(impostor: PhysicsImpostor): void;
  76533. removePhysicsBody(impostor: PhysicsImpostor): void;
  76534. generateJoint(joint: PhysicsImpostorJoint): void;
  76535. removeJoint(joint: PhysicsImpostorJoint): void;
  76536. isSupported(): boolean;
  76537. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  76538. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  76539. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76540. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76541. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76542. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76543. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  76544. getBodyMass(impostor: PhysicsImpostor): number;
  76545. getBodyFriction(impostor: PhysicsImpostor): number;
  76546. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  76547. getBodyRestitution(impostor: PhysicsImpostor): number;
  76548. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  76549. sleepBody(impostor: PhysicsImpostor): void;
  76550. wakeUpBody(impostor: PhysicsImpostor): void;
  76551. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  76552. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  76553. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76554. getRadius(impostor: PhysicsImpostor): number;
  76555. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  76556. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  76557. dispose(): void;
  76558. }
  76559. /**
  76560. * Interface used to define a physics engine
  76561. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  76562. */
  76563. export interface IPhysicsEngine {
  76564. /**
  76565. * Gets the gravity vector used by the simulation
  76566. */
  76567. gravity: Vector3;
  76568. /**
  76569. * Sets the gravity vector used by the simulation
  76570. * @param gravity defines the gravity vector to use
  76571. */
  76572. setGravity(gravity: Vector3): void;
  76573. /**
  76574. * Set the time step of the physics engine.
  76575. * Default is 1/60.
  76576. * To slow it down, enter 1/600 for example.
  76577. * To speed it up, 1/30
  76578. * @param newTimeStep the new timestep to apply to this world.
  76579. */
  76580. setTimeStep(newTimeStep: number): void;
  76581. /**
  76582. * Get the time step of the physics engine.
  76583. * @returns the current time step
  76584. */
  76585. getTimeStep(): number;
  76586. /**
  76587. * Release all resources
  76588. */
  76589. dispose(): void;
  76590. /**
  76591. * Gets the name of the current physics plugin
  76592. * @returns the name of the plugin
  76593. */
  76594. getPhysicsPluginName(): string;
  76595. /**
  76596. * Adding a new impostor for the impostor tracking.
  76597. * This will be done by the impostor itself.
  76598. * @param impostor the impostor to add
  76599. */
  76600. addImpostor(impostor: PhysicsImpostor): void;
  76601. /**
  76602. * Remove an impostor from the engine.
  76603. * This impostor and its mesh will not longer be updated by the physics engine.
  76604. * @param impostor the impostor to remove
  76605. */
  76606. removeImpostor(impostor: PhysicsImpostor): void;
  76607. /**
  76608. * Add a joint to the physics engine
  76609. * @param mainImpostor defines the main impostor to which the joint is added.
  76610. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76611. * @param joint defines the joint that will connect both impostors.
  76612. */
  76613. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76614. /**
  76615. * Removes a joint from the simulation
  76616. * @param mainImpostor defines the impostor used with the joint
  76617. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  76618. * @param joint defines the joint to remove
  76619. */
  76620. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76621. /**
  76622. * Gets the current plugin used to run the simulation
  76623. * @returns current plugin
  76624. */
  76625. getPhysicsPlugin(): IPhysicsEnginePlugin;
  76626. /**
  76627. * Gets the list of physic impostors
  76628. * @returns an array of PhysicsImpostor
  76629. */
  76630. getImpostors(): Array<PhysicsImpostor>;
  76631. /**
  76632. * Gets the impostor for a physics enabled object
  76633. * @param object defines the object impersonated by the impostor
  76634. * @returns the PhysicsImpostor or null if not found
  76635. */
  76636. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76637. /**
  76638. * Gets the impostor for a physics body object
  76639. * @param body defines physics body used by the impostor
  76640. * @returns the PhysicsImpostor or null if not found
  76641. */
  76642. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  76643. /**
  76644. * Called by the scene. No need to call it.
  76645. * @param delta defines the timespam between frames
  76646. */
  76647. _step(delta: number): void;
  76648. }
  76649. }
  76650. declare module BABYLON {
  76651. /**
  76652. * The interface for the physics imposter parameters
  76653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76654. */
  76655. export interface PhysicsImpostorParameters {
  76656. /**
  76657. * The mass of the physics imposter
  76658. */
  76659. mass: number;
  76660. /**
  76661. * The friction of the physics imposter
  76662. */
  76663. friction?: number;
  76664. /**
  76665. * The coefficient of restitution of the physics imposter
  76666. */
  76667. restitution?: number;
  76668. /**
  76669. * The native options of the physics imposter
  76670. */
  76671. nativeOptions?: any;
  76672. /**
  76673. * Specifies if the parent should be ignored
  76674. */
  76675. ignoreParent?: boolean;
  76676. /**
  76677. * Specifies if bi-directional transformations should be disabled
  76678. */
  76679. disableBidirectionalTransformation?: boolean;
  76680. }
  76681. /**
  76682. * Interface for a physics-enabled object
  76683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76684. */
  76685. export interface IPhysicsEnabledObject {
  76686. /**
  76687. * The position of the physics-enabled object
  76688. */
  76689. position: Vector3;
  76690. /**
  76691. * The rotation of the physics-enabled object
  76692. */
  76693. rotationQuaternion: Nullable<Quaternion>;
  76694. /**
  76695. * The scale of the physics-enabled object
  76696. */
  76697. scaling: Vector3;
  76698. /**
  76699. * The rotation of the physics-enabled object
  76700. */
  76701. rotation?: Vector3;
  76702. /**
  76703. * The parent of the physics-enabled object
  76704. */
  76705. parent?: any;
  76706. /**
  76707. * The bounding info of the physics-enabled object
  76708. * @returns The bounding info of the physics-enabled object
  76709. */
  76710. getBoundingInfo(): BoundingInfo;
  76711. /**
  76712. * Computes the world matrix
  76713. * @param force Specifies if the world matrix should be computed by force
  76714. * @returns A world matrix
  76715. */
  76716. computeWorldMatrix(force: boolean): Matrix;
  76717. /**
  76718. * Gets the world matrix
  76719. * @returns A world matrix
  76720. */
  76721. getWorldMatrix?(): Matrix;
  76722. /**
  76723. * Gets the child meshes
  76724. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  76725. * @returns An array of abstract meshes
  76726. */
  76727. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  76728. /**
  76729. * Gets the vertex data
  76730. * @param kind The type of vertex data
  76731. * @returns A nullable array of numbers, or a float32 array
  76732. */
  76733. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  76734. /**
  76735. * Gets the indices from the mesh
  76736. * @returns A nullable array of index arrays
  76737. */
  76738. getIndices?(): Nullable<IndicesArray>;
  76739. /**
  76740. * Gets the scene from the mesh
  76741. * @returns the indices array or null
  76742. */
  76743. getScene?(): Scene;
  76744. /**
  76745. * Gets the absolute position from the mesh
  76746. * @returns the absolute position
  76747. */
  76748. getAbsolutePosition(): Vector3;
  76749. /**
  76750. * Gets the absolute pivot point from the mesh
  76751. * @returns the absolute pivot point
  76752. */
  76753. getAbsolutePivotPoint(): Vector3;
  76754. /**
  76755. * Rotates the mesh
  76756. * @param axis The axis of rotation
  76757. * @param amount The amount of rotation
  76758. * @param space The space of the rotation
  76759. * @returns The rotation transform node
  76760. */
  76761. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  76762. /**
  76763. * Translates the mesh
  76764. * @param axis The axis of translation
  76765. * @param distance The distance of translation
  76766. * @param space The space of the translation
  76767. * @returns The transform node
  76768. */
  76769. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  76770. /**
  76771. * Sets the absolute position of the mesh
  76772. * @param absolutePosition The absolute position of the mesh
  76773. * @returns The transform node
  76774. */
  76775. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  76776. /**
  76777. * Gets the class name of the mesh
  76778. * @returns The class name
  76779. */
  76780. getClassName(): string;
  76781. }
  76782. /**
  76783. * Represents a physics imposter
  76784. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76785. */
  76786. export class PhysicsImpostor {
  76787. /**
  76788. * The physics-enabled object used as the physics imposter
  76789. */
  76790. object: IPhysicsEnabledObject;
  76791. /**
  76792. * The type of the physics imposter
  76793. */
  76794. type: number;
  76795. private _options;
  76796. private _scene?;
  76797. /**
  76798. * The default object size of the imposter
  76799. */
  76800. static DEFAULT_OBJECT_SIZE: Vector3;
  76801. /**
  76802. * The identity quaternion of the imposter
  76803. */
  76804. static IDENTITY_QUATERNION: Quaternion;
  76805. /** @hidden */
  76806. _pluginData: any;
  76807. private _physicsEngine;
  76808. private _physicsBody;
  76809. private _bodyUpdateRequired;
  76810. private _onBeforePhysicsStepCallbacks;
  76811. private _onAfterPhysicsStepCallbacks;
  76812. /** @hidden */
  76813. _onPhysicsCollideCallbacks: Array<{
  76814. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76815. otherImpostors: Array<PhysicsImpostor>;
  76816. }>;
  76817. private _deltaPosition;
  76818. private _deltaRotation;
  76819. private _deltaRotationConjugated;
  76820. private _parent;
  76821. private _isDisposed;
  76822. private static _tmpVecs;
  76823. private static _tmpQuat;
  76824. /**
  76825. * Specifies if the physics imposter is disposed
  76826. */
  76827. readonly isDisposed: boolean;
  76828. /**
  76829. * Gets the mass of the physics imposter
  76830. */
  76831. mass: number;
  76832. /**
  76833. * Gets the coefficient of friction
  76834. */
  76835. /**
  76836. * Sets the coefficient of friction
  76837. */
  76838. friction: number;
  76839. /**
  76840. * Gets the coefficient of restitution
  76841. */
  76842. /**
  76843. * Sets the coefficient of restitution
  76844. */
  76845. restitution: number;
  76846. /**
  76847. * The unique id of the physics imposter
  76848. * set by the physics engine when adding this impostor to the array
  76849. */
  76850. uniqueId: number;
  76851. private _joints;
  76852. /**
  76853. * Initializes the physics imposter
  76854. * @param object The physics-enabled object used as the physics imposter
  76855. * @param type The type of the physics imposter
  76856. * @param _options The options for the physics imposter
  76857. * @param _scene The Babylon scene
  76858. */
  76859. constructor(
  76860. /**
  76861. * The physics-enabled object used as the physics imposter
  76862. */
  76863. object: IPhysicsEnabledObject,
  76864. /**
  76865. * The type of the physics imposter
  76866. */
  76867. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76868. /**
  76869. * This function will completly initialize this impostor.
  76870. * It will create a new body - but only if this mesh has no parent.
  76871. * If it has, this impostor will not be used other than to define the impostor
  76872. * of the child mesh.
  76873. * @hidden
  76874. */
  76875. _init(): void;
  76876. private _getPhysicsParent;
  76877. /**
  76878. * Should a new body be generated.
  76879. * @returns boolean specifying if body initialization is required
  76880. */
  76881. isBodyInitRequired(): boolean;
  76882. /**
  76883. * Sets the updated scaling
  76884. * @param updated Specifies if the scaling is updated
  76885. */
  76886. setScalingUpdated(): void;
  76887. /**
  76888. * Force a regeneration of this or the parent's impostor's body.
  76889. * Use under cautious - This will remove all joints already implemented.
  76890. */
  76891. forceUpdate(): void;
  76892. /**
  76893. * Gets the body that holds this impostor. Either its own, or its parent.
  76894. */
  76895. /**
  76896. * Set the physics body. Used mainly by the physics engine/plugin
  76897. */
  76898. physicsBody: any;
  76899. /**
  76900. * Get the parent of the physics imposter
  76901. * @returns Physics imposter or null
  76902. */
  76903. /**
  76904. * Sets the parent of the physics imposter
  76905. */
  76906. parent: Nullable<PhysicsImpostor>;
  76907. /**
  76908. * Resets the update flags
  76909. */
  76910. resetUpdateFlags(): void;
  76911. /**
  76912. * Gets the object extend size
  76913. * @returns the object extend size
  76914. */
  76915. getObjectExtendSize(): Vector3;
  76916. /**
  76917. * Gets the object center
  76918. * @returns The object center
  76919. */
  76920. getObjectCenter(): Vector3;
  76921. /**
  76922. * Get a specific parametes from the options parameter
  76923. * @param paramName The object parameter name
  76924. * @returns The object parameter
  76925. */
  76926. getParam(paramName: string): any;
  76927. /**
  76928. * Sets a specific parameter in the options given to the physics plugin
  76929. * @param paramName The parameter name
  76930. * @param value The value of the parameter
  76931. */
  76932. setParam(paramName: string, value: number): void;
  76933. /**
  76934. * Specifically change the body's mass option. Won't recreate the physics body object
  76935. * @param mass The mass of the physics imposter
  76936. */
  76937. setMass(mass: number): void;
  76938. /**
  76939. * Gets the linear velocity
  76940. * @returns linear velocity or null
  76941. */
  76942. getLinearVelocity(): Nullable<Vector3>;
  76943. /**
  76944. * Sets the linear velocity
  76945. * @param velocity linear velocity or null
  76946. */
  76947. setLinearVelocity(velocity: Nullable<Vector3>): void;
  76948. /**
  76949. * Gets the angular velocity
  76950. * @returns angular velocity or null
  76951. */
  76952. getAngularVelocity(): Nullable<Vector3>;
  76953. /**
  76954. * Sets the angular velocity
  76955. * @param velocity The velocity or null
  76956. */
  76957. setAngularVelocity(velocity: Nullable<Vector3>): void;
  76958. /**
  76959. * Execute a function with the physics plugin native code
  76960. * Provide a function the will have two variables - the world object and the physics body object
  76961. * @param func The function to execute with the physics plugin native code
  76962. */
  76963. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  76964. /**
  76965. * Register a function that will be executed before the physics world is stepping forward
  76966. * @param func The function to execute before the physics world is stepped forward
  76967. */
  76968. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76969. /**
  76970. * Unregister a function that will be executed before the physics world is stepping forward
  76971. * @param func The function to execute before the physics world is stepped forward
  76972. */
  76973. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76974. /**
  76975. * Register a function that will be executed after the physics step
  76976. * @param func The function to execute after physics step
  76977. */
  76978. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76979. /**
  76980. * Unregisters a function that will be executed after the physics step
  76981. * @param func The function to execute after physics step
  76982. */
  76983. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76984. /**
  76985. * register a function that will be executed when this impostor collides against a different body
  76986. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  76987. * @param func Callback that is executed on collision
  76988. */
  76989. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  76990. /**
  76991. * Unregisters the physics imposter on contact
  76992. * @param collideAgainst The physics object to collide against
  76993. * @param func Callback to execute on collision
  76994. */
  76995. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  76996. private _tmpQuat;
  76997. private _tmpQuat2;
  76998. /**
  76999. * Get the parent rotation
  77000. * @returns The parent rotation
  77001. */
  77002. getParentsRotation(): Quaternion;
  77003. /**
  77004. * this function is executed by the physics engine.
  77005. */
  77006. beforeStep: () => void;
  77007. /**
  77008. * this function is executed by the physics engine
  77009. */
  77010. afterStep: () => void;
  77011. /**
  77012. * Legacy collision detection event support
  77013. */
  77014. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  77015. /**
  77016. * event and body object due to cannon's event-based architecture.
  77017. */
  77018. onCollide: (e: {
  77019. body: any;
  77020. }) => void;
  77021. /**
  77022. * Apply a force
  77023. * @param force The force to apply
  77024. * @param contactPoint The contact point for the force
  77025. * @returns The physics imposter
  77026. */
  77027. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77028. /**
  77029. * Apply an impulse
  77030. * @param force The impulse force
  77031. * @param contactPoint The contact point for the impulse force
  77032. * @returns The physics imposter
  77033. */
  77034. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77035. /**
  77036. * A help function to create a joint
  77037. * @param otherImpostor A physics imposter used to create a joint
  77038. * @param jointType The type of joint
  77039. * @param jointData The data for the joint
  77040. * @returns The physics imposter
  77041. */
  77042. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  77043. /**
  77044. * Add a joint to this impostor with a different impostor
  77045. * @param otherImpostor A physics imposter used to add a joint
  77046. * @param joint The joint to add
  77047. * @returns The physics imposter
  77048. */
  77049. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  77050. /**
  77051. * Will keep this body still, in a sleep mode.
  77052. * @returns the physics imposter
  77053. */
  77054. sleep(): PhysicsImpostor;
  77055. /**
  77056. * Wake the body up.
  77057. * @returns The physics imposter
  77058. */
  77059. wakeUp(): PhysicsImpostor;
  77060. /**
  77061. * Clones the physics imposter
  77062. * @param newObject The physics imposter clones to this physics-enabled object
  77063. * @returns A nullable physics imposter
  77064. */
  77065. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77066. /**
  77067. * Disposes the physics imposter
  77068. */
  77069. dispose(): void;
  77070. /**
  77071. * Sets the delta position
  77072. * @param position The delta position amount
  77073. */
  77074. setDeltaPosition(position: Vector3): void;
  77075. /**
  77076. * Sets the delta rotation
  77077. * @param rotation The delta rotation amount
  77078. */
  77079. setDeltaRotation(rotation: Quaternion): void;
  77080. /**
  77081. * Gets the box size of the physics imposter and stores the result in the input parameter
  77082. * @param result Stores the box size
  77083. * @returns The physics imposter
  77084. */
  77085. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  77086. /**
  77087. * Gets the radius of the physics imposter
  77088. * @returns Radius of the physics imposter
  77089. */
  77090. getRadius(): number;
  77091. /**
  77092. * Sync a bone with this impostor
  77093. * @param bone The bone to sync to the impostor.
  77094. * @param boneMesh The mesh that the bone is influencing.
  77095. * @param jointPivot The pivot of the joint / bone in local space.
  77096. * @param distToJoint Optional distance from the impostor to the joint.
  77097. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77098. */
  77099. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  77100. /**
  77101. * Sync impostor to a bone
  77102. * @param bone The bone that the impostor will be synced to.
  77103. * @param boneMesh The mesh that the bone is influencing.
  77104. * @param jointPivot The pivot of the joint / bone in local space.
  77105. * @param distToJoint Optional distance from the impostor to the joint.
  77106. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77107. * @param boneAxis Optional vector3 axis the bone is aligned with
  77108. */
  77109. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  77110. /**
  77111. * No-Imposter type
  77112. */
  77113. static NoImpostor: number;
  77114. /**
  77115. * Sphere-Imposter type
  77116. */
  77117. static SphereImpostor: number;
  77118. /**
  77119. * Box-Imposter type
  77120. */
  77121. static BoxImpostor: number;
  77122. /**
  77123. * Plane-Imposter type
  77124. */
  77125. static PlaneImpostor: number;
  77126. /**
  77127. * Mesh-imposter type
  77128. */
  77129. static MeshImpostor: number;
  77130. /**
  77131. * Cylinder-Imposter type
  77132. */
  77133. static CylinderImpostor: number;
  77134. /**
  77135. * Particle-Imposter type
  77136. */
  77137. static ParticleImpostor: number;
  77138. /**
  77139. * Heightmap-Imposter type
  77140. */
  77141. static HeightmapImpostor: number;
  77142. }
  77143. }
  77144. declare module BABYLON {
  77145. /**
  77146. * Class used to represent a specific level of detail of a mesh
  77147. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77148. */
  77149. export class MeshLODLevel {
  77150. /** Defines the distance where this level should star being displayed */
  77151. distance: number;
  77152. /** Defines the mesh to use to render this level */
  77153. mesh: Nullable<Mesh>;
  77154. /**
  77155. * Creates a new LOD level
  77156. * @param distance defines the distance where this level should star being displayed
  77157. * @param mesh defines the mesh to use to render this level
  77158. */
  77159. constructor(
  77160. /** Defines the distance where this level should star being displayed */
  77161. distance: number,
  77162. /** Defines the mesh to use to render this level */
  77163. mesh: Nullable<Mesh>);
  77164. }
  77165. /**
  77166. * @hidden
  77167. **/
  77168. export class _CreationDataStorage {
  77169. closePath?: boolean;
  77170. closeArray?: boolean;
  77171. idx: number[];
  77172. dashSize: number;
  77173. gapSize: number;
  77174. path3D: Path3D;
  77175. pathArray: Vector3[][];
  77176. arc: number;
  77177. radius: number;
  77178. cap: number;
  77179. tessellation: number;
  77180. }
  77181. /**
  77182. * @hidden
  77183. **/
  77184. class _InstanceDataStorage {
  77185. visibleInstances: any;
  77186. renderIdForInstances: number[];
  77187. batchCache: _InstancesBatch;
  77188. instancesBufferSize: number;
  77189. instancesBuffer: Nullable<Buffer>;
  77190. instancesData: Float32Array;
  77191. overridenInstanceCount: number;
  77192. }
  77193. /**
  77194. * @hidden
  77195. **/
  77196. export class _InstancesBatch {
  77197. mustReturn: boolean;
  77198. visibleInstances: Nullable<InstancedMesh[]>[];
  77199. renderSelf: boolean[];
  77200. }
  77201. /**
  77202. * Class used to represent renderable models
  77203. */
  77204. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  77205. /**
  77206. * Mesh side orientation : usually the external or front surface
  77207. */
  77208. static readonly FRONTSIDE: number;
  77209. /**
  77210. * Mesh side orientation : usually the internal or back surface
  77211. */
  77212. static readonly BACKSIDE: number;
  77213. /**
  77214. * Mesh side orientation : both internal and external or front and back surfaces
  77215. */
  77216. static readonly DOUBLESIDE: number;
  77217. /**
  77218. * Mesh side orientation : by default, `FRONTSIDE`
  77219. */
  77220. static readonly DEFAULTSIDE: number;
  77221. /**
  77222. * Mesh cap setting : no cap
  77223. */
  77224. static readonly NO_CAP: number;
  77225. /**
  77226. * Mesh cap setting : one cap at the beginning of the mesh
  77227. */
  77228. static readonly CAP_START: number;
  77229. /**
  77230. * Mesh cap setting : one cap at the end of the mesh
  77231. */
  77232. static readonly CAP_END: number;
  77233. /**
  77234. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  77235. */
  77236. static readonly CAP_ALL: number;
  77237. /**
  77238. * Gets the default side orientation.
  77239. * @param orientation the orientation to value to attempt to get
  77240. * @returns the default orientation
  77241. * @hidden
  77242. */
  77243. static _GetDefaultSideOrientation(orientation?: number): number;
  77244. private _onBeforeRenderObservable;
  77245. private _onBeforeBindObservable;
  77246. private _onAfterRenderObservable;
  77247. private _onBeforeDrawObservable;
  77248. /**
  77249. * An event triggered before rendering the mesh
  77250. */
  77251. readonly onBeforeRenderObservable: Observable<Mesh>;
  77252. /**
  77253. * An event triggered before binding the mesh
  77254. */
  77255. readonly onBeforeBindObservable: Observable<Mesh>;
  77256. /**
  77257. * An event triggered after rendering the mesh
  77258. */
  77259. readonly onAfterRenderObservable: Observable<Mesh>;
  77260. /**
  77261. * An event triggered before drawing the mesh
  77262. */
  77263. readonly onBeforeDrawObservable: Observable<Mesh>;
  77264. private _onBeforeDrawObserver;
  77265. /**
  77266. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  77267. */
  77268. onBeforeDraw: () => void;
  77269. /**
  77270. * Gets the delay loading state of the mesh (when delay loading is turned on)
  77271. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  77272. */
  77273. delayLoadState: number;
  77274. /**
  77275. * Gets the list of instances created from this mesh
  77276. * it is not supposed to be modified manually.
  77277. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  77278. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77279. */
  77280. instances: InstancedMesh[];
  77281. /**
  77282. * Gets the file containing delay loading data for this mesh
  77283. */
  77284. delayLoadingFile: string;
  77285. /** @hidden */
  77286. _binaryInfo: any;
  77287. private _LODLevels;
  77288. /**
  77289. * User defined function used to change how LOD level selection is done
  77290. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77291. */
  77292. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  77293. private _morphTargetManager;
  77294. /**
  77295. * Gets or sets the morph target manager
  77296. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77297. */
  77298. morphTargetManager: Nullable<MorphTargetManager>;
  77299. /** @hidden */
  77300. _creationDataStorage: Nullable<_CreationDataStorage>;
  77301. /** @hidden */
  77302. _geometry: Nullable<Geometry>;
  77303. /** @hidden */
  77304. _delayInfo: Array<string>;
  77305. /** @hidden */
  77306. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77307. /** @hidden */
  77308. _instanceDataStorage: _InstanceDataStorage;
  77309. private _effectiveMaterial;
  77310. /** @hidden */
  77311. _shouldGenerateFlatShading: boolean;
  77312. private _preActivateId;
  77313. /** @hidden */
  77314. _originalBuilderSideOrientation: number;
  77315. /**
  77316. * Use this property to change the original side orientation defined at construction time
  77317. */
  77318. overrideMaterialSideOrientation: Nullable<number>;
  77319. private _areNormalsFrozen;
  77320. private _sourcePositions;
  77321. private _sourceNormals;
  77322. private _source;
  77323. private meshMap;
  77324. /**
  77325. * Gets the source mesh (the one used to clone this one from)
  77326. */
  77327. readonly source: Nullable<Mesh>;
  77328. /**
  77329. * Gets or sets a boolean indicating that this mesh does not use index buffer
  77330. */
  77331. isUnIndexed: boolean;
  77332. /**
  77333. * @constructor
  77334. * @param name The value used by scene.getMeshByName() to do a lookup.
  77335. * @param scene The scene to add this mesh to.
  77336. * @param parent The parent of this mesh, if it has one
  77337. * @param source An optional Mesh from which geometry is shared, cloned.
  77338. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77339. * When false, achieved by calling a clone(), also passing False.
  77340. * This will make creation of children, recursive.
  77341. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  77342. */
  77343. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  77344. /**
  77345. * Gets the class name
  77346. * @returns the string "Mesh".
  77347. */
  77348. getClassName(): string;
  77349. /** @hidden */
  77350. readonly _isMesh: boolean;
  77351. /**
  77352. * Returns a description of this mesh
  77353. * @param fullDetails define if full details about this mesh must be used
  77354. * @returns a descriptive string representing this mesh
  77355. */
  77356. toString(fullDetails?: boolean): string;
  77357. /** @hidden */
  77358. _unBindEffect(): void;
  77359. /**
  77360. * Gets a boolean indicating if this mesh has LOD
  77361. */
  77362. readonly hasLODLevels: boolean;
  77363. /**
  77364. * Gets the list of MeshLODLevel associated with the current mesh
  77365. * @returns an array of MeshLODLevel
  77366. */
  77367. getLODLevels(): MeshLODLevel[];
  77368. private _sortLODLevels;
  77369. /**
  77370. * Add a mesh as LOD level triggered at the given distance.
  77371. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77372. * @param distance The distance from the center of the object to show this level
  77373. * @param mesh The mesh to be added as LOD level (can be null)
  77374. * @return This mesh (for chaining)
  77375. */
  77376. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  77377. /**
  77378. * Returns the LOD level mesh at the passed distance or null if not found.
  77379. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77380. * @param distance The distance from the center of the object to show this level
  77381. * @returns a Mesh or `null`
  77382. */
  77383. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  77384. /**
  77385. * Remove a mesh from the LOD array
  77386. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77387. * @param mesh defines the mesh to be removed
  77388. * @return This mesh (for chaining)
  77389. */
  77390. removeLODLevel(mesh: Mesh): Mesh;
  77391. /**
  77392. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  77393. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77394. * @param camera defines the camera to use to compute distance
  77395. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  77396. * @return This mesh (for chaining)
  77397. */
  77398. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  77399. /**
  77400. * Gets the mesh internal Geometry object
  77401. */
  77402. readonly geometry: Nullable<Geometry>;
  77403. /**
  77404. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  77405. * @returns the total number of vertices
  77406. */
  77407. getTotalVertices(): number;
  77408. /**
  77409. * Returns the content of an associated vertex buffer
  77410. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77411. * - VertexBuffer.PositionKind
  77412. * - VertexBuffer.UVKind
  77413. * - VertexBuffer.UV2Kind
  77414. * - VertexBuffer.UV3Kind
  77415. * - VertexBuffer.UV4Kind
  77416. * - VertexBuffer.UV5Kind
  77417. * - VertexBuffer.UV6Kind
  77418. * - VertexBuffer.ColorKind
  77419. * - VertexBuffer.MatricesIndicesKind
  77420. * - VertexBuffer.MatricesIndicesExtraKind
  77421. * - VertexBuffer.MatricesWeightsKind
  77422. * - VertexBuffer.MatricesWeightsExtraKind
  77423. * @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
  77424. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77425. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77426. */
  77427. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77428. /**
  77429. * Returns the mesh VertexBuffer object from the requested `kind`
  77430. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77431. * - VertexBuffer.PositionKind
  77432. * - VertexBuffer.UVKind
  77433. * - VertexBuffer.UV2Kind
  77434. * - VertexBuffer.UV3Kind
  77435. * - VertexBuffer.UV4Kind
  77436. * - VertexBuffer.UV5Kind
  77437. * - VertexBuffer.UV6Kind
  77438. * - VertexBuffer.ColorKind
  77439. * - VertexBuffer.MatricesIndicesKind
  77440. * - VertexBuffer.MatricesIndicesExtraKind
  77441. * - VertexBuffer.MatricesWeightsKind
  77442. * - VertexBuffer.MatricesWeightsExtraKind
  77443. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  77444. */
  77445. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77446. /**
  77447. * Tests if a specific vertex buffer is associated with this mesh
  77448. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77449. * - VertexBuffer.PositionKind
  77450. * - VertexBuffer.UVKind
  77451. * - VertexBuffer.UV2Kind
  77452. * - VertexBuffer.UV3Kind
  77453. * - VertexBuffer.UV4Kind
  77454. * - VertexBuffer.UV5Kind
  77455. * - VertexBuffer.UV6Kind
  77456. * - VertexBuffer.ColorKind
  77457. * - VertexBuffer.MatricesIndicesKind
  77458. * - VertexBuffer.MatricesIndicesExtraKind
  77459. * - VertexBuffer.MatricesWeightsKind
  77460. * - VertexBuffer.MatricesWeightsExtraKind
  77461. * @returns a boolean
  77462. */
  77463. isVerticesDataPresent(kind: string): boolean;
  77464. /**
  77465. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  77466. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77467. * - VertexBuffer.PositionKind
  77468. * - VertexBuffer.UVKind
  77469. * - VertexBuffer.UV2Kind
  77470. * - VertexBuffer.UV3Kind
  77471. * - VertexBuffer.UV4Kind
  77472. * - VertexBuffer.UV5Kind
  77473. * - VertexBuffer.UV6Kind
  77474. * - VertexBuffer.ColorKind
  77475. * - VertexBuffer.MatricesIndicesKind
  77476. * - VertexBuffer.MatricesIndicesExtraKind
  77477. * - VertexBuffer.MatricesWeightsKind
  77478. * - VertexBuffer.MatricesWeightsExtraKind
  77479. * @returns a boolean
  77480. */
  77481. isVertexBufferUpdatable(kind: string): boolean;
  77482. /**
  77483. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  77484. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77485. * - VertexBuffer.PositionKind
  77486. * - VertexBuffer.UVKind
  77487. * - VertexBuffer.UV2Kind
  77488. * - VertexBuffer.UV3Kind
  77489. * - VertexBuffer.UV4Kind
  77490. * - VertexBuffer.UV5Kind
  77491. * - VertexBuffer.UV6Kind
  77492. * - VertexBuffer.ColorKind
  77493. * - VertexBuffer.MatricesIndicesKind
  77494. * - VertexBuffer.MatricesIndicesExtraKind
  77495. * - VertexBuffer.MatricesWeightsKind
  77496. * - VertexBuffer.MatricesWeightsExtraKind
  77497. * @returns an array of strings
  77498. */
  77499. getVerticesDataKinds(): string[];
  77500. /**
  77501. * Returns a positive integer : the total number of indices in this mesh geometry.
  77502. * @returns the numner of indices or zero if the mesh has no geometry.
  77503. */
  77504. getTotalIndices(): number;
  77505. /**
  77506. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77507. * @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.
  77508. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77509. * @returns the indices array or an empty array if the mesh has no geometry
  77510. */
  77511. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77512. readonly isBlocked: boolean;
  77513. /**
  77514. * Determine if the current mesh is ready to be rendered
  77515. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  77516. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  77517. * @returns true if all associated assets are ready (material, textures, shaders)
  77518. */
  77519. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  77520. /**
  77521. * 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.
  77522. */
  77523. readonly areNormalsFrozen: boolean;
  77524. /**
  77525. * 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.
  77526. * @returns the current mesh
  77527. */
  77528. freezeNormals(): Mesh;
  77529. /**
  77530. * 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
  77531. * @returns the current mesh
  77532. */
  77533. unfreezeNormals(): Mesh;
  77534. /**
  77535. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77536. */
  77537. overridenInstanceCount: number;
  77538. /** @hidden */
  77539. _preActivate(): Mesh;
  77540. /** @hidden */
  77541. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77542. /** @hidden */
  77543. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77544. /**
  77545. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77546. * This means the mesh underlying bounding box and sphere are recomputed.
  77547. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77548. * @returns the current mesh
  77549. */
  77550. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77551. /** @hidden */
  77552. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77553. /**
  77554. * This function will subdivide the mesh into multiple submeshes
  77555. * @param count defines the expected number of submeshes
  77556. */
  77557. subdivide(count: number): void;
  77558. /**
  77559. * Copy a FloatArray into a specific associated vertex buffer
  77560. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77561. * - VertexBuffer.PositionKind
  77562. * - VertexBuffer.UVKind
  77563. * - VertexBuffer.UV2Kind
  77564. * - VertexBuffer.UV3Kind
  77565. * - VertexBuffer.UV4Kind
  77566. * - VertexBuffer.UV5Kind
  77567. * - VertexBuffer.UV6Kind
  77568. * - VertexBuffer.ColorKind
  77569. * - VertexBuffer.MatricesIndicesKind
  77570. * - VertexBuffer.MatricesIndicesExtraKind
  77571. * - VertexBuffer.MatricesWeightsKind
  77572. * - VertexBuffer.MatricesWeightsExtraKind
  77573. * @param data defines the data source
  77574. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77575. * @param stride defines the data stride size (can be null)
  77576. * @returns the current mesh
  77577. */
  77578. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77579. /**
  77580. * Flags an associated vertex buffer as updatable
  77581. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77582. * - VertexBuffer.PositionKind
  77583. * - VertexBuffer.UVKind
  77584. * - VertexBuffer.UV2Kind
  77585. * - VertexBuffer.UV3Kind
  77586. * - VertexBuffer.UV4Kind
  77587. * - VertexBuffer.UV5Kind
  77588. * - VertexBuffer.UV6Kind
  77589. * - VertexBuffer.ColorKind
  77590. * - VertexBuffer.MatricesIndicesKind
  77591. * - VertexBuffer.MatricesIndicesExtraKind
  77592. * - VertexBuffer.MatricesWeightsKind
  77593. * - VertexBuffer.MatricesWeightsExtraKind
  77594. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77595. */
  77596. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77597. /**
  77598. * Sets the mesh global Vertex Buffer
  77599. * @param buffer defines the buffer to use
  77600. * @returns the current mesh
  77601. */
  77602. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77603. /**
  77604. * Update a specific associated vertex buffer
  77605. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77606. * - VertexBuffer.PositionKind
  77607. * - VertexBuffer.UVKind
  77608. * - VertexBuffer.UV2Kind
  77609. * - VertexBuffer.UV3Kind
  77610. * - VertexBuffer.UV4Kind
  77611. * - VertexBuffer.UV5Kind
  77612. * - VertexBuffer.UV6Kind
  77613. * - VertexBuffer.ColorKind
  77614. * - VertexBuffer.MatricesIndicesKind
  77615. * - VertexBuffer.MatricesIndicesExtraKind
  77616. * - VertexBuffer.MatricesWeightsKind
  77617. * - VertexBuffer.MatricesWeightsExtraKind
  77618. * @param data defines the data source
  77619. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77620. * @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)
  77621. * @returns the current mesh
  77622. */
  77623. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77624. /**
  77625. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77626. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77627. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77628. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77629. * @returns the current mesh
  77630. */
  77631. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77632. /**
  77633. * Creates a un-shared specific occurence of the geometry for the mesh.
  77634. * @returns the current mesh
  77635. */
  77636. makeGeometryUnique(): Mesh;
  77637. /**
  77638. * Set the index buffer of this mesh
  77639. * @param indices defines the source data
  77640. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77641. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77642. * @returns the current mesh
  77643. */
  77644. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77645. /**
  77646. * Update the current index buffer
  77647. * @param indices defines the source data
  77648. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77649. * @returns the current mesh
  77650. */
  77651. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  77652. /**
  77653. * Invert the geometry to move from a right handed system to a left handed one.
  77654. * @returns the current mesh
  77655. */
  77656. toLeftHanded(): Mesh;
  77657. /** @hidden */
  77658. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77659. /** @hidden */
  77660. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  77661. /**
  77662. * Registers for this mesh a javascript function called just before the rendering process
  77663. * @param func defines the function to call before rendering this mesh
  77664. * @returns the current mesh
  77665. */
  77666. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77667. /**
  77668. * Disposes a previously registered javascript function called before the rendering
  77669. * @param func defines the function to remove
  77670. * @returns the current mesh
  77671. */
  77672. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77673. /**
  77674. * Registers for this mesh a javascript function called just after the rendering is complete
  77675. * @param func defines the function to call after rendering this mesh
  77676. * @returns the current mesh
  77677. */
  77678. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77679. /**
  77680. * Disposes a previously registered javascript function called after the rendering.
  77681. * @param func defines the function to remove
  77682. * @returns the current mesh
  77683. */
  77684. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77685. /** @hidden */
  77686. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  77687. /** @hidden */
  77688. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  77689. /** @hidden */
  77690. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  77691. /**
  77692. * 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
  77693. * @param subMesh defines the subMesh to render
  77694. * @param enableAlphaMode defines if alpha mode can be changed
  77695. * @returns the current mesh
  77696. */
  77697. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77698. private _onBeforeDraw;
  77699. /**
  77700. * Renormalize the mesh and patch it up if there are no weights
  77701. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77702. * However in the case of zero weights then we set just a single influence to 1.
  77703. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77704. */
  77705. cleanMatrixWeights(): void;
  77706. private normalizeSkinFourWeights;
  77707. private normalizeSkinWeightsAndExtra;
  77708. /**
  77709. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77710. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77711. * the user know there was an issue with importing the mesh
  77712. * @returns a validation object with skinned, valid and report string
  77713. */
  77714. validateSkinning(): {
  77715. skinned: boolean;
  77716. valid: boolean;
  77717. report: string;
  77718. };
  77719. /** @hidden */
  77720. _checkDelayState(): Mesh;
  77721. private _queueLoad;
  77722. /**
  77723. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77724. * A mesh is in the frustum if its bounding box intersects the frustum
  77725. * @param frustumPlanes defines the frustum to test
  77726. * @returns true if the mesh is in the frustum planes
  77727. */
  77728. isInFrustum(frustumPlanes: Plane[]): boolean;
  77729. /**
  77730. * Sets the mesh material by the material or multiMaterial `id` property
  77731. * @param id is a string identifying the material or the multiMaterial
  77732. * @returns the current mesh
  77733. */
  77734. setMaterialByID(id: string): Mesh;
  77735. /**
  77736. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77737. * @returns an array of IAnimatable
  77738. */
  77739. getAnimatables(): IAnimatable[];
  77740. /**
  77741. * Modifies the mesh geometry according to the passed transformation matrix.
  77742. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77743. * The mesh normals are modified using the same transformation.
  77744. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77745. * @param transform defines the transform matrix to use
  77746. * @see http://doc.babylonjs.com/resources/baking_transformations
  77747. * @returns the current mesh
  77748. */
  77749. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77750. /**
  77751. * Modifies the mesh geometry according to its own current World Matrix.
  77752. * The mesh World Matrix is then reset.
  77753. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77754. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77755. * @see http://doc.babylonjs.com/resources/baking_transformations
  77756. * @returns the current mesh
  77757. */
  77758. bakeCurrentTransformIntoVertices(): Mesh;
  77759. /** @hidden */
  77760. readonly _positions: Nullable<Vector3[]>;
  77761. /** @hidden */
  77762. _resetPointsArrayCache(): Mesh;
  77763. /** @hidden */
  77764. _generatePointsArray(): boolean;
  77765. /**
  77766. * Returns a new Mesh object generated from the current mesh properties.
  77767. * This method must not get confused with createInstance()
  77768. * @param name is a string, the name given to the new mesh
  77769. * @param newParent can be any Node object (default `null`)
  77770. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77771. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77772. * @returns a new mesh
  77773. */
  77774. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77775. /**
  77776. * Releases resources associated with this mesh.
  77777. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77778. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77779. */
  77780. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77781. /**
  77782. * Modifies the mesh geometry according to a displacement map.
  77783. * 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.
  77784. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77785. * @param url is a string, the URL from the image file is to be downloaded.
  77786. * @param minHeight is the lower limit of the displacement.
  77787. * @param maxHeight is the upper limit of the displacement.
  77788. * @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.
  77789. * @param uvOffset is an optional vector2 used to offset UV.
  77790. * @param uvScale is an optional vector2 used to scale UV.
  77791. * @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.
  77792. * @returns the Mesh.
  77793. */
  77794. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77795. /**
  77796. * Modifies the mesh geometry according to a displacementMap buffer.
  77797. * 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.
  77798. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77799. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77800. * @param heightMapWidth is the width of the buffer image.
  77801. * @param heightMapHeight is the height of the buffer image.
  77802. * @param minHeight is the lower limit of the displacement.
  77803. * @param maxHeight is the upper limit of the displacement.
  77804. * @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.
  77805. * @param uvOffset is an optional vector2 used to offset UV.
  77806. * @param uvScale is an optional vector2 used to scale UV.
  77807. * @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.
  77808. * @returns the Mesh.
  77809. */
  77810. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77811. /**
  77812. * Modify the mesh to get a flat shading rendering.
  77813. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77814. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77815. * @returns current mesh
  77816. */
  77817. convertToFlatShadedMesh(): Mesh;
  77818. /**
  77819. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77820. * In other words, more vertices, no more indices and a single bigger VBO.
  77821. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77822. * @returns current mesh
  77823. */
  77824. convertToUnIndexedMesh(): Mesh;
  77825. /**
  77826. * Inverses facet orientations.
  77827. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77828. * @param flipNormals will also inverts the normals
  77829. * @returns current mesh
  77830. */
  77831. flipFaces(flipNormals?: boolean): Mesh;
  77832. /** @hidden */
  77833. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77834. /** @hidden */
  77835. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77836. /**
  77837. * Creates a new InstancedMesh object from the mesh model.
  77838. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77839. * @param name defines the name of the new instance
  77840. * @returns a new InstancedMesh
  77841. */
  77842. createInstance(name: string): InstancedMesh;
  77843. /**
  77844. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77845. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77846. * @returns the current mesh
  77847. */
  77848. synchronizeInstances(): Mesh;
  77849. /**
  77850. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77851. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77852. * This should be used together with the simplification to avoid disappearing triangles.
  77853. * @param successCallback an optional success callback to be called after the optimization finished.
  77854. * @returns the current mesh
  77855. */
  77856. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77857. /**
  77858. * Serialize current mesh
  77859. * @param serializationObject defines the object which will receive the serialization data
  77860. */
  77861. serialize(serializationObject: any): void;
  77862. /** @hidden */
  77863. _syncGeometryWithMorphTargetManager(): void;
  77864. /** @hidden */
  77865. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77866. /**
  77867. * Returns a new Mesh object parsed from the source provided.
  77868. * @param parsedMesh is the source
  77869. * @param scene defines the hosting scene
  77870. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77871. * @returns a new Mesh
  77872. */
  77873. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77874. /**
  77875. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77876. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77877. * @param name defines the name of the mesh to create
  77878. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77879. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77880. * @param closePath creates a seam between the first and the last points of each path of the path array
  77881. * @param offset is taken in account only if the `pathArray` is containing a single path
  77882. * @param scene defines the hosting scene
  77883. * @param updatable defines if the mesh must be flagged as updatable
  77884. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77885. * @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)
  77886. * @returns a new Mesh
  77887. */
  77888. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77889. /**
  77890. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77891. * @param name defines the name of the mesh to create
  77892. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77893. * @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
  77894. * @param scene defines the hosting scene
  77895. * @param updatable defines if the mesh must be flagged as updatable
  77896. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77897. * @returns a new Mesh
  77898. */
  77899. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77900. /**
  77901. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77902. * @param name defines the name of the mesh to create
  77903. * @param size sets the size (float) of each box side (default 1)
  77904. * @param scene defines the hosting scene
  77905. * @param updatable defines if the mesh must be flagged as updatable
  77906. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77907. * @returns a new Mesh
  77908. */
  77909. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77910. /**
  77911. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77912. * @param name defines the name of the mesh to create
  77913. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77914. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77915. * @param scene defines the hosting scene
  77916. * @param updatable defines if the mesh must be flagged as updatable
  77917. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77918. * @returns a new Mesh
  77919. */
  77920. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77921. /**
  77922. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77923. * @param name defines the name of the mesh to create
  77924. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77925. * @param diameterTop set the top cap diameter (floats, default 1)
  77926. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77927. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77928. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77929. * @param scene defines the hosting scene
  77930. * @param updatable defines if the mesh must be flagged as updatable
  77931. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77932. * @returns a new Mesh
  77933. */
  77934. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  77935. /**
  77936. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  77937. * @param name defines the name of the mesh to create
  77938. * @param diameter sets the diameter size (float) of the torus (default 1)
  77939. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  77940. * @param tessellation sets the number of torus sides (postive integer, default 16)
  77941. * @param scene defines the hosting scene
  77942. * @param updatable defines if the mesh must be flagged as updatable
  77943. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77944. * @returns a new Mesh
  77945. */
  77946. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77947. /**
  77948. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  77949. * @param name defines the name of the mesh to create
  77950. * @param radius sets the global radius size (float) of the torus knot (default 2)
  77951. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  77952. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  77953. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  77954. * @param p the number of windings on X axis (positive integers, default 2)
  77955. * @param q the number of windings on Y axis (positive integers, default 3)
  77956. * @param scene defines the hosting scene
  77957. * @param updatable defines if the mesh must be flagged as updatable
  77958. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77959. * @returns a new Mesh
  77960. */
  77961. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77962. /**
  77963. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  77964. * @param name defines the name of the mesh to create
  77965. * @param points is an array successive Vector3
  77966. * @param scene defines the hosting scene
  77967. * @param updatable defines if the mesh must be flagged as updatable
  77968. * @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).
  77969. * @returns a new Mesh
  77970. */
  77971. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  77972. /**
  77973. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  77974. * @param name defines the name of the mesh to create
  77975. * @param points is an array successive Vector3
  77976. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  77977. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  77978. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  77979. * @param scene defines the hosting scene
  77980. * @param updatable defines if the mesh must be flagged as updatable
  77981. * @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)
  77982. * @returns a new Mesh
  77983. */
  77984. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  77985. /**
  77986. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  77987. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  77988. * 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.
  77989. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77990. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77991. * Remember you can only change the shape positions, not their number when updating a polygon.
  77992. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  77993. * @param name defines the name of the mesh to create
  77994. * @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
  77995. * @param scene defines the hosting scene
  77996. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77997. * @param updatable defines if the mesh must be flagged as updatable
  77998. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77999. * @param earcutInjection can be used to inject your own earcut reference
  78000. * @returns a new Mesh
  78001. */
  78002. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78003. /**
  78004. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  78005. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  78006. * @param name defines the name of the mesh to create
  78007. * @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
  78008. * @param depth defines the height of extrusion
  78009. * @param scene defines the hosting scene
  78010. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78011. * @param updatable defines if the mesh must be flagged as updatable
  78012. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78013. * @param earcutInjection can be used to inject your own earcut reference
  78014. * @returns a new Mesh
  78015. */
  78016. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78017. /**
  78018. * Creates an extruded shape mesh.
  78019. * 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
  78020. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78021. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78022. * @param name defines the name of the mesh to create
  78023. * @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
  78024. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78025. * @param scale is the value to scale the shape
  78026. * @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
  78027. * @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
  78028. * @param scene defines the hosting scene
  78029. * @param updatable defines if the mesh must be flagged as updatable
  78030. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78031. * @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)
  78032. * @returns a new Mesh
  78033. */
  78034. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78035. /**
  78036. * Creates an custom extruded shape mesh.
  78037. * The custom extrusion is a parametric shape.
  78038. * It has no predefined shape. Its final shape will depend on the input parameters.
  78039. * Please consider using the same method from the MeshBuilder class instead
  78040. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78041. * @param name defines the name of the mesh to create
  78042. * @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
  78043. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78044. * @param scaleFunction is a custom Javascript function called on each path point
  78045. * @param rotationFunction is a custom Javascript function called on each path point
  78046. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  78047. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  78048. * @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
  78049. * @param scene defines the hosting scene
  78050. * @param updatable defines if the mesh must be flagged as updatable
  78051. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78052. * @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)
  78053. * @returns a new Mesh
  78054. */
  78055. 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;
  78056. /**
  78057. * Creates lathe mesh.
  78058. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  78059. * Please consider using the same method from the MeshBuilder class instead
  78060. * @param name defines the name of the mesh to create
  78061. * @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
  78062. * @param radius is the radius value of the lathe
  78063. * @param tessellation is the side number of the lathe.
  78064. * @param scene defines the hosting scene
  78065. * @param updatable defines if the mesh must be flagged as updatable
  78066. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78067. * @returns a new Mesh
  78068. */
  78069. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78070. /**
  78071. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  78072. * @param name defines the name of the mesh to create
  78073. * @param size sets the size (float) of both sides of the plane at once (default 1)
  78074. * @param scene defines the hosting scene
  78075. * @param updatable defines if the mesh must be flagged as updatable
  78076. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78077. * @returns a new Mesh
  78078. */
  78079. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78080. /**
  78081. * Creates a ground mesh.
  78082. * Please consider using the same method from the MeshBuilder class instead
  78083. * @param name defines the name of the mesh to create
  78084. * @param width set the width of the ground
  78085. * @param height set the height of the ground
  78086. * @param subdivisions sets the number of subdivisions per side
  78087. * @param scene defines the hosting scene
  78088. * @param updatable defines if the mesh must be flagged as updatable
  78089. * @returns a new Mesh
  78090. */
  78091. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  78092. /**
  78093. * Creates a tiled ground mesh.
  78094. * Please consider using the same method from the MeshBuilder class instead
  78095. * @param name defines the name of the mesh to create
  78096. * @param xmin set the ground minimum X coordinate
  78097. * @param zmin set the ground minimum Y coordinate
  78098. * @param xmax set the ground maximum X coordinate
  78099. * @param zmax set the ground maximum Z coordinate
  78100. * @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
  78101. * @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
  78102. * @param scene defines the hosting scene
  78103. * @param updatable defines if the mesh must be flagged as updatable
  78104. * @returns a new Mesh
  78105. */
  78106. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  78107. w: number;
  78108. h: number;
  78109. }, precision: {
  78110. w: number;
  78111. h: number;
  78112. }, scene: Scene, updatable?: boolean): Mesh;
  78113. /**
  78114. * Creates a ground mesh from a height map.
  78115. * Please consider using the same method from the MeshBuilder class instead
  78116. * @see http://doc.babylonjs.com/babylon101/height_map
  78117. * @param name defines the name of the mesh to create
  78118. * @param url sets the URL of the height map image resource
  78119. * @param width set the ground width size
  78120. * @param height set the ground height size
  78121. * @param subdivisions sets the number of subdivision per side
  78122. * @param minHeight is the minimum altitude on the ground
  78123. * @param maxHeight is the maximum altitude on the ground
  78124. * @param scene defines the hosting scene
  78125. * @param updatable defines if the mesh must be flagged as updatable
  78126. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  78127. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  78128. * @returns a new Mesh
  78129. */
  78130. 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;
  78131. /**
  78132. * Creates a tube mesh.
  78133. * The tube is a parametric shape.
  78134. * It has no predefined shape. Its final shape will depend on the input parameters.
  78135. * Please consider using the same method from the MeshBuilder class instead
  78136. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78137. * @param name defines the name of the mesh to create
  78138. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  78139. * @param radius sets the tube radius size
  78140. * @param tessellation is the number of sides on the tubular surface
  78141. * @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
  78142. * @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
  78143. * @param scene defines the hosting scene
  78144. * @param updatable defines if the mesh must be flagged as updatable
  78145. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78146. * @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)
  78147. * @returns a new Mesh
  78148. */
  78149. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  78150. (i: number, distance: number): number;
  78151. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78152. /**
  78153. * Creates a polyhedron mesh.
  78154. * Please consider using the same method from the MeshBuilder class instead.
  78155. * * 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
  78156. * * The parameter `size` (positive float, default 1) sets the polygon size
  78157. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  78158. * * 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`
  78159. * * 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
  78160. * * 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)`)
  78161. * * 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
  78162. * * 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
  78163. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78164. * * If you create a double-sided mesh, you can choose what parts of 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
  78165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78166. * @param name defines the name of the mesh to create
  78167. * @param options defines the options used to create the mesh
  78168. * @param scene defines the hosting scene
  78169. * @returns a new Mesh
  78170. */
  78171. static CreatePolyhedron(name: string, options: {
  78172. type?: number;
  78173. size?: number;
  78174. sizeX?: number;
  78175. sizeY?: number;
  78176. sizeZ?: number;
  78177. custom?: any;
  78178. faceUV?: Vector4[];
  78179. faceColors?: Color4[];
  78180. updatable?: boolean;
  78181. sideOrientation?: number;
  78182. }, scene: Scene): Mesh;
  78183. /**
  78184. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  78185. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  78186. * * 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`)
  78187. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  78188. * * 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
  78189. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78190. * * If you create a double-sided mesh, you can choose what parts of 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
  78191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78192. * @param name defines the name of the mesh
  78193. * @param options defines the options used to create the mesh
  78194. * @param scene defines the hosting scene
  78195. * @returns a new Mesh
  78196. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  78197. */
  78198. static CreateIcoSphere(name: string, options: {
  78199. radius?: number;
  78200. flat?: boolean;
  78201. subdivisions?: number;
  78202. sideOrientation?: number;
  78203. updatable?: boolean;
  78204. }, scene: Scene): Mesh;
  78205. /**
  78206. * Creates a decal mesh.
  78207. * Please consider using the same method from the MeshBuilder class instead.
  78208. * A decal is a mesh usually applied as a model onto the surface of another mesh
  78209. * @param name defines the name of the mesh
  78210. * @param sourceMesh defines the mesh receiving the decal
  78211. * @param position sets the position of the decal in world coordinates
  78212. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  78213. * @param size sets the decal scaling
  78214. * @param angle sets the angle to rotate the decal
  78215. * @returns a new Mesh
  78216. */
  78217. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  78218. /**
  78219. * Prepare internal position array for software CPU skinning
  78220. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  78221. */
  78222. setPositionsForCPUSkinning(): Float32Array;
  78223. /**
  78224. * Prepare internal normal array for software CPU skinning
  78225. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  78226. */
  78227. setNormalsForCPUSkinning(): Float32Array;
  78228. /**
  78229. * Updates the vertex buffer by applying transformation from the bones
  78230. * @param skeleton defines the skeleton to apply to current mesh
  78231. * @returns the current mesh
  78232. */
  78233. applySkeleton(skeleton: Skeleton): Mesh;
  78234. /**
  78235. * 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
  78236. * @param meshes defines the list of meshes to scan
  78237. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  78238. */
  78239. static MinMax(meshes: AbstractMesh[]): {
  78240. min: Vector3;
  78241. max: Vector3;
  78242. };
  78243. /**
  78244. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  78245. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  78246. * @returns a vector3
  78247. */
  78248. static Center(meshesOrMinMaxVector: {
  78249. min: Vector3;
  78250. max: Vector3;
  78251. } | AbstractMesh[]): Vector3;
  78252. /**
  78253. * Merge the array of meshes into a single mesh for performance reasons.
  78254. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  78255. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  78256. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  78257. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  78258. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  78259. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  78260. * @returns a new mesh
  78261. */
  78262. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  78263. /** @hidden */
  78264. addInstance(instance: InstancedMesh): void;
  78265. /** @hidden */
  78266. removeInstance(instance: InstancedMesh): void;
  78267. }
  78268. }
  78269. declare module BABYLON {
  78270. /**
  78271. * Base class for the main features of a material in Babylon.js
  78272. */
  78273. export class Material implements IAnimatable {
  78274. /**
  78275. * Returns the triangle fill mode
  78276. */
  78277. static readonly TriangleFillMode: number;
  78278. /**
  78279. * Returns the wireframe mode
  78280. */
  78281. static readonly WireFrameFillMode: number;
  78282. /**
  78283. * Returns the point fill mode
  78284. */
  78285. static readonly PointFillMode: number;
  78286. /**
  78287. * Returns the point list draw mode
  78288. */
  78289. static readonly PointListDrawMode: number;
  78290. /**
  78291. * Returns the line list draw mode
  78292. */
  78293. static readonly LineListDrawMode: number;
  78294. /**
  78295. * Returns the line loop draw mode
  78296. */
  78297. static readonly LineLoopDrawMode: number;
  78298. /**
  78299. * Returns the line strip draw mode
  78300. */
  78301. static readonly LineStripDrawMode: number;
  78302. /**
  78303. * Returns the triangle strip draw mode
  78304. */
  78305. static readonly TriangleStripDrawMode: number;
  78306. /**
  78307. * Returns the triangle fan draw mode
  78308. */
  78309. static readonly TriangleFanDrawMode: number;
  78310. /**
  78311. * Stores the clock-wise side orientation
  78312. */
  78313. static readonly ClockWiseSideOrientation: number;
  78314. /**
  78315. * Stores the counter clock-wise side orientation
  78316. */
  78317. static readonly CounterClockWiseSideOrientation: number;
  78318. /**
  78319. * The dirty texture flag value
  78320. */
  78321. static readonly TextureDirtyFlag: number;
  78322. /**
  78323. * The dirty light flag value
  78324. */
  78325. static readonly LightDirtyFlag: number;
  78326. /**
  78327. * The dirty fresnel flag value
  78328. */
  78329. static readonly FresnelDirtyFlag: number;
  78330. /**
  78331. * The dirty attribute flag value
  78332. */
  78333. static readonly AttributesDirtyFlag: number;
  78334. /**
  78335. * The dirty misc flag value
  78336. */
  78337. static readonly MiscDirtyFlag: number;
  78338. /**
  78339. * The all dirty flag value
  78340. */
  78341. static readonly AllDirtyFlag: number;
  78342. /**
  78343. * The ID of the material
  78344. */
  78345. id: string;
  78346. /**
  78347. * Gets or sets the unique id of the material
  78348. */
  78349. uniqueId: number;
  78350. /**
  78351. * The name of the material
  78352. */
  78353. name: string;
  78354. /**
  78355. * Gets or sets user defined metadata
  78356. */
  78357. metadata: any;
  78358. /**
  78359. * For internal use only. Please do not use.
  78360. */
  78361. reservedDataStore: any;
  78362. /**
  78363. * Specifies if the ready state should be checked on each call
  78364. */
  78365. checkReadyOnEveryCall: boolean;
  78366. /**
  78367. * Specifies if the ready state should be checked once
  78368. */
  78369. checkReadyOnlyOnce: boolean;
  78370. /**
  78371. * The state of the material
  78372. */
  78373. state: string;
  78374. /**
  78375. * The alpha value of the material
  78376. */
  78377. protected _alpha: number;
  78378. /**
  78379. * Sets the alpha value of the material
  78380. */
  78381. /**
  78382. * Gets the alpha value of the material
  78383. */
  78384. alpha: number;
  78385. /**
  78386. * Specifies if back face culling is enabled
  78387. */
  78388. protected _backFaceCulling: boolean;
  78389. /**
  78390. * Sets the back-face culling state
  78391. */
  78392. /**
  78393. * Gets the back-face culling state
  78394. */
  78395. backFaceCulling: boolean;
  78396. /**
  78397. * Stores the value for side orientation
  78398. */
  78399. sideOrientation: number;
  78400. /**
  78401. * Callback triggered when the material is compiled
  78402. */
  78403. onCompiled: (effect: Effect) => void;
  78404. /**
  78405. * Callback triggered when an error occurs
  78406. */
  78407. onError: (effect: Effect, errors: string) => void;
  78408. /**
  78409. * Callback triggered to get the render target textures
  78410. */
  78411. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  78412. /**
  78413. * Gets a boolean indicating that current material needs to register RTT
  78414. */
  78415. readonly hasRenderTargetTextures: boolean;
  78416. /**
  78417. * Specifies if the material should be serialized
  78418. */
  78419. doNotSerialize: boolean;
  78420. /**
  78421. * @hidden
  78422. */
  78423. _storeEffectOnSubMeshes: boolean;
  78424. /**
  78425. * Stores the animations for the material
  78426. */
  78427. animations: Array<Animation>;
  78428. /**
  78429. * An event triggered when the material is disposed
  78430. */
  78431. onDisposeObservable: Observable<Material>;
  78432. /**
  78433. * An observer which watches for dispose events
  78434. */
  78435. private _onDisposeObserver;
  78436. private _onUnBindObservable;
  78437. /**
  78438. * Called during a dispose event
  78439. */
  78440. onDispose: () => void;
  78441. private _onBindObservable;
  78442. /**
  78443. * An event triggered when the material is bound
  78444. */
  78445. readonly onBindObservable: Observable<AbstractMesh>;
  78446. /**
  78447. * An observer which watches for bind events
  78448. */
  78449. private _onBindObserver;
  78450. /**
  78451. * Called during a bind event
  78452. */
  78453. onBind: (Mesh: AbstractMesh) => void;
  78454. /**
  78455. * An event triggered when the material is unbound
  78456. */
  78457. readonly onUnBindObservable: Observable<Material>;
  78458. /**
  78459. * Stores the value of the alpha mode
  78460. */
  78461. private _alphaMode;
  78462. /**
  78463. * Sets the value of the alpha mode.
  78464. *
  78465. * | Value | Type | Description |
  78466. * | --- | --- | --- |
  78467. * | 0 | ALPHA_DISABLE | |
  78468. * | 1 | ALPHA_ADD | |
  78469. * | 2 | ALPHA_COMBINE | |
  78470. * | 3 | ALPHA_SUBTRACT | |
  78471. * | 4 | ALPHA_MULTIPLY | |
  78472. * | 5 | ALPHA_MAXIMIZED | |
  78473. * | 6 | ALPHA_ONEONE | |
  78474. * | 7 | ALPHA_PREMULTIPLIED | |
  78475. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  78476. * | 9 | ALPHA_INTERPOLATE | |
  78477. * | 10 | ALPHA_SCREENMODE | |
  78478. *
  78479. */
  78480. /**
  78481. * Gets the value of the alpha mode
  78482. */
  78483. alphaMode: number;
  78484. /**
  78485. * Stores the state of the need depth pre-pass value
  78486. */
  78487. private _needDepthPrePass;
  78488. /**
  78489. * Sets the need depth pre-pass value
  78490. */
  78491. /**
  78492. * Gets the depth pre-pass value
  78493. */
  78494. needDepthPrePass: boolean;
  78495. /**
  78496. * Specifies if depth writing should be disabled
  78497. */
  78498. disableDepthWrite: boolean;
  78499. /**
  78500. * Specifies if depth writing should be forced
  78501. */
  78502. forceDepthWrite: boolean;
  78503. /**
  78504. * Specifies if there should be a separate pass for culling
  78505. */
  78506. separateCullingPass: boolean;
  78507. /**
  78508. * Stores the state specifing if fog should be enabled
  78509. */
  78510. private _fogEnabled;
  78511. /**
  78512. * Sets the state for enabling fog
  78513. */
  78514. /**
  78515. * Gets the value of the fog enabled state
  78516. */
  78517. fogEnabled: boolean;
  78518. /**
  78519. * Stores the size of points
  78520. */
  78521. pointSize: number;
  78522. /**
  78523. * Stores the z offset value
  78524. */
  78525. zOffset: number;
  78526. /**
  78527. * Gets a value specifying if wireframe mode is enabled
  78528. */
  78529. /**
  78530. * Sets the state of wireframe mode
  78531. */
  78532. wireframe: boolean;
  78533. /**
  78534. * Gets the value specifying if point clouds are enabled
  78535. */
  78536. /**
  78537. * Sets the state of point cloud mode
  78538. */
  78539. pointsCloud: boolean;
  78540. /**
  78541. * Gets the material fill mode
  78542. */
  78543. /**
  78544. * Sets the material fill mode
  78545. */
  78546. fillMode: number;
  78547. /**
  78548. * @hidden
  78549. * Stores the effects for the material
  78550. */
  78551. _effect: Nullable<Effect>;
  78552. /**
  78553. * @hidden
  78554. * Specifies if the material was previously ready
  78555. */
  78556. _wasPreviouslyReady: boolean;
  78557. /**
  78558. * Specifies if uniform buffers should be used
  78559. */
  78560. private _useUBO;
  78561. /**
  78562. * Stores a reference to the scene
  78563. */
  78564. private _scene;
  78565. /**
  78566. * Stores the fill mode state
  78567. */
  78568. private _fillMode;
  78569. /**
  78570. * Specifies if the depth write state should be cached
  78571. */
  78572. private _cachedDepthWriteState;
  78573. /**
  78574. * Stores the uniform buffer
  78575. */
  78576. protected _uniformBuffer: UniformBuffer;
  78577. /** @hidden */
  78578. _indexInSceneMaterialArray: number;
  78579. /** @hidden */
  78580. meshMap: Nullable<{
  78581. [id: string]: AbstractMesh | undefined;
  78582. }>;
  78583. /**
  78584. * Creates a material instance
  78585. * @param name defines the name of the material
  78586. * @param scene defines the scene to reference
  78587. * @param doNotAdd specifies if the material should be added to the scene
  78588. */
  78589. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  78590. /**
  78591. * Returns a string representation of the current material
  78592. * @param fullDetails defines a boolean indicating which levels of logging is desired
  78593. * @returns a string with material information
  78594. */
  78595. toString(fullDetails?: boolean): string;
  78596. /**
  78597. * Gets the class name of the material
  78598. * @returns a string with the class name of the material
  78599. */
  78600. getClassName(): string;
  78601. /**
  78602. * Specifies if updates for the material been locked
  78603. */
  78604. readonly isFrozen: boolean;
  78605. /**
  78606. * Locks updates for the material
  78607. */
  78608. freeze(): void;
  78609. /**
  78610. * Unlocks updates for the material
  78611. */
  78612. unfreeze(): void;
  78613. /**
  78614. * Specifies if the material is ready to be used
  78615. * @param mesh defines the mesh to check
  78616. * @param useInstances specifies if instances should be used
  78617. * @returns a boolean indicating if the material is ready to be used
  78618. */
  78619. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  78620. /**
  78621. * Specifies that the submesh is ready to be used
  78622. * @param mesh defines the mesh to check
  78623. * @param subMesh defines which submesh to check
  78624. * @param useInstances specifies that instances should be used
  78625. * @returns a boolean indicating that the submesh is ready or not
  78626. */
  78627. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  78628. /**
  78629. * Returns the material effect
  78630. * @returns the effect associated with the material
  78631. */
  78632. getEffect(): Nullable<Effect>;
  78633. /**
  78634. * Returns the current scene
  78635. * @returns a Scene
  78636. */
  78637. getScene(): Scene;
  78638. /**
  78639. * Specifies if the material will require alpha blending
  78640. * @returns a boolean specifying if alpha blending is needed
  78641. */
  78642. needAlphaBlending(): boolean;
  78643. /**
  78644. * Specifies if the mesh will require alpha blending
  78645. * @param mesh defines the mesh to check
  78646. * @returns a boolean specifying if alpha blending is needed for the mesh
  78647. */
  78648. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  78649. /**
  78650. * Specifies if this material should be rendered in alpha test mode
  78651. * @returns a boolean specifying if an alpha test is needed.
  78652. */
  78653. needAlphaTesting(): boolean;
  78654. /**
  78655. * Gets the texture used for the alpha test
  78656. * @returns the texture to use for alpha testing
  78657. */
  78658. getAlphaTestTexture(): Nullable<BaseTexture>;
  78659. /**
  78660. * Marks the material to indicate that it needs to be re-calculated
  78661. */
  78662. markDirty(): void;
  78663. /** @hidden */
  78664. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  78665. /**
  78666. * Binds the material to the mesh
  78667. * @param world defines the world transformation matrix
  78668. * @param mesh defines the mesh to bind the material to
  78669. */
  78670. bind(world: Matrix, mesh?: Mesh): void;
  78671. /**
  78672. * Binds the submesh to the material
  78673. * @param world defines the world transformation matrix
  78674. * @param mesh defines the mesh containing the submesh
  78675. * @param subMesh defines the submesh to bind the material to
  78676. */
  78677. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  78678. /**
  78679. * Binds the world matrix to the material
  78680. * @param world defines the world transformation matrix
  78681. */
  78682. bindOnlyWorldMatrix(world: Matrix): void;
  78683. /**
  78684. * Binds the scene's uniform buffer to the effect.
  78685. * @param effect defines the effect to bind to the scene uniform buffer
  78686. * @param sceneUbo defines the uniform buffer storing scene data
  78687. */
  78688. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  78689. /**
  78690. * Binds the view matrix to the effect
  78691. * @param effect defines the effect to bind the view matrix to
  78692. */
  78693. bindView(effect: Effect): void;
  78694. /**
  78695. * Binds the view projection matrix to the effect
  78696. * @param effect defines the effect to bind the view projection matrix to
  78697. */
  78698. bindViewProjection(effect: Effect): void;
  78699. /**
  78700. * Specifies if material alpha testing should be turned on for the mesh
  78701. * @param mesh defines the mesh to check
  78702. */
  78703. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  78704. /**
  78705. * Processes to execute after binding the material to a mesh
  78706. * @param mesh defines the rendered mesh
  78707. */
  78708. protected _afterBind(mesh?: Mesh): void;
  78709. /**
  78710. * Unbinds the material from the mesh
  78711. */
  78712. unbind(): void;
  78713. /**
  78714. * Gets the active textures from the material
  78715. * @returns an array of textures
  78716. */
  78717. getActiveTextures(): BaseTexture[];
  78718. /**
  78719. * Specifies if the material uses a texture
  78720. * @param texture defines the texture to check against the material
  78721. * @returns a boolean specifying if the material uses the texture
  78722. */
  78723. hasTexture(texture: BaseTexture): boolean;
  78724. /**
  78725. * Makes a duplicate of the material, and gives it a new name
  78726. * @param name defines the new name for the duplicated material
  78727. * @returns the cloned material
  78728. */
  78729. clone(name: string): Nullable<Material>;
  78730. /**
  78731. * Gets the meshes bound to the material
  78732. * @returns an array of meshes bound to the material
  78733. */
  78734. getBindedMeshes(): AbstractMesh[];
  78735. /**
  78736. * Force shader compilation
  78737. * @param mesh defines the mesh associated with this material
  78738. * @param onCompiled defines a function to execute once the material is compiled
  78739. * @param options defines the options to configure the compilation
  78740. */
  78741. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  78742. clipPlane: boolean;
  78743. }>): void;
  78744. /**
  78745. * Force shader compilation
  78746. * @param mesh defines the mesh that will use this material
  78747. * @param options defines additional options for compiling the shaders
  78748. * @returns a promise that resolves when the compilation completes
  78749. */
  78750. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  78751. clipPlane: boolean;
  78752. }>): Promise<void>;
  78753. private static readonly _ImageProcessingDirtyCallBack;
  78754. private static readonly _TextureDirtyCallBack;
  78755. private static readonly _FresnelDirtyCallBack;
  78756. private static readonly _MiscDirtyCallBack;
  78757. private static readonly _LightsDirtyCallBack;
  78758. private static readonly _AttributeDirtyCallBack;
  78759. private static _FresnelAndMiscDirtyCallBack;
  78760. private static _TextureAndMiscDirtyCallBack;
  78761. private static readonly _DirtyCallbackArray;
  78762. private static readonly _RunDirtyCallBacks;
  78763. /**
  78764. * Marks a define in the material to indicate that it needs to be re-computed
  78765. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  78766. */
  78767. markAsDirty(flag: number): void;
  78768. /**
  78769. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  78770. * @param func defines a function which checks material defines against the submeshes
  78771. */
  78772. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  78773. /**
  78774. * Indicates that image processing needs to be re-calculated for all submeshes
  78775. */
  78776. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  78777. /**
  78778. * Indicates that textures need to be re-calculated for all submeshes
  78779. */
  78780. protected _markAllSubMeshesAsTexturesDirty(): void;
  78781. /**
  78782. * Indicates that fresnel needs to be re-calculated for all submeshes
  78783. */
  78784. protected _markAllSubMeshesAsFresnelDirty(): void;
  78785. /**
  78786. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  78787. */
  78788. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  78789. /**
  78790. * Indicates that lights need to be re-calculated for all submeshes
  78791. */
  78792. protected _markAllSubMeshesAsLightsDirty(): void;
  78793. /**
  78794. * Indicates that attributes need to be re-calculated for all submeshes
  78795. */
  78796. protected _markAllSubMeshesAsAttributesDirty(): void;
  78797. /**
  78798. * Indicates that misc needs to be re-calculated for all submeshes
  78799. */
  78800. protected _markAllSubMeshesAsMiscDirty(): void;
  78801. /**
  78802. * Indicates that textures and misc need to be re-calculated for all submeshes
  78803. */
  78804. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  78805. /**
  78806. * Disposes the material
  78807. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  78808. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  78809. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  78810. */
  78811. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  78812. /** @hidden */
  78813. private releaseVertexArrayObject;
  78814. /**
  78815. * Serializes this material
  78816. * @returns the serialized material object
  78817. */
  78818. serialize(): any;
  78819. /**
  78820. * Creates a material from parsed material data
  78821. * @param parsedMaterial defines parsed material data
  78822. * @param scene defines the hosting scene
  78823. * @param rootUrl defines the root URL to use to load textures
  78824. * @returns a new material
  78825. */
  78826. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  78827. }
  78828. }
  78829. declare module BABYLON {
  78830. /**
  78831. * Base class for submeshes
  78832. */
  78833. export class BaseSubMesh {
  78834. /** @hidden */
  78835. _materialDefines: Nullable<MaterialDefines>;
  78836. /** @hidden */
  78837. _materialEffect: Nullable<Effect>;
  78838. /**
  78839. * Gets associated effect
  78840. */
  78841. readonly effect: Nullable<Effect>;
  78842. /**
  78843. * Sets associated effect (effect used to render this submesh)
  78844. * @param effect defines the effect to associate with
  78845. * @param defines defines the set of defines used to compile this effect
  78846. */
  78847. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  78848. }
  78849. /**
  78850. * Defines a subdivision inside a mesh
  78851. */
  78852. export class SubMesh extends BaseSubMesh implements ICullable {
  78853. /** the material index to use */
  78854. materialIndex: number;
  78855. /** vertex index start */
  78856. verticesStart: number;
  78857. /** vertices count */
  78858. verticesCount: number;
  78859. /** index start */
  78860. indexStart: number;
  78861. /** indices count */
  78862. indexCount: number;
  78863. /** @hidden */
  78864. _linesIndexCount: number;
  78865. private _mesh;
  78866. private _renderingMesh;
  78867. private _boundingInfo;
  78868. private _linesIndexBuffer;
  78869. /** @hidden */
  78870. _lastColliderWorldVertices: Nullable<Vector3[]>;
  78871. /** @hidden */
  78872. _trianglePlanes: Plane[];
  78873. /** @hidden */
  78874. _lastColliderTransformMatrix: Matrix;
  78875. /** @hidden */
  78876. _renderId: number;
  78877. /** @hidden */
  78878. _alphaIndex: number;
  78879. /** @hidden */
  78880. _distanceToCamera: number;
  78881. /** @hidden */
  78882. _id: number;
  78883. private _currentMaterial;
  78884. /**
  78885. * Add a new submesh to a mesh
  78886. * @param materialIndex defines the material index to use
  78887. * @param verticesStart defines vertex index start
  78888. * @param verticesCount defines vertices count
  78889. * @param indexStart defines index start
  78890. * @param indexCount defines indices count
  78891. * @param mesh defines the parent mesh
  78892. * @param renderingMesh defines an optional rendering mesh
  78893. * @param createBoundingBox defines if bounding box should be created for this submesh
  78894. * @returns the new submesh
  78895. */
  78896. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  78897. /**
  78898. * Creates a new submesh
  78899. * @param materialIndex defines the material index to use
  78900. * @param verticesStart defines vertex index start
  78901. * @param verticesCount defines vertices count
  78902. * @param indexStart defines index start
  78903. * @param indexCount defines indices count
  78904. * @param mesh defines the parent mesh
  78905. * @param renderingMesh defines an optional rendering mesh
  78906. * @param createBoundingBox defines if bounding box should be created for this submesh
  78907. */
  78908. constructor(
  78909. /** the material index to use */
  78910. materialIndex: number,
  78911. /** vertex index start */
  78912. verticesStart: number,
  78913. /** vertices count */
  78914. verticesCount: number,
  78915. /** index start */
  78916. indexStart: number,
  78917. /** indices count */
  78918. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  78919. /**
  78920. * Returns true if this submesh covers the entire parent mesh
  78921. * @ignorenaming
  78922. */
  78923. readonly IsGlobal: boolean;
  78924. /**
  78925. * Returns the submesh BoudingInfo object
  78926. * @returns current bounding info (or mesh's one if the submesh is global)
  78927. */
  78928. getBoundingInfo(): BoundingInfo;
  78929. /**
  78930. * Sets the submesh BoundingInfo
  78931. * @param boundingInfo defines the new bounding info to use
  78932. * @returns the SubMesh
  78933. */
  78934. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  78935. /**
  78936. * Returns the mesh of the current submesh
  78937. * @return the parent mesh
  78938. */
  78939. getMesh(): AbstractMesh;
  78940. /**
  78941. * Returns the rendering mesh of the submesh
  78942. * @returns the rendering mesh (could be different from parent mesh)
  78943. */
  78944. getRenderingMesh(): Mesh;
  78945. /**
  78946. * Returns the submesh material
  78947. * @returns null or the current material
  78948. */
  78949. getMaterial(): Nullable<Material>;
  78950. /**
  78951. * Sets a new updated BoundingInfo object to the submesh
  78952. * @returns the SubMesh
  78953. */
  78954. refreshBoundingInfo(): SubMesh;
  78955. /** @hidden */
  78956. _checkCollision(collider: Collider): boolean;
  78957. /**
  78958. * Updates the submesh BoundingInfo
  78959. * @param world defines the world matrix to use to update the bounding info
  78960. * @returns the submesh
  78961. */
  78962. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  78963. /**
  78964. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  78965. * @param frustumPlanes defines the frustum planes
  78966. * @returns true if the submesh is intersecting with the frustum
  78967. */
  78968. isInFrustum(frustumPlanes: Plane[]): boolean;
  78969. /**
  78970. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  78971. * @param frustumPlanes defines the frustum planes
  78972. * @returns true if the submesh is inside the frustum
  78973. */
  78974. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  78975. /**
  78976. * Renders the submesh
  78977. * @param enableAlphaMode defines if alpha needs to be used
  78978. * @returns the submesh
  78979. */
  78980. render(enableAlphaMode: boolean): SubMesh;
  78981. /**
  78982. * @hidden
  78983. */
  78984. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  78985. /**
  78986. * Checks if the submesh intersects with a ray
  78987. * @param ray defines the ray to test
  78988. * @returns true is the passed ray intersects the submesh bounding box
  78989. */
  78990. canIntersects(ray: Ray): boolean;
  78991. /**
  78992. * Intersects current submesh with a ray
  78993. * @param ray defines the ray to test
  78994. * @param positions defines mesh's positions array
  78995. * @param indices defines mesh's indices array
  78996. * @param fastCheck defines if only bounding info should be used
  78997. * @returns intersection info or null if no intersection
  78998. */
  78999. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  79000. /** @hidden */
  79001. private _intersectLines;
  79002. /** @hidden */
  79003. private _intersectTriangles;
  79004. /** @hidden */
  79005. _rebuild(): void;
  79006. /**
  79007. * Creates a new submesh from the passed mesh
  79008. * @param newMesh defines the new hosting mesh
  79009. * @param newRenderingMesh defines an optional rendering mesh
  79010. * @returns the new submesh
  79011. */
  79012. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  79013. /**
  79014. * Release associated resources
  79015. */
  79016. dispose(): void;
  79017. /**
  79018. * Gets the class name
  79019. * @returns the string "SubMesh".
  79020. */
  79021. getClassName(): string;
  79022. /**
  79023. * Creates a new submesh from indices data
  79024. * @param materialIndex the index of the main mesh material
  79025. * @param startIndex the index where to start the copy in the mesh indices array
  79026. * @param indexCount the number of indices to copy then from the startIndex
  79027. * @param mesh the main mesh to create the submesh from
  79028. * @param renderingMesh the optional rendering mesh
  79029. * @returns a new submesh
  79030. */
  79031. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  79032. }
  79033. }
  79034. declare module BABYLON {
  79035. /**
  79036. * Class used to store geometry data (vertex buffers + index buffer)
  79037. */
  79038. export class Geometry implements IGetSetVerticesData {
  79039. /**
  79040. * Gets or sets the ID of the geometry
  79041. */
  79042. id: string;
  79043. /**
  79044. * Gets or sets the unique ID of the geometry
  79045. */
  79046. uniqueId: number;
  79047. /**
  79048. * Gets the delay loading state of the geometry (none by default which means not delayed)
  79049. */
  79050. delayLoadState: number;
  79051. /**
  79052. * Gets the file containing the data to load when running in delay load state
  79053. */
  79054. delayLoadingFile: Nullable<string>;
  79055. /**
  79056. * Callback called when the geometry is updated
  79057. */
  79058. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  79059. private _scene;
  79060. private _engine;
  79061. private _meshes;
  79062. private _totalVertices;
  79063. /** @hidden */
  79064. _indices: IndicesArray;
  79065. /** @hidden */
  79066. _vertexBuffers: {
  79067. [key: string]: VertexBuffer;
  79068. };
  79069. private _isDisposed;
  79070. private _extend;
  79071. private _boundingBias;
  79072. /** @hidden */
  79073. _delayInfo: Array<string>;
  79074. private _indexBuffer;
  79075. private _indexBufferIsUpdatable;
  79076. /** @hidden */
  79077. _boundingInfo: Nullable<BoundingInfo>;
  79078. /** @hidden */
  79079. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  79080. /** @hidden */
  79081. _softwareSkinningFrameId: number;
  79082. private _vertexArrayObjects;
  79083. private _updatable;
  79084. /** @hidden */
  79085. _positions: Nullable<Vector3[]>;
  79086. /**
  79087. * 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
  79088. */
  79089. /**
  79090. * 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
  79091. */
  79092. boundingBias: Vector2;
  79093. /**
  79094. * Static function used to attach a new empty geometry to a mesh
  79095. * @param mesh defines the mesh to attach the geometry to
  79096. * @returns the new Geometry
  79097. */
  79098. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  79099. /**
  79100. * Creates a new geometry
  79101. * @param id defines the unique ID
  79102. * @param scene defines the hosting scene
  79103. * @param vertexData defines the VertexData used to get geometry data
  79104. * @param updatable defines if geometry must be updatable (false by default)
  79105. * @param mesh defines the mesh that will be associated with the geometry
  79106. */
  79107. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  79108. /**
  79109. * Gets the current extend of the geometry
  79110. */
  79111. readonly extend: {
  79112. minimum: Vector3;
  79113. maximum: Vector3;
  79114. };
  79115. /**
  79116. * Gets the hosting scene
  79117. * @returns the hosting Scene
  79118. */
  79119. getScene(): Scene;
  79120. /**
  79121. * Gets the hosting engine
  79122. * @returns the hosting Engine
  79123. */
  79124. getEngine(): Engine;
  79125. /**
  79126. * Defines if the geometry is ready to use
  79127. * @returns true if the geometry is ready to be used
  79128. */
  79129. isReady(): boolean;
  79130. /**
  79131. * Gets a value indicating that the geometry should not be serialized
  79132. */
  79133. readonly doNotSerialize: boolean;
  79134. /** @hidden */
  79135. _rebuild(): void;
  79136. /**
  79137. * Affects all geometry data in one call
  79138. * @param vertexData defines the geometry data
  79139. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  79140. */
  79141. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  79142. /**
  79143. * Set specific vertex data
  79144. * @param kind defines the data kind (Position, normal, etc...)
  79145. * @param data defines the vertex data to use
  79146. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79147. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79148. */
  79149. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  79150. /**
  79151. * Removes a specific vertex data
  79152. * @param kind defines the data kind (Position, normal, etc...)
  79153. */
  79154. removeVerticesData(kind: string): void;
  79155. /**
  79156. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  79157. * @param buffer defines the vertex buffer to use
  79158. * @param totalVertices defines the total number of vertices for position kind (could be null)
  79159. */
  79160. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  79161. /**
  79162. * Update a specific vertex buffer
  79163. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  79164. * It will do nothing if the buffer is not updatable
  79165. * @param kind defines the data kind (Position, normal, etc...)
  79166. * @param data defines the data to use
  79167. * @param offset defines the offset in the target buffer where to store the data
  79168. * @param useBytes set to true if the offset is in bytes
  79169. */
  79170. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  79171. /**
  79172. * Update a specific vertex buffer
  79173. * This function will create a new buffer if the current one is not updatable
  79174. * @param kind defines the data kind (Position, normal, etc...)
  79175. * @param data defines the data to use
  79176. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  79177. */
  79178. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  79179. private _updateBoundingInfo;
  79180. /** @hidden */
  79181. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  79182. /**
  79183. * Gets total number of vertices
  79184. * @returns the total number of vertices
  79185. */
  79186. getTotalVertices(): number;
  79187. /**
  79188. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79189. * @param kind defines the data kind (Position, normal, etc...)
  79190. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79191. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79192. * @returns a float array containing vertex data
  79193. */
  79194. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79195. /**
  79196. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  79197. * @param kind defines the data kind (Position, normal, etc...)
  79198. * @returns true if the vertex buffer with the specified kind is updatable
  79199. */
  79200. isVertexBufferUpdatable(kind: string): boolean;
  79201. /**
  79202. * Gets a specific vertex buffer
  79203. * @param kind defines the data kind (Position, normal, etc...)
  79204. * @returns a VertexBuffer
  79205. */
  79206. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79207. /**
  79208. * Returns all vertex buffers
  79209. * @return an object holding all vertex buffers indexed by kind
  79210. */
  79211. getVertexBuffers(): Nullable<{
  79212. [key: string]: VertexBuffer;
  79213. }>;
  79214. /**
  79215. * Gets a boolean indicating if specific vertex buffer is present
  79216. * @param kind defines the data kind (Position, normal, etc...)
  79217. * @returns true if data is present
  79218. */
  79219. isVerticesDataPresent(kind: string): boolean;
  79220. /**
  79221. * Gets a list of all attached data kinds (Position, normal, etc...)
  79222. * @returns a list of string containing all kinds
  79223. */
  79224. getVerticesDataKinds(): string[];
  79225. /**
  79226. * Update index buffer
  79227. * @param indices defines the indices to store in the index buffer
  79228. * @param offset defines the offset in the target buffer where to store the data
  79229. */
  79230. updateIndices(indices: IndicesArray, offset?: number): void;
  79231. /**
  79232. * Creates a new index buffer
  79233. * @param indices defines the indices to store in the index buffer
  79234. * @param totalVertices defines the total number of vertices (could be null)
  79235. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79236. */
  79237. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  79238. /**
  79239. * Return the total number of indices
  79240. * @returns the total number of indices
  79241. */
  79242. getTotalIndices(): number;
  79243. /**
  79244. * Gets the index buffer array
  79245. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79246. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79247. * @returns the index buffer array
  79248. */
  79249. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79250. /**
  79251. * Gets the index buffer
  79252. * @return the index buffer
  79253. */
  79254. getIndexBuffer(): Nullable<WebGLBuffer>;
  79255. /** @hidden */
  79256. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  79257. /**
  79258. * Release the associated resources for a specific mesh
  79259. * @param mesh defines the source mesh
  79260. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  79261. */
  79262. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  79263. /**
  79264. * Apply current geometry to a given mesh
  79265. * @param mesh defines the mesh to apply geometry to
  79266. */
  79267. applyToMesh(mesh: Mesh): void;
  79268. private _updateExtend;
  79269. private _applyToMesh;
  79270. private notifyUpdate;
  79271. /**
  79272. * Load the geometry if it was flagged as delay loaded
  79273. * @param scene defines the hosting scene
  79274. * @param onLoaded defines a callback called when the geometry is loaded
  79275. */
  79276. load(scene: Scene, onLoaded?: () => void): void;
  79277. private _queueLoad;
  79278. /**
  79279. * Invert the geometry to move from a right handed system to a left handed one.
  79280. */
  79281. toLeftHanded(): void;
  79282. /** @hidden */
  79283. _resetPointsArrayCache(): void;
  79284. /** @hidden */
  79285. _generatePointsArray(): boolean;
  79286. /**
  79287. * Gets a value indicating if the geometry is disposed
  79288. * @returns true if the geometry was disposed
  79289. */
  79290. isDisposed(): boolean;
  79291. private _disposeVertexArrayObjects;
  79292. /**
  79293. * Free all associated resources
  79294. */
  79295. dispose(): void;
  79296. /**
  79297. * Clone the current geometry into a new geometry
  79298. * @param id defines the unique ID of the new geometry
  79299. * @returns a new geometry object
  79300. */
  79301. copy(id: string): Geometry;
  79302. /**
  79303. * Serialize the current geometry info (and not the vertices data) into a JSON object
  79304. * @return a JSON representation of the current geometry data (without the vertices data)
  79305. */
  79306. serialize(): any;
  79307. private toNumberArray;
  79308. /**
  79309. * Serialize all vertices data into a JSON oject
  79310. * @returns a JSON representation of the current geometry data
  79311. */
  79312. serializeVerticeData(): any;
  79313. /**
  79314. * Extracts a clone of a mesh geometry
  79315. * @param mesh defines the source mesh
  79316. * @param id defines the unique ID of the new geometry object
  79317. * @returns the new geometry object
  79318. */
  79319. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  79320. /**
  79321. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  79322. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  79323. * Be aware Math.random() could cause collisions, but:
  79324. * "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"
  79325. * @returns a string containing a new GUID
  79326. */
  79327. static RandomId(): string;
  79328. /** @hidden */
  79329. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  79330. private static _CleanMatricesWeights;
  79331. /**
  79332. * Create a new geometry from persisted data (Using .babylon file format)
  79333. * @param parsedVertexData defines the persisted data
  79334. * @param scene defines the hosting scene
  79335. * @param rootUrl defines the root url to use to load assets (like delayed data)
  79336. * @returns the new geometry object
  79337. */
  79338. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  79339. }
  79340. }
  79341. declare module BABYLON {
  79342. /**
  79343. * Define an interface for all classes that will get and set the data on vertices
  79344. */
  79345. export interface IGetSetVerticesData {
  79346. /**
  79347. * Gets a boolean indicating if specific vertex data is present
  79348. * @param kind defines the vertex data kind to use
  79349. * @returns true is data kind is present
  79350. */
  79351. isVerticesDataPresent(kind: string): boolean;
  79352. /**
  79353. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79354. * @param kind defines the data kind (Position, normal, etc...)
  79355. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79356. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79357. * @returns a float array containing vertex data
  79358. */
  79359. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79360. /**
  79361. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79362. * @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.
  79363. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79364. * @returns the indices array or an empty array if the mesh has no geometry
  79365. */
  79366. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79367. /**
  79368. * Set specific vertex data
  79369. * @param kind defines the data kind (Position, normal, etc...)
  79370. * @param data defines the vertex data to use
  79371. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79372. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79373. */
  79374. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  79375. /**
  79376. * Update a specific associated vertex buffer
  79377. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79378. * - VertexBuffer.PositionKind
  79379. * - VertexBuffer.UVKind
  79380. * - VertexBuffer.UV2Kind
  79381. * - VertexBuffer.UV3Kind
  79382. * - VertexBuffer.UV4Kind
  79383. * - VertexBuffer.UV5Kind
  79384. * - VertexBuffer.UV6Kind
  79385. * - VertexBuffer.ColorKind
  79386. * - VertexBuffer.MatricesIndicesKind
  79387. * - VertexBuffer.MatricesIndicesExtraKind
  79388. * - VertexBuffer.MatricesWeightsKind
  79389. * - VertexBuffer.MatricesWeightsExtraKind
  79390. * @param data defines the data source
  79391. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79392. * @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)
  79393. */
  79394. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  79395. /**
  79396. * Creates a new index buffer
  79397. * @param indices defines the indices to store in the index buffer
  79398. * @param totalVertices defines the total number of vertices (could be null)
  79399. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79400. */
  79401. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  79402. }
  79403. /**
  79404. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  79405. */
  79406. export class VertexData {
  79407. /**
  79408. * Mesh side orientation : usually the external or front surface
  79409. */
  79410. static readonly FRONTSIDE: number;
  79411. /**
  79412. * Mesh side orientation : usually the internal or back surface
  79413. */
  79414. static readonly BACKSIDE: number;
  79415. /**
  79416. * Mesh side orientation : both internal and external or front and back surfaces
  79417. */
  79418. static readonly DOUBLESIDE: number;
  79419. /**
  79420. * Mesh side orientation : by default, `FRONTSIDE`
  79421. */
  79422. static readonly DEFAULTSIDE: number;
  79423. /**
  79424. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  79425. */
  79426. positions: Nullable<FloatArray>;
  79427. /**
  79428. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  79429. */
  79430. normals: Nullable<FloatArray>;
  79431. /**
  79432. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  79433. */
  79434. tangents: Nullable<FloatArray>;
  79435. /**
  79436. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79437. */
  79438. uvs: Nullable<FloatArray>;
  79439. /**
  79440. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79441. */
  79442. uvs2: Nullable<FloatArray>;
  79443. /**
  79444. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79445. */
  79446. uvs3: Nullable<FloatArray>;
  79447. /**
  79448. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79449. */
  79450. uvs4: Nullable<FloatArray>;
  79451. /**
  79452. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79453. */
  79454. uvs5: Nullable<FloatArray>;
  79455. /**
  79456. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79457. */
  79458. uvs6: Nullable<FloatArray>;
  79459. /**
  79460. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  79461. */
  79462. colors: Nullable<FloatArray>;
  79463. /**
  79464. * 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).
  79465. */
  79466. matricesIndices: Nullable<FloatArray>;
  79467. /**
  79468. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  79469. */
  79470. matricesWeights: Nullable<FloatArray>;
  79471. /**
  79472. * An array extending the number of possible indices
  79473. */
  79474. matricesIndicesExtra: Nullable<FloatArray>;
  79475. /**
  79476. * An array extending the number of possible weights when the number of indices is extended
  79477. */
  79478. matricesWeightsExtra: Nullable<FloatArray>;
  79479. /**
  79480. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  79481. */
  79482. indices: Nullable<IndicesArray>;
  79483. /**
  79484. * Uses the passed data array to set the set the values for the specified kind of data
  79485. * @param data a linear array of floating numbers
  79486. * @param kind the type of data that is being set, eg positions, colors etc
  79487. */
  79488. set(data: FloatArray, kind: string): void;
  79489. /**
  79490. * Associates the vertexData to the passed Mesh.
  79491. * Sets it as updatable or not (default `false`)
  79492. * @param mesh the mesh the vertexData is applied to
  79493. * @param updatable when used and having the value true allows new data to update the vertexData
  79494. * @returns the VertexData
  79495. */
  79496. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  79497. /**
  79498. * Associates the vertexData to the passed Geometry.
  79499. * Sets it as updatable or not (default `false`)
  79500. * @param geometry the geometry the vertexData is applied to
  79501. * @param updatable when used and having the value true allows new data to update the vertexData
  79502. * @returns VertexData
  79503. */
  79504. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  79505. /**
  79506. * Updates the associated mesh
  79507. * @param mesh the mesh to be updated
  79508. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79509. * @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
  79510. * @returns VertexData
  79511. */
  79512. updateMesh(mesh: Mesh): VertexData;
  79513. /**
  79514. * Updates the associated geometry
  79515. * @param geometry the geometry to be updated
  79516. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79517. * @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
  79518. * @returns VertexData.
  79519. */
  79520. updateGeometry(geometry: Geometry): VertexData;
  79521. private _applyTo;
  79522. private _update;
  79523. /**
  79524. * Transforms each position and each normal of the vertexData according to the passed Matrix
  79525. * @param matrix the transforming matrix
  79526. * @returns the VertexData
  79527. */
  79528. transform(matrix: Matrix): VertexData;
  79529. /**
  79530. * Merges the passed VertexData into the current one
  79531. * @param other the VertexData to be merged into the current one
  79532. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  79533. * @returns the modified VertexData
  79534. */
  79535. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  79536. private _mergeElement;
  79537. private _validate;
  79538. /**
  79539. * Serializes the VertexData
  79540. * @returns a serialized object
  79541. */
  79542. serialize(): any;
  79543. /**
  79544. * Extracts the vertexData from a mesh
  79545. * @param mesh the mesh from which to extract the VertexData
  79546. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  79547. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79548. * @returns the object VertexData associated to the passed mesh
  79549. */
  79550. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79551. /**
  79552. * Extracts the vertexData from the geometry
  79553. * @param geometry the geometry from which to extract the VertexData
  79554. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  79555. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79556. * @returns the object VertexData associated to the passed mesh
  79557. */
  79558. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79559. private static _ExtractFrom;
  79560. /**
  79561. * Creates the VertexData for a Ribbon
  79562. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  79563. * * pathArray array of paths, each of which an array of successive Vector3
  79564. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  79565. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  79566. * * 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
  79567. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79568. * * 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)
  79569. * * 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)
  79570. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  79571. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  79572. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  79573. * @returns the VertexData of the ribbon
  79574. */
  79575. static CreateRibbon(options: {
  79576. pathArray: Vector3[][];
  79577. closeArray?: boolean;
  79578. closePath?: boolean;
  79579. offset?: number;
  79580. sideOrientation?: number;
  79581. frontUVs?: Vector4;
  79582. backUVs?: Vector4;
  79583. invertUV?: boolean;
  79584. uvs?: Vector2[];
  79585. colors?: Color4[];
  79586. }): VertexData;
  79587. /**
  79588. * Creates the VertexData for a box
  79589. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79590. * * size sets the width, height and depth of the box to the value of size, optional default 1
  79591. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  79592. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  79593. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  79594. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  79595. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  79596. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79597. * * 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)
  79598. * * 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)
  79599. * @returns the VertexData of the box
  79600. */
  79601. static CreateBox(options: {
  79602. size?: number;
  79603. width?: number;
  79604. height?: number;
  79605. depth?: number;
  79606. faceUV?: Vector4[];
  79607. faceColors?: Color4[];
  79608. sideOrientation?: number;
  79609. frontUVs?: Vector4;
  79610. backUVs?: Vector4;
  79611. }): VertexData;
  79612. /**
  79613. * Creates the VertexData for an ellipsoid, defaults to a sphere
  79614. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79615. * * segments sets the number of horizontal strips optional, default 32
  79616. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  79617. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  79618. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  79619. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  79620. * * 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
  79621. * * 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
  79622. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79623. * * 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)
  79624. * * 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)
  79625. * @returns the VertexData of the ellipsoid
  79626. */
  79627. static CreateSphere(options: {
  79628. segments?: number;
  79629. diameter?: number;
  79630. diameterX?: number;
  79631. diameterY?: number;
  79632. diameterZ?: number;
  79633. arc?: number;
  79634. slice?: number;
  79635. sideOrientation?: number;
  79636. frontUVs?: Vector4;
  79637. backUVs?: Vector4;
  79638. }): VertexData;
  79639. /**
  79640. * Creates the VertexData for a cylinder, cone or prism
  79641. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79642. * * height sets the height (y direction) of the cylinder, optional, default 2
  79643. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  79644. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  79645. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  79646. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79647. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  79648. * * 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
  79649. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79650. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79651. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  79652. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  79653. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79654. * * 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)
  79655. * * 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)
  79656. * @returns the VertexData of the cylinder, cone or prism
  79657. */
  79658. static CreateCylinder(options: {
  79659. height?: number;
  79660. diameterTop?: number;
  79661. diameterBottom?: number;
  79662. diameter?: number;
  79663. tessellation?: number;
  79664. subdivisions?: number;
  79665. arc?: number;
  79666. faceColors?: Color4[];
  79667. faceUV?: Vector4[];
  79668. hasRings?: boolean;
  79669. enclose?: boolean;
  79670. sideOrientation?: number;
  79671. frontUVs?: Vector4;
  79672. backUVs?: Vector4;
  79673. }): VertexData;
  79674. /**
  79675. * Creates the VertexData for a torus
  79676. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79677. * * diameter the diameter of the torus, optional default 1
  79678. * * thickness the diameter of the tube forming the torus, optional default 0.5
  79679. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79680. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79681. * * 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)
  79682. * * 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)
  79683. * @returns the VertexData of the torus
  79684. */
  79685. static CreateTorus(options: {
  79686. diameter?: number;
  79687. thickness?: number;
  79688. tessellation?: number;
  79689. sideOrientation?: number;
  79690. frontUVs?: Vector4;
  79691. backUVs?: Vector4;
  79692. }): VertexData;
  79693. /**
  79694. * Creates the VertexData of the LineSystem
  79695. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  79696. * - lines an array of lines, each line being an array of successive Vector3
  79697. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  79698. * @returns the VertexData of the LineSystem
  79699. */
  79700. static CreateLineSystem(options: {
  79701. lines: Vector3[][];
  79702. colors?: Nullable<Color4[][]>;
  79703. }): VertexData;
  79704. /**
  79705. * Create the VertexData for a DashedLines
  79706. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  79707. * - points an array successive Vector3
  79708. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  79709. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  79710. * - dashNb the intended total number of dashes, optional, default 200
  79711. * @returns the VertexData for the DashedLines
  79712. */
  79713. static CreateDashedLines(options: {
  79714. points: Vector3[];
  79715. dashSize?: number;
  79716. gapSize?: number;
  79717. dashNb?: number;
  79718. }): VertexData;
  79719. /**
  79720. * Creates the VertexData for a Ground
  79721. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  79722. * - width the width (x direction) of the ground, optional, default 1
  79723. * - height the height (z direction) of the ground, optional, default 1
  79724. * - subdivisions the number of subdivisions per side, optional, default 1
  79725. * @returns the VertexData of the Ground
  79726. */
  79727. static CreateGround(options: {
  79728. width?: number;
  79729. height?: number;
  79730. subdivisions?: number;
  79731. subdivisionsX?: number;
  79732. subdivisionsY?: number;
  79733. }): VertexData;
  79734. /**
  79735. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  79736. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  79737. * * xmin the ground minimum X coordinate, optional, default -1
  79738. * * zmin the ground minimum Z coordinate, optional, default -1
  79739. * * xmax the ground maximum X coordinate, optional, default 1
  79740. * * zmax the ground maximum Z coordinate, optional, default 1
  79741. * * 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}
  79742. * * 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}
  79743. * @returns the VertexData of the TiledGround
  79744. */
  79745. static CreateTiledGround(options: {
  79746. xmin: number;
  79747. zmin: number;
  79748. xmax: number;
  79749. zmax: number;
  79750. subdivisions?: {
  79751. w: number;
  79752. h: number;
  79753. };
  79754. precision?: {
  79755. w: number;
  79756. h: number;
  79757. };
  79758. }): VertexData;
  79759. /**
  79760. * Creates the VertexData of the Ground designed from a heightmap
  79761. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  79762. * * width the width (x direction) of the ground
  79763. * * height the height (z direction) of the ground
  79764. * * subdivisions the number of subdivisions per side
  79765. * * minHeight the minimum altitude on the ground, optional, default 0
  79766. * * maxHeight the maximum altitude on the ground, optional default 1
  79767. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  79768. * * buffer the array holding the image color data
  79769. * * bufferWidth the width of image
  79770. * * bufferHeight the height of image
  79771. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  79772. * @returns the VertexData of the Ground designed from a heightmap
  79773. */
  79774. static CreateGroundFromHeightMap(options: {
  79775. width: number;
  79776. height: number;
  79777. subdivisions: number;
  79778. minHeight: number;
  79779. maxHeight: number;
  79780. colorFilter: Color3;
  79781. buffer: Uint8Array;
  79782. bufferWidth: number;
  79783. bufferHeight: number;
  79784. alphaFilter: number;
  79785. }): VertexData;
  79786. /**
  79787. * Creates the VertexData for a Plane
  79788. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  79789. * * size sets the width and height of the plane to the value of size, optional default 1
  79790. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  79791. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  79792. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79793. * * 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)
  79794. * * 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)
  79795. * @returns the VertexData of the box
  79796. */
  79797. static CreatePlane(options: {
  79798. size?: number;
  79799. width?: number;
  79800. height?: number;
  79801. sideOrientation?: number;
  79802. frontUVs?: Vector4;
  79803. backUVs?: Vector4;
  79804. }): VertexData;
  79805. /**
  79806. * Creates the VertexData of the Disc or regular Polygon
  79807. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  79808. * * radius the radius of the disc, optional default 0.5
  79809. * * tessellation the number of polygon sides, optional, default 64
  79810. * * 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
  79811. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79812. * * 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)
  79813. * * 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)
  79814. * @returns the VertexData of the box
  79815. */
  79816. static CreateDisc(options: {
  79817. radius?: number;
  79818. tessellation?: number;
  79819. arc?: number;
  79820. sideOrientation?: number;
  79821. frontUVs?: Vector4;
  79822. backUVs?: Vector4;
  79823. }): VertexData;
  79824. /**
  79825. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  79826. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  79827. * @param polygon a mesh built from polygonTriangulation.build()
  79828. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79829. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79830. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79831. * @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)
  79832. * @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)
  79833. * @returns the VertexData of the Polygon
  79834. */
  79835. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  79836. /**
  79837. * Creates the VertexData of the IcoSphere
  79838. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  79839. * * radius the radius of the IcoSphere, optional default 1
  79840. * * radiusX allows stretching in the x direction, optional, default radius
  79841. * * radiusY allows stretching in the y direction, optional, default radius
  79842. * * radiusZ allows stretching in the z direction, optional, default radius
  79843. * * flat when true creates a flat shaded mesh, optional, default true
  79844. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  79845. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79846. * * 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)
  79847. * * 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)
  79848. * @returns the VertexData of the IcoSphere
  79849. */
  79850. static CreateIcoSphere(options: {
  79851. radius?: number;
  79852. radiusX?: number;
  79853. radiusY?: number;
  79854. radiusZ?: number;
  79855. flat?: boolean;
  79856. subdivisions?: number;
  79857. sideOrientation?: number;
  79858. frontUVs?: Vector4;
  79859. backUVs?: Vector4;
  79860. }): VertexData;
  79861. /**
  79862. * Creates the VertexData for a Polyhedron
  79863. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  79864. * * type provided types are:
  79865. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  79866. * * 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)
  79867. * * size the size of the IcoSphere, optional default 1
  79868. * * sizeX allows stretching in the x direction, optional, default size
  79869. * * sizeY allows stretching in the y direction, optional, default size
  79870. * * sizeZ allows stretching in the z direction, optional, default size
  79871. * * 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
  79872. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79873. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79874. * * flat when true creates a flat shaded mesh, optional, default true
  79875. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  79876. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79877. * * 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)
  79878. * * 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)
  79879. * @returns the VertexData of the Polyhedron
  79880. */
  79881. static CreatePolyhedron(options: {
  79882. type?: number;
  79883. size?: number;
  79884. sizeX?: number;
  79885. sizeY?: number;
  79886. sizeZ?: number;
  79887. custom?: any;
  79888. faceUV?: Vector4[];
  79889. faceColors?: Color4[];
  79890. flat?: boolean;
  79891. sideOrientation?: number;
  79892. frontUVs?: Vector4;
  79893. backUVs?: Vector4;
  79894. }): VertexData;
  79895. /**
  79896. * Creates the VertexData for a TorusKnot
  79897. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  79898. * * radius the radius of the torus knot, optional, default 2
  79899. * * tube the thickness of the tube, optional, default 0.5
  79900. * * radialSegments the number of sides on each tube segments, optional, default 32
  79901. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  79902. * * p the number of windings around the z axis, optional, default 2
  79903. * * q the number of windings around the x axis, optional, default 3
  79904. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79905. * * 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)
  79906. * * 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)
  79907. * @returns the VertexData of the Torus Knot
  79908. */
  79909. static CreateTorusKnot(options: {
  79910. radius?: number;
  79911. tube?: number;
  79912. radialSegments?: number;
  79913. tubularSegments?: number;
  79914. p?: number;
  79915. q?: number;
  79916. sideOrientation?: number;
  79917. frontUVs?: Vector4;
  79918. backUVs?: Vector4;
  79919. }): VertexData;
  79920. /**
  79921. * Compute normals for given positions and indices
  79922. * @param positions an array of vertex positions, [...., x, y, z, ......]
  79923. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  79924. * @param normals an array of vertex normals, [...., x, y, z, ......]
  79925. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  79926. * * facetNormals : optional array of facet normals (vector3)
  79927. * * facetPositions : optional array of facet positions (vector3)
  79928. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  79929. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  79930. * * bInfo : optional bounding info, required for facetPartitioning computation
  79931. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  79932. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  79933. * * useRightHandedSystem: optional boolean to for right handed system computation
  79934. * * depthSort : optional boolean to enable the facet depth sort computation
  79935. * * distanceTo : optional Vector3 to compute the facet depth from this location
  79936. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  79937. */
  79938. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  79939. facetNormals?: any;
  79940. facetPositions?: any;
  79941. facetPartitioning?: any;
  79942. ratio?: number;
  79943. bInfo?: any;
  79944. bbSize?: Vector3;
  79945. subDiv?: any;
  79946. useRightHandedSystem?: boolean;
  79947. depthSort?: boolean;
  79948. distanceTo?: Vector3;
  79949. depthSortedFacets?: any;
  79950. }): void;
  79951. /** @hidden */
  79952. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  79953. /**
  79954. * Applies VertexData created from the imported parameters to the geometry
  79955. * @param parsedVertexData the parsed data from an imported file
  79956. * @param geometry the geometry to apply the VertexData to
  79957. */
  79958. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  79959. }
  79960. }
  79961. declare module BABYLON {
  79962. /**
  79963. * Class containing static functions to help procedurally build meshes
  79964. */
  79965. export class DiscBuilder {
  79966. /**
  79967. * Creates a plane polygonal mesh. By default, this is a disc
  79968. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  79969. * * 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
  79970. * * 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
  79971. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79972. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79974. * @param name defines the name of the mesh
  79975. * @param options defines the options used to create the mesh
  79976. * @param scene defines the hosting scene
  79977. * @returns the plane polygonal mesh
  79978. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  79979. */
  79980. static CreateDisc(name: string, options: {
  79981. radius?: number;
  79982. tessellation?: number;
  79983. arc?: number;
  79984. updatable?: boolean;
  79985. sideOrientation?: number;
  79986. frontUVs?: Vector4;
  79987. backUVs?: Vector4;
  79988. }, scene?: Nullable<Scene>): Mesh;
  79989. }
  79990. }
  79991. declare module BABYLON {
  79992. /**
  79993. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  79994. *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.
  79995. * The SPS is also a particle system. It provides some methods to manage the particles.
  79996. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  79997. *
  79998. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  79999. */
  80000. export class SolidParticleSystem implements IDisposable {
  80001. /**
  80002. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  80003. * Example : var p = SPS.particles[i];
  80004. */
  80005. particles: SolidParticle[];
  80006. /**
  80007. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  80008. */
  80009. nbParticles: number;
  80010. /**
  80011. * If the particles must ever face the camera (default false). Useful for planar particles.
  80012. */
  80013. billboard: boolean;
  80014. /**
  80015. * Recompute normals when adding a shape
  80016. */
  80017. recomputeNormals: boolean;
  80018. /**
  80019. * This a counter ofr your own usage. It's not set by any SPS functions.
  80020. */
  80021. counter: number;
  80022. /**
  80023. * The SPS name. This name is also given to the underlying mesh.
  80024. */
  80025. name: string;
  80026. /**
  80027. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  80028. */
  80029. mesh: Mesh;
  80030. /**
  80031. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  80032. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  80033. */
  80034. vars: any;
  80035. /**
  80036. * This array is populated when the SPS is set as 'pickable'.
  80037. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  80038. * Each element of this array is an object `{idx: int, faceId: int}`.
  80039. * `idx` is the picked particle index in the `SPS.particles` array
  80040. * `faceId` is the picked face index counted within this particle.
  80041. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  80042. */
  80043. pickedParticles: {
  80044. idx: number;
  80045. faceId: number;
  80046. }[];
  80047. /**
  80048. * This array is populated when `enableDepthSort` is set to true.
  80049. * Each element of this array is an instance of the class DepthSortedParticle.
  80050. */
  80051. depthSortedParticles: DepthSortedParticle[];
  80052. /**
  80053. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  80054. * @hidden
  80055. */
  80056. _bSphereOnly: boolean;
  80057. /**
  80058. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  80059. * @hidden
  80060. */
  80061. _bSphereRadiusFactor: number;
  80062. private _scene;
  80063. private _positions;
  80064. private _indices;
  80065. private _normals;
  80066. private _colors;
  80067. private _uvs;
  80068. private _indices32;
  80069. private _positions32;
  80070. private _normals32;
  80071. private _fixedNormal32;
  80072. private _colors32;
  80073. private _uvs32;
  80074. private _index;
  80075. private _updatable;
  80076. private _pickable;
  80077. private _isVisibilityBoxLocked;
  80078. private _alwaysVisible;
  80079. private _depthSort;
  80080. private _shapeCounter;
  80081. private _copy;
  80082. private _color;
  80083. private _computeParticleColor;
  80084. private _computeParticleTexture;
  80085. private _computeParticleRotation;
  80086. private _computeParticleVertex;
  80087. private _computeBoundingBox;
  80088. private _depthSortParticles;
  80089. private _camera;
  80090. private _mustUnrotateFixedNormals;
  80091. private _particlesIntersect;
  80092. private _needs32Bits;
  80093. /**
  80094. * Creates a SPS (Solid Particle System) object.
  80095. * @param name (String) is the SPS name, this will be the underlying mesh name.
  80096. * @param scene (Scene) is the scene in which the SPS is added.
  80097. * @param options defines the options of the sps e.g.
  80098. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  80099. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  80100. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  80101. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  80102. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  80103. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  80104. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  80105. */
  80106. constructor(name: string, scene: Scene, options?: {
  80107. updatable?: boolean;
  80108. isPickable?: boolean;
  80109. enableDepthSort?: boolean;
  80110. particleIntersection?: boolean;
  80111. boundingSphereOnly?: boolean;
  80112. bSphereRadiusFactor?: number;
  80113. });
  80114. /**
  80115. * Builds the SPS underlying mesh. Returns a standard Mesh.
  80116. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  80117. * @returns the created mesh
  80118. */
  80119. buildMesh(): Mesh;
  80120. /**
  80121. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  80122. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  80123. * Thus the particles generated from `digest()` have their property `position` set yet.
  80124. * @param mesh ( Mesh ) is the mesh to be digested
  80125. * @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
  80126. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  80127. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  80128. * @returns the current SPS
  80129. */
  80130. digest(mesh: Mesh, options?: {
  80131. facetNb?: number;
  80132. number?: number;
  80133. delta?: number;
  80134. }): SolidParticleSystem;
  80135. private _unrotateFixedNormals;
  80136. private _resetCopy;
  80137. private _meshBuilder;
  80138. private _posToShape;
  80139. private _uvsToShapeUV;
  80140. private _addParticle;
  80141. /**
  80142. * Adds some particles to the SPS from the model shape. Returns the shape id.
  80143. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  80144. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  80145. * @param nb (positive integer) the number of particles to be created from this model
  80146. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  80147. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  80148. * @returns the number of shapes in the system
  80149. */
  80150. addShape(mesh: Mesh, nb: number, options?: {
  80151. positionFunction?: any;
  80152. vertexFunction?: any;
  80153. }): number;
  80154. private _rebuildParticle;
  80155. /**
  80156. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  80157. * @returns the SPS.
  80158. */
  80159. rebuildMesh(): SolidParticleSystem;
  80160. /**
  80161. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  80162. * This method calls `updateParticle()` for each particle of the SPS.
  80163. * For an animated SPS, it is usually called within the render loop.
  80164. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  80165. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  80166. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  80167. * @returns the SPS.
  80168. */
  80169. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  80170. /**
  80171. * Disposes the SPS.
  80172. */
  80173. dispose(): void;
  80174. /**
  80175. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  80176. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80177. * @returns the SPS.
  80178. */
  80179. refreshVisibleSize(): SolidParticleSystem;
  80180. /**
  80181. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  80182. * @param size the size (float) of the visibility box
  80183. * note : this doesn't lock the SPS mesh bounding box.
  80184. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80185. */
  80186. setVisibilityBox(size: number): void;
  80187. /**
  80188. * Gets whether the SPS as always visible or not
  80189. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80190. */
  80191. /**
  80192. * Sets the SPS as always visible or not
  80193. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80194. */
  80195. isAlwaysVisible: boolean;
  80196. /**
  80197. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80198. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80199. */
  80200. /**
  80201. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80202. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80203. */
  80204. isVisibilityBoxLocked: boolean;
  80205. /**
  80206. * Tells to `setParticles()` to compute the particle rotations or not.
  80207. * Default value : true. The SPS is faster when it's set to false.
  80208. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80209. */
  80210. /**
  80211. * Gets if `setParticles()` computes the particle rotations or not.
  80212. * Default value : true. The SPS is faster when it's set to false.
  80213. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80214. */
  80215. computeParticleRotation: boolean;
  80216. /**
  80217. * Tells to `setParticles()` to compute the particle colors or not.
  80218. * Default value : true. The SPS is faster when it's set to false.
  80219. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80220. */
  80221. /**
  80222. * Gets if `setParticles()` computes the particle colors or not.
  80223. * Default value : true. The SPS is faster when it's set to false.
  80224. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80225. */
  80226. computeParticleColor: boolean;
  80227. /**
  80228. * Gets if `setParticles()` computes the particle textures or not.
  80229. * Default value : true. The SPS is faster when it's set to false.
  80230. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  80231. */
  80232. computeParticleTexture: boolean;
  80233. /**
  80234. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  80235. * Default value : false. The SPS is faster when it's set to false.
  80236. * Note : the particle custom vertex positions aren't stored values.
  80237. */
  80238. /**
  80239. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  80240. * Default value : false. The SPS is faster when it's set to false.
  80241. * Note : the particle custom vertex positions aren't stored values.
  80242. */
  80243. computeParticleVertex: boolean;
  80244. /**
  80245. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  80246. */
  80247. /**
  80248. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  80249. */
  80250. computeBoundingBox: boolean;
  80251. /**
  80252. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  80253. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80254. * Default : `true`
  80255. */
  80256. /**
  80257. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  80258. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80259. * Default : `true`
  80260. */
  80261. depthSortParticles: boolean;
  80262. /**
  80263. * This function does nothing. It may be overwritten to set all the particle first values.
  80264. * The SPS doesn't call this function, you may have to call it by your own.
  80265. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80266. */
  80267. initParticles(): void;
  80268. /**
  80269. * This function does nothing. It may be overwritten to recycle a particle.
  80270. * The SPS doesn't call this function, you may have to call it by your own.
  80271. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80272. * @param particle The particle to recycle
  80273. * @returns the recycled particle
  80274. */
  80275. recycleParticle(particle: SolidParticle): SolidParticle;
  80276. /**
  80277. * Updates a particle : this function should be overwritten by the user.
  80278. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  80279. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80280. * @example : just set a particle position or velocity and recycle conditions
  80281. * @param particle The particle to update
  80282. * @returns the updated particle
  80283. */
  80284. updateParticle(particle: SolidParticle): SolidParticle;
  80285. /**
  80286. * Updates a vertex of a particle : it can be overwritten by the user.
  80287. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  80288. * @param particle the current particle
  80289. * @param vertex the current index of the current particle
  80290. * @param pt the index of the current vertex in the particle shape
  80291. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  80292. * @example : just set a vertex particle position
  80293. * @returns the updated vertex
  80294. */
  80295. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  80296. /**
  80297. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  80298. * This does nothing and may be overwritten by the user.
  80299. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80300. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80301. * @param update the boolean update value actually passed to setParticles()
  80302. */
  80303. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80304. /**
  80305. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  80306. * This will be passed three parameters.
  80307. * This does nothing and may be overwritten by the user.
  80308. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80309. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80310. * @param update the boolean update value actually passed to setParticles()
  80311. */
  80312. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80313. }
  80314. }
  80315. declare module BABYLON {
  80316. /**
  80317. * Represents one particle of a solid particle system.
  80318. */
  80319. export class SolidParticle {
  80320. /**
  80321. * particle global index
  80322. */
  80323. idx: number;
  80324. /**
  80325. * The color of the particle
  80326. */
  80327. color: Nullable<Color4>;
  80328. /**
  80329. * The world space position of the particle.
  80330. */
  80331. position: Vector3;
  80332. /**
  80333. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  80334. */
  80335. rotation: Vector3;
  80336. /**
  80337. * The world space rotation quaternion of the particle.
  80338. */
  80339. rotationQuaternion: Nullable<Quaternion>;
  80340. /**
  80341. * The scaling of the particle.
  80342. */
  80343. scaling: Vector3;
  80344. /**
  80345. * The uvs of the particle.
  80346. */
  80347. uvs: Vector4;
  80348. /**
  80349. * The current speed of the particle.
  80350. */
  80351. velocity: Vector3;
  80352. /**
  80353. * The pivot point in the particle local space.
  80354. */
  80355. pivot: Vector3;
  80356. /**
  80357. * Must the particle be translated from its pivot point in its local space ?
  80358. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  80359. * Default : false
  80360. */
  80361. translateFromPivot: boolean;
  80362. /**
  80363. * Is the particle active or not ?
  80364. */
  80365. alive: boolean;
  80366. /**
  80367. * Is the particle visible or not ?
  80368. */
  80369. isVisible: boolean;
  80370. /**
  80371. * Index of this particle in the global "positions" array (Internal use)
  80372. * @hidden
  80373. */
  80374. _pos: number;
  80375. /**
  80376. * @hidden Index of this particle in the global "indices" array (Internal use)
  80377. */
  80378. _ind: number;
  80379. /**
  80380. * @hidden ModelShape of this particle (Internal use)
  80381. */
  80382. _model: ModelShape;
  80383. /**
  80384. * ModelShape id of this particle
  80385. */
  80386. shapeId: number;
  80387. /**
  80388. * Index of the particle in its shape id (Internal use)
  80389. */
  80390. idxInShape: number;
  80391. /**
  80392. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  80393. */
  80394. _modelBoundingInfo: BoundingInfo;
  80395. /**
  80396. * @hidden Particle BoundingInfo object (Internal use)
  80397. */
  80398. _boundingInfo: BoundingInfo;
  80399. /**
  80400. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  80401. */
  80402. _sps: SolidParticleSystem;
  80403. /**
  80404. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  80405. */
  80406. _stillInvisible: boolean;
  80407. /**
  80408. * @hidden Last computed particle rotation matrix
  80409. */
  80410. _rotationMatrix: number[];
  80411. /**
  80412. * Parent particle Id, if any.
  80413. * Default null.
  80414. */
  80415. parentId: Nullable<number>;
  80416. /**
  80417. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  80418. * The possible values are :
  80419. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80420. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80421. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80422. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80423. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80424. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  80425. * */
  80426. cullingStrategy: number;
  80427. /**
  80428. * @hidden Internal global position in the SPS.
  80429. */
  80430. _globalPosition: Vector3;
  80431. /**
  80432. * Creates a Solid Particle object.
  80433. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  80434. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  80435. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  80436. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  80437. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  80438. * @param shapeId (integer) is the model shape identifier in the SPS.
  80439. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  80440. * @param sps defines the sps it is associated to
  80441. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  80442. */
  80443. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  80444. /**
  80445. * Legacy support, changed scale to scaling
  80446. */
  80447. /**
  80448. * Legacy support, changed scale to scaling
  80449. */
  80450. scale: Vector3;
  80451. /**
  80452. * Legacy support, changed quaternion to rotationQuaternion
  80453. */
  80454. /**
  80455. * Legacy support, changed quaternion to rotationQuaternion
  80456. */
  80457. quaternion: Nullable<Quaternion>;
  80458. /**
  80459. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  80460. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  80461. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  80462. * @returns true if it intersects
  80463. */
  80464. intersectsMesh(target: Mesh | SolidParticle): boolean;
  80465. /**
  80466. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  80467. * A particle is in the frustum if its bounding box intersects the frustum
  80468. * @param frustumPlanes defines the frustum to test
  80469. * @returns true if the particle is in the frustum planes
  80470. */
  80471. isInFrustum(frustumPlanes: Plane[]): boolean;
  80472. /**
  80473. * get the rotation matrix of the particle
  80474. * @hidden
  80475. */
  80476. getRotationMatrix(m: Matrix): void;
  80477. }
  80478. /**
  80479. * Represents the shape of the model used by one particle of a solid particle system.
  80480. * SPS internal tool, don't use it manually.
  80481. */
  80482. export class ModelShape {
  80483. /**
  80484. * The shape id
  80485. * @hidden
  80486. */
  80487. shapeID: number;
  80488. /**
  80489. * flat array of model positions (internal use)
  80490. * @hidden
  80491. */
  80492. _shape: Vector3[];
  80493. /**
  80494. * flat array of model UVs (internal use)
  80495. * @hidden
  80496. */
  80497. _shapeUV: number[];
  80498. /**
  80499. * length of the shape in the model indices array (internal use)
  80500. * @hidden
  80501. */
  80502. _indicesLength: number;
  80503. /**
  80504. * Custom position function (internal use)
  80505. * @hidden
  80506. */
  80507. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  80508. /**
  80509. * Custom vertex function (internal use)
  80510. * @hidden
  80511. */
  80512. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  80513. /**
  80514. * 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.
  80515. * SPS internal tool, don't use it manually.
  80516. * @hidden
  80517. */
  80518. 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>);
  80519. }
  80520. /**
  80521. * Represents a Depth Sorted Particle in the solid particle system.
  80522. */
  80523. export class DepthSortedParticle {
  80524. /**
  80525. * Index of the particle in the "indices" array
  80526. */
  80527. ind: number;
  80528. /**
  80529. * Length of the particle shape in the "indices" array
  80530. */
  80531. indicesLength: number;
  80532. /**
  80533. * Squared distance from the particle to the camera
  80534. */
  80535. sqDistance: number;
  80536. }
  80537. }
  80538. declare module BABYLON {
  80539. /**
  80540. * Class used to store all common mesh properties
  80541. */
  80542. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  80543. /** No occlusion */
  80544. static OCCLUSION_TYPE_NONE: number;
  80545. /** Occlusion set to optimisitic */
  80546. static OCCLUSION_TYPE_OPTIMISTIC: number;
  80547. /** Occlusion set to strict */
  80548. static OCCLUSION_TYPE_STRICT: number;
  80549. /** Use an accurante occlusion algorithm */
  80550. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  80551. /** Use a conservative occlusion algorithm */
  80552. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  80553. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80554. * Test order :
  80555. * Is the bounding sphere outside the frustum ?
  80556. * If not, are the bounding box vertices outside the frustum ?
  80557. * It not, then the cullable object is in the frustum.
  80558. */
  80559. static readonly CULLINGSTRATEGY_STANDARD: number;
  80560. /** Culling strategy : Bounding Sphere Only.
  80561. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80562. * It's also less accurate than the standard because some not visible objects can still be selected.
  80563. * Test : is the bounding sphere outside the frustum ?
  80564. * If not, then the cullable object is in the frustum.
  80565. */
  80566. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80567. /** Culling strategy : Optimistic Inclusion.
  80568. * This in an inclusion test first, then the standard exclusion test.
  80569. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80570. * 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.
  80571. * Anyway, it's as accurate as the standard strategy.
  80572. * Test :
  80573. * Is the cullable object bounding sphere center in the frustum ?
  80574. * If not, apply the default culling strategy.
  80575. */
  80576. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80577. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80578. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80579. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80580. * 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.
  80581. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80582. * Test :
  80583. * Is the cullable object bounding sphere center in the frustum ?
  80584. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80585. */
  80586. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80587. /**
  80588. * No billboard
  80589. */
  80590. static readonly BILLBOARDMODE_NONE: number;
  80591. /** Billboard on X axis */
  80592. static readonly BILLBOARDMODE_X: number;
  80593. /** Billboard on Y axis */
  80594. static readonly BILLBOARDMODE_Y: number;
  80595. /** Billboard on Z axis */
  80596. static readonly BILLBOARDMODE_Z: number;
  80597. /** Billboard on all axes */
  80598. static readonly BILLBOARDMODE_ALL: number;
  80599. private _facetData;
  80600. /**
  80601. * The culling strategy to use to check whether the mesh must be rendered or not.
  80602. * This value can be changed at any time and will be used on the next render mesh selection.
  80603. * The possible values are :
  80604. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80605. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80606. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80607. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80608. * Please read each static variable documentation to get details about the culling process.
  80609. * */
  80610. cullingStrategy: number;
  80611. /**
  80612. * Gets the number of facets in the mesh
  80613. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80614. */
  80615. readonly facetNb: number;
  80616. /**
  80617. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  80618. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80619. */
  80620. partitioningSubdivisions: number;
  80621. /**
  80622. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  80623. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  80624. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80625. */
  80626. partitioningBBoxRatio: number;
  80627. /**
  80628. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  80629. * Works only for updatable meshes.
  80630. * Doesn't work with multi-materials
  80631. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80632. */
  80633. mustDepthSortFacets: boolean;
  80634. /**
  80635. * The location (Vector3) where the facet depth sort must be computed from.
  80636. * By default, the active camera position.
  80637. * Used only when facet depth sort is enabled
  80638. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80639. */
  80640. facetDepthSortFrom: Vector3;
  80641. /**
  80642. * gets a boolean indicating if facetData is enabled
  80643. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80644. */
  80645. readonly isFacetDataEnabled: boolean;
  80646. /** @hidden */
  80647. _updateNonUniformScalingState(value: boolean): boolean;
  80648. /**
  80649. * An event triggered when this mesh collides with another one
  80650. */
  80651. onCollideObservable: Observable<AbstractMesh>;
  80652. private _onCollideObserver;
  80653. /** Set a function to call when this mesh collides with another one */
  80654. onCollide: () => void;
  80655. /**
  80656. * An event triggered when the collision's position changes
  80657. */
  80658. onCollisionPositionChangeObservable: Observable<Vector3>;
  80659. private _onCollisionPositionChangeObserver;
  80660. /** Set a function to call when the collision's position changes */
  80661. onCollisionPositionChange: () => void;
  80662. /**
  80663. * An event triggered when material is changed
  80664. */
  80665. onMaterialChangedObservable: Observable<AbstractMesh>;
  80666. /**
  80667. * Gets or sets the orientation for POV movement & rotation
  80668. */
  80669. definedFacingForward: boolean;
  80670. /** @hidden */
  80671. _occlusionQuery: Nullable<WebGLQuery>;
  80672. private _visibility;
  80673. /**
  80674. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80675. */
  80676. /**
  80677. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80678. */
  80679. visibility: number;
  80680. /** Gets or sets the alpha index used to sort transparent meshes
  80681. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  80682. */
  80683. alphaIndex: number;
  80684. /**
  80685. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  80686. */
  80687. isVisible: boolean;
  80688. /**
  80689. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80690. */
  80691. isPickable: boolean;
  80692. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  80693. showSubMeshesBoundingBox: boolean;
  80694. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  80695. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  80696. */
  80697. isBlocker: boolean;
  80698. /**
  80699. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  80700. */
  80701. enablePointerMoveEvents: boolean;
  80702. /**
  80703. * Specifies the rendering group id for this mesh (0 by default)
  80704. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80705. */
  80706. renderingGroupId: number;
  80707. private _material;
  80708. /** Gets or sets current material */
  80709. material: Nullable<Material>;
  80710. private _receiveShadows;
  80711. /**
  80712. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  80713. * @see http://doc.babylonjs.com/babylon101/shadows
  80714. */
  80715. receiveShadows: boolean;
  80716. /** Defines color to use when rendering outline */
  80717. outlineColor: Color3;
  80718. /** Define width to use when rendering outline */
  80719. outlineWidth: number;
  80720. /** Defines color to use when rendering overlay */
  80721. overlayColor: Color3;
  80722. /** Defines alpha to use when rendering overlay */
  80723. overlayAlpha: number;
  80724. private _hasVertexAlpha;
  80725. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  80726. hasVertexAlpha: boolean;
  80727. private _useVertexColors;
  80728. /** 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) */
  80729. useVertexColors: boolean;
  80730. private _computeBonesUsingShaders;
  80731. /**
  80732. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  80733. */
  80734. computeBonesUsingShaders: boolean;
  80735. private _numBoneInfluencers;
  80736. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  80737. numBoneInfluencers: number;
  80738. private _applyFog;
  80739. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  80740. applyFog: boolean;
  80741. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  80742. useOctreeForRenderingSelection: boolean;
  80743. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  80744. useOctreeForPicking: boolean;
  80745. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  80746. useOctreeForCollisions: boolean;
  80747. private _layerMask;
  80748. /**
  80749. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  80750. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  80751. */
  80752. layerMask: number;
  80753. /**
  80754. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  80755. */
  80756. alwaysSelectAsActiveMesh: boolean;
  80757. /**
  80758. * Gets or sets the current action manager
  80759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80760. */
  80761. actionManager: Nullable<AbstractActionManager>;
  80762. private _checkCollisions;
  80763. private _collisionMask;
  80764. private _collisionGroup;
  80765. /**
  80766. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  80767. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80768. */
  80769. ellipsoid: Vector3;
  80770. /**
  80771. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  80772. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80773. */
  80774. ellipsoidOffset: Vector3;
  80775. private _collider;
  80776. private _oldPositionForCollisions;
  80777. private _diffPositionForCollisions;
  80778. /**
  80779. * Gets or sets a collision mask used to mask collisions (default is -1).
  80780. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80781. */
  80782. collisionMask: number;
  80783. /**
  80784. * Gets or sets the current collision group mask (-1 by default).
  80785. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80786. */
  80787. collisionGroup: number;
  80788. /**
  80789. * Defines edge width used when edgesRenderer is enabled
  80790. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80791. */
  80792. edgesWidth: number;
  80793. /**
  80794. * Defines edge color used when edgesRenderer is enabled
  80795. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80796. */
  80797. edgesColor: Color4;
  80798. /** @hidden */
  80799. _edgesRenderer: Nullable<IEdgesRenderer>;
  80800. /** @hidden */
  80801. _masterMesh: Nullable<AbstractMesh>;
  80802. /** @hidden */
  80803. _boundingInfo: Nullable<BoundingInfo>;
  80804. /** @hidden */
  80805. _renderId: number;
  80806. /**
  80807. * Gets or sets the list of subMeshes
  80808. * @see http://doc.babylonjs.com/how_to/multi_materials
  80809. */
  80810. subMeshes: SubMesh[];
  80811. /** @hidden */
  80812. _intersectionsInProgress: AbstractMesh[];
  80813. /** @hidden */
  80814. _unIndexed: boolean;
  80815. /** @hidden */
  80816. _lightSources: Light[];
  80817. /** @hidden */
  80818. readonly _positions: Nullable<Vector3[]>;
  80819. /** @hidden */
  80820. _waitingActions: any;
  80821. /** @hidden */
  80822. _waitingFreezeWorldMatrix: Nullable<boolean>;
  80823. private _skeleton;
  80824. /** @hidden */
  80825. _bonesTransformMatrices: Nullable<Float32Array>;
  80826. /**
  80827. * Gets or sets a skeleton to apply skining transformations
  80828. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80829. */
  80830. skeleton: Nullable<Skeleton>;
  80831. /**
  80832. * An event triggered when the mesh is rebuilt.
  80833. */
  80834. onRebuildObservable: Observable<AbstractMesh>;
  80835. /**
  80836. * Creates a new AbstractMesh
  80837. * @param name defines the name of the mesh
  80838. * @param scene defines the hosting scene
  80839. */
  80840. constructor(name: string, scene?: Nullable<Scene>);
  80841. /**
  80842. * Returns the string "AbstractMesh"
  80843. * @returns "AbstractMesh"
  80844. */
  80845. getClassName(): string;
  80846. /**
  80847. * Gets a string representation of the current mesh
  80848. * @param fullDetails defines a boolean indicating if full details must be included
  80849. * @returns a string representation of the current mesh
  80850. */
  80851. toString(fullDetails?: boolean): string;
  80852. /** @hidden */
  80853. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  80854. /** @hidden */
  80855. _rebuild(): void;
  80856. /** @hidden */
  80857. _resyncLightSources(): void;
  80858. /** @hidden */
  80859. _resyncLighSource(light: Light): void;
  80860. /** @hidden */
  80861. _unBindEffect(): void;
  80862. /** @hidden */
  80863. _removeLightSource(light: Light): void;
  80864. private _markSubMeshesAsDirty;
  80865. /** @hidden */
  80866. _markSubMeshesAsLightDirty(): void;
  80867. /** @hidden */
  80868. _markSubMeshesAsAttributesDirty(): void;
  80869. /** @hidden */
  80870. _markSubMeshesAsMiscDirty(): void;
  80871. /**
  80872. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  80873. */
  80874. scaling: Vector3;
  80875. /**
  80876. * Returns true if the mesh is blocked. Implemented by child classes
  80877. */
  80878. readonly isBlocked: boolean;
  80879. /**
  80880. * Returns the mesh itself by default. Implemented by child classes
  80881. * @param camera defines the camera to use to pick the right LOD level
  80882. * @returns the currentAbstractMesh
  80883. */
  80884. getLOD(camera: Camera): Nullable<AbstractMesh>;
  80885. /**
  80886. * Returns 0 by default. Implemented by child classes
  80887. * @returns an integer
  80888. */
  80889. getTotalVertices(): number;
  80890. /**
  80891. * Returns a positive integer : the total number of indices in this mesh geometry.
  80892. * @returns the numner of indices or zero if the mesh has no geometry.
  80893. */
  80894. getTotalIndices(): number;
  80895. /**
  80896. * Returns null by default. Implemented by child classes
  80897. * @returns null
  80898. */
  80899. getIndices(): Nullable<IndicesArray>;
  80900. /**
  80901. * Returns the array of the requested vertex data kind. Implemented by child classes
  80902. * @param kind defines the vertex data kind to use
  80903. * @returns null
  80904. */
  80905. getVerticesData(kind: string): Nullable<FloatArray>;
  80906. /**
  80907. * Sets the vertex data of the mesh geometry for the requested `kind`.
  80908. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  80909. * Note that a new underlying VertexBuffer object is created each call.
  80910. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  80911. * @param kind defines vertex data kind:
  80912. * * VertexBuffer.PositionKind
  80913. * * VertexBuffer.UVKind
  80914. * * VertexBuffer.UV2Kind
  80915. * * VertexBuffer.UV3Kind
  80916. * * VertexBuffer.UV4Kind
  80917. * * VertexBuffer.UV5Kind
  80918. * * VertexBuffer.UV6Kind
  80919. * * VertexBuffer.ColorKind
  80920. * * VertexBuffer.MatricesIndicesKind
  80921. * * VertexBuffer.MatricesIndicesExtraKind
  80922. * * VertexBuffer.MatricesWeightsKind
  80923. * * VertexBuffer.MatricesWeightsExtraKind
  80924. * @param data defines the data source
  80925. * @param updatable defines if the data must be flagged as updatable (or static)
  80926. * @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
  80927. * @returns the current mesh
  80928. */
  80929. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  80930. /**
  80931. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  80932. * If the mesh has no geometry, it is simply returned as it is.
  80933. * @param kind defines vertex data kind:
  80934. * * VertexBuffer.PositionKind
  80935. * * VertexBuffer.UVKind
  80936. * * VertexBuffer.UV2Kind
  80937. * * VertexBuffer.UV3Kind
  80938. * * VertexBuffer.UV4Kind
  80939. * * VertexBuffer.UV5Kind
  80940. * * VertexBuffer.UV6Kind
  80941. * * VertexBuffer.ColorKind
  80942. * * VertexBuffer.MatricesIndicesKind
  80943. * * VertexBuffer.MatricesIndicesExtraKind
  80944. * * VertexBuffer.MatricesWeightsKind
  80945. * * VertexBuffer.MatricesWeightsExtraKind
  80946. * @param data defines the data source
  80947. * @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
  80948. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  80949. * @returns the current mesh
  80950. */
  80951. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  80952. /**
  80953. * Sets the mesh indices,
  80954. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  80955. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  80956. * @param totalVertices Defines the total number of vertices
  80957. * @returns the current mesh
  80958. */
  80959. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  80960. /**
  80961. * Gets a boolean indicating if specific vertex data is present
  80962. * @param kind defines the vertex data kind to use
  80963. * @returns true is data kind is present
  80964. */
  80965. isVerticesDataPresent(kind: string): boolean;
  80966. /**
  80967. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  80968. * @returns a BoundingInfo
  80969. */
  80970. getBoundingInfo(): BoundingInfo;
  80971. /**
  80972. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  80973. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  80974. * @returns the current mesh
  80975. */
  80976. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  80977. /**
  80978. * Overwrite the current bounding info
  80979. * @param boundingInfo defines the new bounding info
  80980. * @returns the current mesh
  80981. */
  80982. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  80983. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  80984. readonly useBones: boolean;
  80985. /** @hidden */
  80986. _preActivate(): void;
  80987. /** @hidden */
  80988. _preActivateForIntermediateRendering(renderId: number): void;
  80989. /** @hidden */
  80990. _activate(renderId: number): void;
  80991. /**
  80992. * Gets the current world matrix
  80993. * @returns a Matrix
  80994. */
  80995. getWorldMatrix(): Matrix;
  80996. /** @hidden */
  80997. _getWorldMatrixDeterminant(): number;
  80998. /**
  80999. * Perform relative position change from the point of view of behind the front of the mesh.
  81000. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81001. * Supports definition of mesh facing forward or backward
  81002. * @param amountRight defines the distance on the right axis
  81003. * @param amountUp defines the distance on the up axis
  81004. * @param amountForward defines the distance on the forward axis
  81005. * @returns the current mesh
  81006. */
  81007. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  81008. /**
  81009. * Calculate relative position change from the point of view of behind the front of the mesh.
  81010. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81011. * Supports definition of mesh facing forward or backward
  81012. * @param amountRight defines the distance on the right axis
  81013. * @param amountUp defines the distance on the up axis
  81014. * @param amountForward defines the distance on the forward axis
  81015. * @returns the new displacement vector
  81016. */
  81017. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  81018. /**
  81019. * Perform relative rotation change from the point of view of behind the front of the mesh.
  81020. * Supports definition of mesh facing forward or backward
  81021. * @param flipBack defines the flip
  81022. * @param twirlClockwise defines the twirl
  81023. * @param tiltRight defines the tilt
  81024. * @returns the current mesh
  81025. */
  81026. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  81027. /**
  81028. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  81029. * Supports definition of mesh facing forward or backward.
  81030. * @param flipBack defines the flip
  81031. * @param twirlClockwise defines the twirl
  81032. * @param tiltRight defines the tilt
  81033. * @returns the new rotation vector
  81034. */
  81035. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  81036. /**
  81037. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  81038. * @param includeDescendants Include bounding info from descendants as well (true by default)
  81039. * @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
  81040. * @returns the new bounding vectors
  81041. */
  81042. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  81043. min: Vector3;
  81044. max: Vector3;
  81045. };
  81046. /**
  81047. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81048. * This means the mesh underlying bounding box and sphere are recomputed.
  81049. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81050. * @returns the current mesh
  81051. */
  81052. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  81053. /** @hidden */
  81054. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  81055. /** @hidden */
  81056. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  81057. /** @hidden */
  81058. _updateBoundingInfo(): AbstractMesh;
  81059. /** @hidden */
  81060. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  81061. /** @hidden */
  81062. protected _afterComputeWorldMatrix(): void;
  81063. /**
  81064. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81065. * A mesh is in the frustum if its bounding box intersects the frustum
  81066. * @param frustumPlanes defines the frustum to test
  81067. * @returns true if the mesh is in the frustum planes
  81068. */
  81069. isInFrustum(frustumPlanes: Plane[]): boolean;
  81070. /**
  81071. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  81072. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  81073. * @param frustumPlanes defines the frustum to test
  81074. * @returns true if the mesh is completely in the frustum planes
  81075. */
  81076. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81077. /**
  81078. * True if the mesh intersects another mesh or a SolidParticle object
  81079. * @param mesh defines a target mesh or SolidParticle to test
  81080. * @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)
  81081. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  81082. * @returns true if there is an intersection
  81083. */
  81084. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  81085. /**
  81086. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  81087. * @param point defines the point to test
  81088. * @returns true if there is an intersection
  81089. */
  81090. intersectsPoint(point: Vector3): boolean;
  81091. /**
  81092. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  81093. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81094. */
  81095. checkCollisions: boolean;
  81096. /**
  81097. * Gets Collider object used to compute collisions (not physics)
  81098. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81099. */
  81100. readonly collider: Collider;
  81101. /**
  81102. * Move the mesh using collision engine
  81103. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81104. * @param displacement defines the requested displacement vector
  81105. * @returns the current mesh
  81106. */
  81107. moveWithCollisions(displacement: Vector3): AbstractMesh;
  81108. private _onCollisionPositionChange;
  81109. /** @hidden */
  81110. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  81111. /** @hidden */
  81112. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  81113. /** @hidden */
  81114. _checkCollision(collider: Collider): AbstractMesh;
  81115. /** @hidden */
  81116. _generatePointsArray(): boolean;
  81117. /**
  81118. * Checks if the passed Ray intersects with the mesh
  81119. * @param ray defines the ray to use
  81120. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  81121. * @returns the picking info
  81122. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81123. */
  81124. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  81125. /**
  81126. * Clones the current mesh
  81127. * @param name defines the mesh name
  81128. * @param newParent defines the new mesh parent
  81129. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  81130. * @returns the new mesh
  81131. */
  81132. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  81133. /**
  81134. * Disposes all the submeshes of the current meshnp
  81135. * @returns the current mesh
  81136. */
  81137. releaseSubMeshes(): AbstractMesh;
  81138. /**
  81139. * Releases resources associated with this abstract mesh.
  81140. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81141. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81142. */
  81143. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81144. /**
  81145. * Adds the passed mesh as a child to the current mesh
  81146. * @param mesh defines the child mesh
  81147. * @returns the current mesh
  81148. */
  81149. addChild(mesh: AbstractMesh): AbstractMesh;
  81150. /**
  81151. * Removes the passed mesh from the current mesh children list
  81152. * @param mesh defines the child mesh
  81153. * @returns the current mesh
  81154. */
  81155. removeChild(mesh: AbstractMesh): AbstractMesh;
  81156. /** @hidden */
  81157. private _initFacetData;
  81158. /**
  81159. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  81160. * This method can be called within the render loop.
  81161. * 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
  81162. * @returns the current mesh
  81163. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81164. */
  81165. updateFacetData(): AbstractMesh;
  81166. /**
  81167. * Returns the facetLocalNormals array.
  81168. * The normals are expressed in the mesh local spac
  81169. * @returns an array of Vector3
  81170. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81171. */
  81172. getFacetLocalNormals(): Vector3[];
  81173. /**
  81174. * Returns the facetLocalPositions array.
  81175. * The facet positions are expressed in the mesh local space
  81176. * @returns an array of Vector3
  81177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81178. */
  81179. getFacetLocalPositions(): Vector3[];
  81180. /**
  81181. * Returns the facetLocalPartioning array
  81182. * @returns an array of array of numbers
  81183. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81184. */
  81185. getFacetLocalPartitioning(): number[][];
  81186. /**
  81187. * Returns the i-th facet position in the world system.
  81188. * This method allocates a new Vector3 per call
  81189. * @param i defines the facet index
  81190. * @returns a new Vector3
  81191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81192. */
  81193. getFacetPosition(i: number): Vector3;
  81194. /**
  81195. * Sets the reference Vector3 with the i-th facet position in the world system
  81196. * @param i defines the facet index
  81197. * @param ref defines the target vector
  81198. * @returns the current mesh
  81199. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81200. */
  81201. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  81202. /**
  81203. * Returns the i-th facet normal in the world system.
  81204. * This method allocates a new Vector3 per call
  81205. * @param i defines the facet index
  81206. * @returns a new Vector3
  81207. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81208. */
  81209. getFacetNormal(i: number): Vector3;
  81210. /**
  81211. * Sets the reference Vector3 with the i-th facet normal in the world system
  81212. * @param i defines the facet index
  81213. * @param ref defines the target vector
  81214. * @returns the current mesh
  81215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81216. */
  81217. getFacetNormalToRef(i: number, ref: Vector3): this;
  81218. /**
  81219. * 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)
  81220. * @param x defines x coordinate
  81221. * @param y defines y coordinate
  81222. * @param z defines z coordinate
  81223. * @returns the array of facet indexes
  81224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81225. */
  81226. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  81227. /**
  81228. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  81229. * @param projected sets as the (x,y,z) world projection on the facet
  81230. * @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
  81231. * @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
  81232. * @param x defines x coordinate
  81233. * @param y defines y coordinate
  81234. * @param z defines z coordinate
  81235. * @returns the face index if found (or null instead)
  81236. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81237. */
  81238. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81239. /**
  81240. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  81241. * @param projected sets as the (x,y,z) local projection on the facet
  81242. * @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
  81243. * @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
  81244. * @param x defines x coordinate
  81245. * @param y defines y coordinate
  81246. * @param z defines z coordinate
  81247. * @returns the face index if found (or null instead)
  81248. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81249. */
  81250. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81251. /**
  81252. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  81253. * @returns the parameters
  81254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81255. */
  81256. getFacetDataParameters(): any;
  81257. /**
  81258. * Disables the feature FacetData and frees the related memory
  81259. * @returns the current mesh
  81260. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81261. */
  81262. disableFacetData(): AbstractMesh;
  81263. /**
  81264. * Updates the AbstractMesh indices array
  81265. * @param indices defines the data source
  81266. * @returns the current mesh
  81267. */
  81268. updateIndices(indices: IndicesArray): AbstractMesh;
  81269. /**
  81270. * Creates new normals data for the mesh
  81271. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  81272. * @returns the current mesh
  81273. */
  81274. createNormals(updatable: boolean): AbstractMesh;
  81275. /**
  81276. * Align the mesh with a normal
  81277. * @param normal defines the normal to use
  81278. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  81279. * @returns the current mesh
  81280. */
  81281. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  81282. /** @hidden */
  81283. _checkOcclusionQuery(): boolean;
  81284. }
  81285. }
  81286. declare module BABYLON {
  81287. /**
  81288. * Interface used to define ActionEvent
  81289. */
  81290. export interface IActionEvent {
  81291. /** The mesh or sprite that triggered the action */
  81292. source: any;
  81293. /** The X mouse cursor position at the time of the event */
  81294. pointerX: number;
  81295. /** The Y mouse cursor position at the time of the event */
  81296. pointerY: number;
  81297. /** The mesh that is currently pointed at (can be null) */
  81298. meshUnderPointer: Nullable<AbstractMesh>;
  81299. /** the original (browser) event that triggered the ActionEvent */
  81300. sourceEvent?: any;
  81301. /** additional data for the event */
  81302. additionalData?: any;
  81303. }
  81304. /**
  81305. * ActionEvent is the event being sent when an action is triggered.
  81306. */
  81307. export class ActionEvent implements IActionEvent {
  81308. /** The mesh or sprite that triggered the action */
  81309. source: any;
  81310. /** The X mouse cursor position at the time of the event */
  81311. pointerX: number;
  81312. /** The Y mouse cursor position at the time of the event */
  81313. pointerY: number;
  81314. /** The mesh that is currently pointed at (can be null) */
  81315. meshUnderPointer: Nullable<AbstractMesh>;
  81316. /** the original (browser) event that triggered the ActionEvent */
  81317. sourceEvent?: any;
  81318. /** additional data for the event */
  81319. additionalData?: any;
  81320. /**
  81321. * Creates a new ActionEvent
  81322. * @param source The mesh or sprite that triggered the action
  81323. * @param pointerX The X mouse cursor position at the time of the event
  81324. * @param pointerY The Y mouse cursor position at the time of the event
  81325. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  81326. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  81327. * @param additionalData additional data for the event
  81328. */
  81329. constructor(
  81330. /** The mesh or sprite that triggered the action */
  81331. source: any,
  81332. /** The X mouse cursor position at the time of the event */
  81333. pointerX: number,
  81334. /** The Y mouse cursor position at the time of the event */
  81335. pointerY: number,
  81336. /** The mesh that is currently pointed at (can be null) */
  81337. meshUnderPointer: Nullable<AbstractMesh>,
  81338. /** the original (browser) event that triggered the ActionEvent */
  81339. sourceEvent?: any,
  81340. /** additional data for the event */
  81341. additionalData?: any);
  81342. /**
  81343. * Helper function to auto-create an ActionEvent from a source mesh.
  81344. * @param source The source mesh that triggered the event
  81345. * @param evt The original (browser) event
  81346. * @param additionalData additional data for the event
  81347. * @returns the new ActionEvent
  81348. */
  81349. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  81350. /**
  81351. * Helper function to auto-create an ActionEvent from a source sprite
  81352. * @param source The source sprite that triggered the event
  81353. * @param scene Scene associated with the sprite
  81354. * @param evt The original (browser) event
  81355. * @param additionalData additional data for the event
  81356. * @returns the new ActionEvent
  81357. */
  81358. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  81359. /**
  81360. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  81361. * @param scene the scene where the event occurred
  81362. * @param evt The original (browser) event
  81363. * @returns the new ActionEvent
  81364. */
  81365. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  81366. /**
  81367. * Helper function to auto-create an ActionEvent from a primitive
  81368. * @param prim defines the target primitive
  81369. * @param pointerPos defines the pointer position
  81370. * @param evt The original (browser) event
  81371. * @param additionalData additional data for the event
  81372. * @returns the new ActionEvent
  81373. */
  81374. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  81375. }
  81376. }
  81377. declare module BABYLON {
  81378. /**
  81379. * Abstract class used to decouple action Manager from scene and meshes.
  81380. * Do not instantiate.
  81381. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81382. */
  81383. export abstract class AbstractActionManager implements IDisposable {
  81384. /** Gets the list of active triggers */
  81385. static Triggers: {
  81386. [key: string]: number;
  81387. };
  81388. /** Gets the cursor to use when hovering items */
  81389. hoverCursor: string;
  81390. /** Gets the list of actions */
  81391. actions: IAction[];
  81392. /**
  81393. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  81394. */
  81395. isRecursive: boolean;
  81396. /**
  81397. * Releases all associated resources
  81398. */
  81399. abstract dispose(): void;
  81400. /**
  81401. * Does this action manager has pointer triggers
  81402. */
  81403. abstract readonly hasPointerTriggers: boolean;
  81404. /**
  81405. * Does this action manager has pick triggers
  81406. */
  81407. abstract readonly hasPickTriggers: boolean;
  81408. /**
  81409. * Process a specific trigger
  81410. * @param trigger defines the trigger to process
  81411. * @param evt defines the event details to be processed
  81412. */
  81413. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  81414. /**
  81415. * Does this action manager handles actions of any of the given triggers
  81416. * @param triggers defines the triggers to be tested
  81417. * @return a boolean indicating whether one (or more) of the triggers is handled
  81418. */
  81419. abstract hasSpecificTriggers(triggers: number[]): boolean;
  81420. /**
  81421. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81422. * speed.
  81423. * @param triggerA defines the trigger to be tested
  81424. * @param triggerB defines the trigger to be tested
  81425. * @return a boolean indicating whether one (or more) of the triggers is handled
  81426. */
  81427. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81428. /**
  81429. * Does this action manager handles actions of a given trigger
  81430. * @param trigger defines the trigger to be tested
  81431. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81432. * @return whether the trigger is handled
  81433. */
  81434. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81435. /**
  81436. * Serialize this manager to a JSON object
  81437. * @param name defines the property name to store this manager
  81438. * @returns a JSON representation of this manager
  81439. */
  81440. abstract serialize(name: string): any;
  81441. /**
  81442. * Does exist one action manager with at least one trigger
  81443. **/
  81444. static readonly HasTriggers: boolean;
  81445. /**
  81446. * Does exist one action manager with at least one pick trigger
  81447. **/
  81448. static readonly HasPickTriggers: boolean;
  81449. /**
  81450. * Does exist one action manager that handles actions of a given trigger
  81451. * @param trigger defines the trigger to be tested
  81452. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  81453. **/
  81454. static HasSpecificTrigger(trigger: number): boolean;
  81455. }
  81456. }
  81457. declare module BABYLON {
  81458. /**
  81459. * Defines how a node can be built from a string name.
  81460. */
  81461. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  81462. /**
  81463. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  81464. */
  81465. export class Node implements IBehaviorAware<Node> {
  81466. /** @hidden */
  81467. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  81468. private static _NodeConstructors;
  81469. /**
  81470. * Add a new node constructor
  81471. * @param type defines the type name of the node to construct
  81472. * @param constructorFunc defines the constructor function
  81473. */
  81474. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  81475. /**
  81476. * Returns a node constructor based on type name
  81477. * @param type defines the type name
  81478. * @param name defines the new node name
  81479. * @param scene defines the hosting scene
  81480. * @param options defines optional options to transmit to constructors
  81481. * @returns the new constructor or null
  81482. */
  81483. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  81484. /**
  81485. * Gets or sets the name of the node
  81486. */
  81487. name: string;
  81488. /**
  81489. * Gets or sets the id of the node
  81490. */
  81491. id: string;
  81492. /**
  81493. * Gets or sets the unique id of the node
  81494. */
  81495. uniqueId: number;
  81496. /**
  81497. * Gets or sets a string used to store user defined state for the node
  81498. */
  81499. state: string;
  81500. /**
  81501. * Gets or sets an object used to store user defined information for the node
  81502. */
  81503. metadata: any;
  81504. /**
  81505. * For internal use only. Please do not use.
  81506. */
  81507. reservedDataStore: any;
  81508. /**
  81509. * Gets or sets a boolean used to define if the node must be serialized
  81510. */
  81511. doNotSerialize: boolean;
  81512. /** @hidden */
  81513. _isDisposed: boolean;
  81514. /**
  81515. * Gets a list of Animations associated with the node
  81516. */
  81517. animations: Animation[];
  81518. protected _ranges: {
  81519. [name: string]: Nullable<AnimationRange>;
  81520. };
  81521. /**
  81522. * Callback raised when the node is ready to be used
  81523. */
  81524. onReady: (node: Node) => void;
  81525. private _isEnabled;
  81526. private _isParentEnabled;
  81527. private _isReady;
  81528. /** @hidden */
  81529. _currentRenderId: number;
  81530. private _parentRenderId;
  81531. protected _childRenderId: number;
  81532. /** @hidden */
  81533. _waitingParentId: Nullable<string>;
  81534. /** @hidden */
  81535. _scene: Scene;
  81536. /** @hidden */
  81537. _cache: any;
  81538. private _parentNode;
  81539. private _children;
  81540. /** @hidden */
  81541. _worldMatrix: Matrix;
  81542. /** @hidden */
  81543. _worldMatrixDeterminant: number;
  81544. /** @hidden */
  81545. private _sceneRootNodesIndex;
  81546. /**
  81547. * Gets a boolean indicating if the node has been disposed
  81548. * @returns true if the node was disposed
  81549. */
  81550. isDisposed(): boolean;
  81551. /**
  81552. * Gets or sets the parent of the node
  81553. */
  81554. parent: Nullable<Node>;
  81555. private addToSceneRootNodes;
  81556. private removeFromSceneRootNodes;
  81557. private _animationPropertiesOverride;
  81558. /**
  81559. * Gets or sets the animation properties override
  81560. */
  81561. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81562. /**
  81563. * Gets a string idenfifying the name of the class
  81564. * @returns "Node" string
  81565. */
  81566. getClassName(): string;
  81567. /** @hidden */
  81568. readonly _isNode: boolean;
  81569. /**
  81570. * An event triggered when the mesh is disposed
  81571. */
  81572. onDisposeObservable: Observable<Node>;
  81573. private _onDisposeObserver;
  81574. /**
  81575. * Sets a callback that will be raised when the node will be disposed
  81576. */
  81577. onDispose: () => void;
  81578. /**
  81579. * Creates a new Node
  81580. * @param name the name and id to be given to this node
  81581. * @param scene the scene this node will be added to
  81582. * @param addToRootNodes the node will be added to scene.rootNodes
  81583. */
  81584. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  81585. /**
  81586. * Gets the scene of the node
  81587. * @returns a scene
  81588. */
  81589. getScene(): Scene;
  81590. /**
  81591. * Gets the engine of the node
  81592. * @returns a Engine
  81593. */
  81594. getEngine(): Engine;
  81595. private _behaviors;
  81596. /**
  81597. * Attach a behavior to the node
  81598. * @see http://doc.babylonjs.com/features/behaviour
  81599. * @param behavior defines the behavior to attach
  81600. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  81601. * @returns the current Node
  81602. */
  81603. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  81604. /**
  81605. * Remove an attached behavior
  81606. * @see http://doc.babylonjs.com/features/behaviour
  81607. * @param behavior defines the behavior to attach
  81608. * @returns the current Node
  81609. */
  81610. removeBehavior(behavior: Behavior<Node>): Node;
  81611. /**
  81612. * Gets the list of attached behaviors
  81613. * @see http://doc.babylonjs.com/features/behaviour
  81614. */
  81615. readonly behaviors: Behavior<Node>[];
  81616. /**
  81617. * Gets an attached behavior by name
  81618. * @param name defines the name of the behavior to look for
  81619. * @see http://doc.babylonjs.com/features/behaviour
  81620. * @returns null if behavior was not found else the requested behavior
  81621. */
  81622. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  81623. /**
  81624. * Returns the latest update of the World matrix
  81625. * @returns a Matrix
  81626. */
  81627. getWorldMatrix(): Matrix;
  81628. /** @hidden */
  81629. _getWorldMatrixDeterminant(): number;
  81630. /**
  81631. * Returns directly the latest state of the mesh World matrix.
  81632. * A Matrix is returned.
  81633. */
  81634. readonly worldMatrixFromCache: Matrix;
  81635. /** @hidden */
  81636. _initCache(): void;
  81637. /** @hidden */
  81638. updateCache(force?: boolean): void;
  81639. /** @hidden */
  81640. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81641. /** @hidden */
  81642. _updateCache(ignoreParentClass?: boolean): void;
  81643. /** @hidden */
  81644. _isSynchronized(): boolean;
  81645. /** @hidden */
  81646. _markSyncedWithParent(): void;
  81647. /** @hidden */
  81648. isSynchronizedWithParent(): boolean;
  81649. /** @hidden */
  81650. isSynchronized(): boolean;
  81651. /**
  81652. * Is this node ready to be used/rendered
  81653. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81654. * @return true if the node is ready
  81655. */
  81656. isReady(completeCheck?: boolean): boolean;
  81657. /**
  81658. * Is this node enabled?
  81659. * 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
  81660. * @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
  81661. * @return whether this node (and its parent) is enabled
  81662. */
  81663. isEnabled(checkAncestors?: boolean): boolean;
  81664. /** @hidden */
  81665. protected _syncParentEnabledState(): void;
  81666. /**
  81667. * Set the enabled state of this node
  81668. * @param value defines the new enabled state
  81669. */
  81670. setEnabled(value: boolean): void;
  81671. /**
  81672. * Is this node a descendant of the given node?
  81673. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  81674. * @param ancestor defines the parent node to inspect
  81675. * @returns a boolean indicating if this node is a descendant of the given node
  81676. */
  81677. isDescendantOf(ancestor: Node): boolean;
  81678. /** @hidden */
  81679. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  81680. /**
  81681. * Will return all nodes that have this node as ascendant
  81682. * @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
  81683. * @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
  81684. * @return all children nodes of all types
  81685. */
  81686. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  81687. /**
  81688. * Get all child-meshes of this node
  81689. * @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)
  81690. * @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
  81691. * @returns an array of AbstractMesh
  81692. */
  81693. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  81694. /**
  81695. * Get all direct children of this node
  81696. * @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
  81697. * @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)
  81698. * @returns an array of Node
  81699. */
  81700. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  81701. /** @hidden */
  81702. _setReady(state: boolean): void;
  81703. /**
  81704. * Get an animation by name
  81705. * @param name defines the name of the animation to look for
  81706. * @returns null if not found else the requested animation
  81707. */
  81708. getAnimationByName(name: string): Nullable<Animation>;
  81709. /**
  81710. * Creates an animation range for this node
  81711. * @param name defines the name of the range
  81712. * @param from defines the starting key
  81713. * @param to defines the end key
  81714. */
  81715. createAnimationRange(name: string, from: number, to: number): void;
  81716. /**
  81717. * Delete a specific animation range
  81718. * @param name defines the name of the range to delete
  81719. * @param deleteFrames defines if animation frames from the range must be deleted as well
  81720. */
  81721. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81722. /**
  81723. * Get an animation range by name
  81724. * @param name defines the name of the animation range to look for
  81725. * @returns null if not found else the requested animation range
  81726. */
  81727. getAnimationRange(name: string): Nullable<AnimationRange>;
  81728. /**
  81729. * Gets the list of all animation ranges defined on this node
  81730. * @returns an array
  81731. */
  81732. getAnimationRanges(): Nullable<AnimationRange>[];
  81733. /**
  81734. * Will start the animation sequence
  81735. * @param name defines the range frames for animation sequence
  81736. * @param loop defines if the animation should loop (false by default)
  81737. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  81738. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  81739. * @returns the object created for this animation. If range does not exist, it will return null
  81740. */
  81741. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81742. /**
  81743. * Serialize animation ranges into a JSON compatible object
  81744. * @returns serialization object
  81745. */
  81746. serializeAnimationRanges(): any;
  81747. /**
  81748. * Computes the world matrix of the node
  81749. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81750. * @returns the world matrix
  81751. */
  81752. computeWorldMatrix(force?: boolean): Matrix;
  81753. /**
  81754. * Releases resources associated with this node.
  81755. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81756. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81757. */
  81758. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81759. /**
  81760. * Parse animation range data from a serialization object and store them into a given node
  81761. * @param node defines where to store the animation ranges
  81762. * @param parsedNode defines the serialization object to read data from
  81763. * @param scene defines the hosting scene
  81764. */
  81765. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  81766. }
  81767. }
  81768. declare module BABYLON {
  81769. /**
  81770. * Class used to store any kind of animation
  81771. */
  81772. export class Animation {
  81773. /**Name of the animation */
  81774. name: string;
  81775. /**Property to animate */
  81776. targetProperty: string;
  81777. /**The frames per second of the animation */
  81778. framePerSecond: number;
  81779. /**The data type of the animation */
  81780. dataType: number;
  81781. /**The loop mode of the animation */
  81782. loopMode?: number | undefined;
  81783. /**Specifies if blending should be enabled */
  81784. enableBlending?: boolean | undefined;
  81785. /**
  81786. * Use matrix interpolation instead of using direct key value when animating matrices
  81787. */
  81788. static AllowMatricesInterpolation: boolean;
  81789. /**
  81790. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  81791. */
  81792. static AllowMatrixDecomposeForInterpolation: boolean;
  81793. /**
  81794. * Stores the key frames of the animation
  81795. */
  81796. private _keys;
  81797. /**
  81798. * Stores the easing function of the animation
  81799. */
  81800. private _easingFunction;
  81801. /**
  81802. * @hidden Internal use only
  81803. */
  81804. _runtimeAnimations: RuntimeAnimation[];
  81805. /**
  81806. * The set of event that will be linked to this animation
  81807. */
  81808. private _events;
  81809. /**
  81810. * Stores an array of target property paths
  81811. */
  81812. targetPropertyPath: string[];
  81813. /**
  81814. * Stores the blending speed of the animation
  81815. */
  81816. blendingSpeed: number;
  81817. /**
  81818. * Stores the animation ranges for the animation
  81819. */
  81820. private _ranges;
  81821. /**
  81822. * @hidden Internal use
  81823. */
  81824. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  81825. /**
  81826. * Sets up an animation
  81827. * @param property The property to animate
  81828. * @param animationType The animation type to apply
  81829. * @param framePerSecond The frames per second of the animation
  81830. * @param easingFunction The easing function used in the animation
  81831. * @returns The created animation
  81832. */
  81833. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  81834. /**
  81835. * Create and start an animation on a node
  81836. * @param name defines the name of the global animation that will be run on all nodes
  81837. * @param node defines the root node where the animation will take place
  81838. * @param targetProperty defines property to animate
  81839. * @param framePerSecond defines the number of frame per second yo use
  81840. * @param totalFrame defines the number of frames in total
  81841. * @param from defines the initial value
  81842. * @param to defines the final value
  81843. * @param loopMode defines which loop mode you want to use (off by default)
  81844. * @param easingFunction defines the easing function to use (linear by default)
  81845. * @param onAnimationEnd defines the callback to call when animation end
  81846. * @returns the animatable created for this animation
  81847. */
  81848. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  81849. /**
  81850. * Create and start an animation on a node and its descendants
  81851. * @param name defines the name of the global animation that will be run on all nodes
  81852. * @param node defines the root node where the animation will take place
  81853. * @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
  81854. * @param targetProperty defines property to animate
  81855. * @param framePerSecond defines the number of frame per second to use
  81856. * @param totalFrame defines the number of frames in total
  81857. * @param from defines the initial value
  81858. * @param to defines the final value
  81859. * @param loopMode defines which loop mode you want to use (off by default)
  81860. * @param easingFunction defines the easing function to use (linear by default)
  81861. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81862. * @returns the list of animatables created for all nodes
  81863. * @example https://www.babylonjs-playground.com/#MH0VLI
  81864. */
  81865. 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[]>;
  81866. /**
  81867. * Creates a new animation, merges it with the existing animations and starts it
  81868. * @param name Name of the animation
  81869. * @param node Node which contains the scene that begins the animations
  81870. * @param targetProperty Specifies which property to animate
  81871. * @param framePerSecond The frames per second of the animation
  81872. * @param totalFrame The total number of frames
  81873. * @param from The frame at the beginning of the animation
  81874. * @param to The frame at the end of the animation
  81875. * @param loopMode Specifies the loop mode of the animation
  81876. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  81877. * @param onAnimationEnd Callback to run once the animation is complete
  81878. * @returns Nullable animation
  81879. */
  81880. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  81881. /**
  81882. * Transition property of an host to the target Value
  81883. * @param property The property to transition
  81884. * @param targetValue The target Value of the property
  81885. * @param host The object where the property to animate belongs
  81886. * @param scene Scene used to run the animation
  81887. * @param frameRate Framerate (in frame/s) to use
  81888. * @param transition The transition type we want to use
  81889. * @param duration The duration of the animation, in milliseconds
  81890. * @param onAnimationEnd Callback trigger at the end of the animation
  81891. * @returns Nullable animation
  81892. */
  81893. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  81894. /**
  81895. * Return the array of runtime animations currently using this animation
  81896. */
  81897. readonly runtimeAnimations: RuntimeAnimation[];
  81898. /**
  81899. * Specifies if any of the runtime animations are currently running
  81900. */
  81901. readonly hasRunningRuntimeAnimations: boolean;
  81902. /**
  81903. * Initializes the animation
  81904. * @param name Name of the animation
  81905. * @param targetProperty Property to animate
  81906. * @param framePerSecond The frames per second of the animation
  81907. * @param dataType The data type of the animation
  81908. * @param loopMode The loop mode of the animation
  81909. * @param enableBlending Specifies if blending should be enabled
  81910. */
  81911. constructor(
  81912. /**Name of the animation */
  81913. name: string,
  81914. /**Property to animate */
  81915. targetProperty: string,
  81916. /**The frames per second of the animation */
  81917. framePerSecond: number,
  81918. /**The data type of the animation */
  81919. dataType: number,
  81920. /**The loop mode of the animation */
  81921. loopMode?: number | undefined,
  81922. /**Specifies if blending should be enabled */
  81923. enableBlending?: boolean | undefined);
  81924. /**
  81925. * Converts the animation to a string
  81926. * @param fullDetails support for multiple levels of logging within scene loading
  81927. * @returns String form of the animation
  81928. */
  81929. toString(fullDetails?: boolean): string;
  81930. /**
  81931. * Add an event to this animation
  81932. * @param event Event to add
  81933. */
  81934. addEvent(event: AnimationEvent): void;
  81935. /**
  81936. * Remove all events found at the given frame
  81937. * @param frame The frame to remove events from
  81938. */
  81939. removeEvents(frame: number): void;
  81940. /**
  81941. * Retrieves all the events from the animation
  81942. * @returns Events from the animation
  81943. */
  81944. getEvents(): AnimationEvent[];
  81945. /**
  81946. * Creates an animation range
  81947. * @param name Name of the animation range
  81948. * @param from Starting frame of the animation range
  81949. * @param to Ending frame of the animation
  81950. */
  81951. createRange(name: string, from: number, to: number): void;
  81952. /**
  81953. * Deletes an animation range by name
  81954. * @param name Name of the animation range to delete
  81955. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  81956. */
  81957. deleteRange(name: string, deleteFrames?: boolean): void;
  81958. /**
  81959. * Gets the animation range by name, or null if not defined
  81960. * @param name Name of the animation range
  81961. * @returns Nullable animation range
  81962. */
  81963. getRange(name: string): Nullable<AnimationRange>;
  81964. /**
  81965. * Gets the key frames from the animation
  81966. * @returns The key frames of the animation
  81967. */
  81968. getKeys(): Array<IAnimationKey>;
  81969. /**
  81970. * Gets the highest frame rate of the animation
  81971. * @returns Highest frame rate of the animation
  81972. */
  81973. getHighestFrame(): number;
  81974. /**
  81975. * Gets the easing function of the animation
  81976. * @returns Easing function of the animation
  81977. */
  81978. getEasingFunction(): IEasingFunction;
  81979. /**
  81980. * Sets the easing function of the animation
  81981. * @param easingFunction A custom mathematical formula for animation
  81982. */
  81983. setEasingFunction(easingFunction: EasingFunction): void;
  81984. /**
  81985. * Interpolates a scalar linearly
  81986. * @param startValue Start value of the animation curve
  81987. * @param endValue End value of the animation curve
  81988. * @param gradient Scalar amount to interpolate
  81989. * @returns Interpolated scalar value
  81990. */
  81991. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  81992. /**
  81993. * Interpolates a scalar cubically
  81994. * @param startValue Start value of the animation curve
  81995. * @param outTangent End tangent of the animation
  81996. * @param endValue End value of the animation curve
  81997. * @param inTangent Start tangent of the animation curve
  81998. * @param gradient Scalar amount to interpolate
  81999. * @returns Interpolated scalar value
  82000. */
  82001. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  82002. /**
  82003. * Interpolates a quaternion using a spherical linear interpolation
  82004. * @param startValue Start value of the animation curve
  82005. * @param endValue End value of the animation curve
  82006. * @param gradient Scalar amount to interpolate
  82007. * @returns Interpolated quaternion value
  82008. */
  82009. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  82010. /**
  82011. * Interpolates a quaternion cubically
  82012. * @param startValue Start value of the animation curve
  82013. * @param outTangent End tangent of the animation curve
  82014. * @param endValue End value of the animation curve
  82015. * @param inTangent Start tangent of the animation curve
  82016. * @param gradient Scalar amount to interpolate
  82017. * @returns Interpolated quaternion value
  82018. */
  82019. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  82020. /**
  82021. * Interpolates a Vector3 linearl
  82022. * @param startValue Start value of the animation curve
  82023. * @param endValue End value of the animation curve
  82024. * @param gradient Scalar amount to interpolate
  82025. * @returns Interpolated scalar value
  82026. */
  82027. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  82028. /**
  82029. * Interpolates a Vector3 cubically
  82030. * @param startValue Start value of the animation curve
  82031. * @param outTangent End tangent of the animation
  82032. * @param endValue End value of the animation curve
  82033. * @param inTangent Start tangent of the animation curve
  82034. * @param gradient Scalar amount to interpolate
  82035. * @returns InterpolatedVector3 value
  82036. */
  82037. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  82038. /**
  82039. * Interpolates a Vector2 linearly
  82040. * @param startValue Start value of the animation curve
  82041. * @param endValue End value of the animation curve
  82042. * @param gradient Scalar amount to interpolate
  82043. * @returns Interpolated Vector2 value
  82044. */
  82045. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  82046. /**
  82047. * Interpolates a Vector2 cubically
  82048. * @param startValue Start value of the animation curve
  82049. * @param outTangent End tangent of the animation
  82050. * @param endValue End value of the animation curve
  82051. * @param inTangent Start tangent of the animation curve
  82052. * @param gradient Scalar amount to interpolate
  82053. * @returns Interpolated Vector2 value
  82054. */
  82055. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  82056. /**
  82057. * Interpolates a size linearly
  82058. * @param startValue Start value of the animation curve
  82059. * @param endValue End value of the animation curve
  82060. * @param gradient Scalar amount to interpolate
  82061. * @returns Interpolated Size value
  82062. */
  82063. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  82064. /**
  82065. * Interpolates a Color3 linearly
  82066. * @param startValue Start value of the animation curve
  82067. * @param endValue End value of the animation curve
  82068. * @param gradient Scalar amount to interpolate
  82069. * @returns Interpolated Color3 value
  82070. */
  82071. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  82072. /**
  82073. * @hidden Internal use only
  82074. */
  82075. _getKeyValue(value: any): any;
  82076. /**
  82077. * @hidden Internal use only
  82078. */
  82079. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  82080. /**
  82081. * Defines the function to use to interpolate matrices
  82082. * @param startValue defines the start matrix
  82083. * @param endValue defines the end matrix
  82084. * @param gradient defines the gradient between both matrices
  82085. * @param result defines an optional target matrix where to store the interpolation
  82086. * @returns the interpolated matrix
  82087. */
  82088. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  82089. /**
  82090. * Makes a copy of the animation
  82091. * @returns Cloned animation
  82092. */
  82093. clone(): Animation;
  82094. /**
  82095. * Sets the key frames of the animation
  82096. * @param values The animation key frames to set
  82097. */
  82098. setKeys(values: Array<IAnimationKey>): void;
  82099. /**
  82100. * Serializes the animation to an object
  82101. * @returns Serialized object
  82102. */
  82103. serialize(): any;
  82104. /**
  82105. * Float animation type
  82106. */
  82107. private static _ANIMATIONTYPE_FLOAT;
  82108. /**
  82109. * Vector3 animation type
  82110. */
  82111. private static _ANIMATIONTYPE_VECTOR3;
  82112. /**
  82113. * Quaternion animation type
  82114. */
  82115. private static _ANIMATIONTYPE_QUATERNION;
  82116. /**
  82117. * Matrix animation type
  82118. */
  82119. private static _ANIMATIONTYPE_MATRIX;
  82120. /**
  82121. * Color3 animation type
  82122. */
  82123. private static _ANIMATIONTYPE_COLOR3;
  82124. /**
  82125. * Vector2 animation type
  82126. */
  82127. private static _ANIMATIONTYPE_VECTOR2;
  82128. /**
  82129. * Size animation type
  82130. */
  82131. private static _ANIMATIONTYPE_SIZE;
  82132. /**
  82133. * Relative Loop Mode
  82134. */
  82135. private static _ANIMATIONLOOPMODE_RELATIVE;
  82136. /**
  82137. * Cycle Loop Mode
  82138. */
  82139. private static _ANIMATIONLOOPMODE_CYCLE;
  82140. /**
  82141. * Constant Loop Mode
  82142. */
  82143. private static _ANIMATIONLOOPMODE_CONSTANT;
  82144. /**
  82145. * Get the float animation type
  82146. */
  82147. static readonly ANIMATIONTYPE_FLOAT: number;
  82148. /**
  82149. * Get the Vector3 animation type
  82150. */
  82151. static readonly ANIMATIONTYPE_VECTOR3: number;
  82152. /**
  82153. * Get the Vector2 animation type
  82154. */
  82155. static readonly ANIMATIONTYPE_VECTOR2: number;
  82156. /**
  82157. * Get the Size animation type
  82158. */
  82159. static readonly ANIMATIONTYPE_SIZE: number;
  82160. /**
  82161. * Get the Quaternion animation type
  82162. */
  82163. static readonly ANIMATIONTYPE_QUATERNION: number;
  82164. /**
  82165. * Get the Matrix animation type
  82166. */
  82167. static readonly ANIMATIONTYPE_MATRIX: number;
  82168. /**
  82169. * Get the Color3 animation type
  82170. */
  82171. static readonly ANIMATIONTYPE_COLOR3: number;
  82172. /**
  82173. * Get the Relative Loop Mode
  82174. */
  82175. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  82176. /**
  82177. * Get the Cycle Loop Mode
  82178. */
  82179. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  82180. /**
  82181. * Get the Constant Loop Mode
  82182. */
  82183. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  82184. /** @hidden */
  82185. static _UniversalLerp(left: any, right: any, amount: number): any;
  82186. /**
  82187. * Parses an animation object and creates an animation
  82188. * @param parsedAnimation Parsed animation object
  82189. * @returns Animation object
  82190. */
  82191. static Parse(parsedAnimation: any): Animation;
  82192. /**
  82193. * Appends the serialized animations from the source animations
  82194. * @param source Source containing the animations
  82195. * @param destination Target to store the animations
  82196. */
  82197. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  82198. }
  82199. }
  82200. declare module BABYLON {
  82201. /**
  82202. * Base class of all the textures in babylon.
  82203. * It groups all the common properties the materials, post process, lights... might need
  82204. * in order to make a correct use of the texture.
  82205. */
  82206. export class BaseTexture implements IAnimatable {
  82207. /**
  82208. * Default anisotropic filtering level for the application.
  82209. * It is set to 4 as a good tradeoff between perf and quality.
  82210. */
  82211. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  82212. /**
  82213. * Gets or sets the unique id of the texture
  82214. */
  82215. uniqueId: number;
  82216. /**
  82217. * Define the name of the texture.
  82218. */
  82219. name: string;
  82220. /**
  82221. * Gets or sets an object used to store user defined information.
  82222. */
  82223. metadata: any;
  82224. /**
  82225. * For internal use only. Please do not use.
  82226. */
  82227. reservedDataStore: any;
  82228. private _hasAlpha;
  82229. /**
  82230. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  82231. */
  82232. hasAlpha: boolean;
  82233. /**
  82234. * Defines if the alpha value should be determined via the rgb values.
  82235. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  82236. */
  82237. getAlphaFromRGB: boolean;
  82238. /**
  82239. * Intensity or strength of the texture.
  82240. * It is commonly used by materials to fine tune the intensity of the texture
  82241. */
  82242. level: number;
  82243. /**
  82244. * Define the UV chanel to use starting from 0 and defaulting to 0.
  82245. * This is part of the texture as textures usually maps to one uv set.
  82246. */
  82247. coordinatesIndex: number;
  82248. private _coordinatesMode;
  82249. /**
  82250. * How a texture is mapped.
  82251. *
  82252. * | Value | Type | Description |
  82253. * | ----- | ----------------------------------- | ----------- |
  82254. * | 0 | EXPLICIT_MODE | |
  82255. * | 1 | SPHERICAL_MODE | |
  82256. * | 2 | PLANAR_MODE | |
  82257. * | 3 | CUBIC_MODE | |
  82258. * | 4 | PROJECTION_MODE | |
  82259. * | 5 | SKYBOX_MODE | |
  82260. * | 6 | INVCUBIC_MODE | |
  82261. * | 7 | EQUIRECTANGULAR_MODE | |
  82262. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  82263. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  82264. */
  82265. coordinatesMode: number;
  82266. /**
  82267. * | Value | Type | Description |
  82268. * | ----- | ------------------ | ----------- |
  82269. * | 0 | CLAMP_ADDRESSMODE | |
  82270. * | 1 | WRAP_ADDRESSMODE | |
  82271. * | 2 | MIRROR_ADDRESSMODE | |
  82272. */
  82273. wrapU: number;
  82274. /**
  82275. * | Value | Type | Description |
  82276. * | ----- | ------------------ | ----------- |
  82277. * | 0 | CLAMP_ADDRESSMODE | |
  82278. * | 1 | WRAP_ADDRESSMODE | |
  82279. * | 2 | MIRROR_ADDRESSMODE | |
  82280. */
  82281. wrapV: number;
  82282. /**
  82283. * | Value | Type | Description |
  82284. * | ----- | ------------------ | ----------- |
  82285. * | 0 | CLAMP_ADDRESSMODE | |
  82286. * | 1 | WRAP_ADDRESSMODE | |
  82287. * | 2 | MIRROR_ADDRESSMODE | |
  82288. */
  82289. wrapR: number;
  82290. /**
  82291. * With compliant hardware and browser (supporting anisotropic filtering)
  82292. * this defines the level of anisotropic filtering in the texture.
  82293. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  82294. */
  82295. anisotropicFilteringLevel: number;
  82296. /**
  82297. * Define if the texture is a cube texture or if false a 2d texture.
  82298. */
  82299. isCube: boolean;
  82300. /**
  82301. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  82302. */
  82303. is3D: boolean;
  82304. /**
  82305. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  82306. * HDR texture are usually stored in linear space.
  82307. * This only impacts the PBR and Background materials
  82308. */
  82309. gammaSpace: boolean;
  82310. /**
  82311. * Gets whether or not the texture contains RGBD data.
  82312. */
  82313. readonly isRGBD: boolean;
  82314. /**
  82315. * Is Z inverted in the texture (useful in a cube texture).
  82316. */
  82317. invertZ: boolean;
  82318. /**
  82319. * Are mip maps generated for this texture or not.
  82320. */
  82321. readonly noMipmap: boolean;
  82322. /**
  82323. * @hidden
  82324. */
  82325. lodLevelInAlpha: boolean;
  82326. /**
  82327. * With prefiltered texture, defined the offset used during the prefiltering steps.
  82328. */
  82329. lodGenerationOffset: number;
  82330. /**
  82331. * With prefiltered texture, defined the scale used during the prefiltering steps.
  82332. */
  82333. lodGenerationScale: number;
  82334. /**
  82335. * Define if the texture is a render target.
  82336. */
  82337. isRenderTarget: boolean;
  82338. /**
  82339. * Define the unique id of the texture in the scene.
  82340. */
  82341. readonly uid: string;
  82342. /**
  82343. * Return a string representation of the texture.
  82344. * @returns the texture as a string
  82345. */
  82346. toString(): string;
  82347. /**
  82348. * Get the class name of the texture.
  82349. * @returns "BaseTexture"
  82350. */
  82351. getClassName(): string;
  82352. /**
  82353. * Define the list of animation attached to the texture.
  82354. */
  82355. animations: Animation[];
  82356. /**
  82357. * An event triggered when the texture is disposed.
  82358. */
  82359. onDisposeObservable: Observable<BaseTexture>;
  82360. private _onDisposeObserver;
  82361. /**
  82362. * Callback triggered when the texture has been disposed.
  82363. * Kept for back compatibility, you can use the onDisposeObservable instead.
  82364. */
  82365. onDispose: () => void;
  82366. /**
  82367. * Define the current state of the loading sequence when in delayed load mode.
  82368. */
  82369. delayLoadState: number;
  82370. private _scene;
  82371. /** @hidden */
  82372. _texture: Nullable<InternalTexture>;
  82373. private _uid;
  82374. /**
  82375. * Define if the texture is preventinga material to render or not.
  82376. * If not and the texture is not ready, the engine will use a default black texture instead.
  82377. */
  82378. readonly isBlocking: boolean;
  82379. /**
  82380. * Instantiates a new BaseTexture.
  82381. * Base class of all the textures in babylon.
  82382. * It groups all the common properties the materials, post process, lights... might need
  82383. * in order to make a correct use of the texture.
  82384. * @param scene Define the scene the texture blongs to
  82385. */
  82386. constructor(scene: Nullable<Scene>);
  82387. /**
  82388. * Get the scene the texture belongs to.
  82389. * @returns the scene or null if undefined
  82390. */
  82391. getScene(): Nullable<Scene>;
  82392. /**
  82393. * Get the texture transform matrix used to offset tile the texture for istance.
  82394. * @returns the transformation matrix
  82395. */
  82396. getTextureMatrix(): Matrix;
  82397. /**
  82398. * Get the texture reflection matrix used to rotate/transform the reflection.
  82399. * @returns the reflection matrix
  82400. */
  82401. getReflectionTextureMatrix(): Matrix;
  82402. /**
  82403. * Get the underlying lower level texture from Babylon.
  82404. * @returns the insternal texture
  82405. */
  82406. getInternalTexture(): Nullable<InternalTexture>;
  82407. /**
  82408. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  82409. * @returns true if ready or not blocking
  82410. */
  82411. isReadyOrNotBlocking(): boolean;
  82412. /**
  82413. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  82414. * @returns true if fully ready
  82415. */
  82416. isReady(): boolean;
  82417. private _cachedSize;
  82418. /**
  82419. * Get the size of the texture.
  82420. * @returns the texture size.
  82421. */
  82422. getSize(): ISize;
  82423. /**
  82424. * Get the base size of the texture.
  82425. * It can be different from the size if the texture has been resized for POT for instance
  82426. * @returns the base size
  82427. */
  82428. getBaseSize(): ISize;
  82429. /**
  82430. * Update the sampling mode of the texture.
  82431. * Default is Trilinear mode.
  82432. *
  82433. * | Value | Type | Description |
  82434. * | ----- | ------------------ | ----------- |
  82435. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  82436. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  82437. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  82438. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  82439. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  82440. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  82441. * | 7 | NEAREST_LINEAR | |
  82442. * | 8 | NEAREST_NEAREST | |
  82443. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  82444. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  82445. * | 11 | LINEAR_LINEAR | |
  82446. * | 12 | LINEAR_NEAREST | |
  82447. *
  82448. * > _mag_: magnification filter (close to the viewer)
  82449. * > _min_: minification filter (far from the viewer)
  82450. * > _mip_: filter used between mip map levels
  82451. *@param samplingMode Define the new sampling mode of the texture
  82452. */
  82453. updateSamplingMode(samplingMode: number): void;
  82454. /**
  82455. * Scales the texture if is `canRescale()`
  82456. * @param ratio the resize factor we want to use to rescale
  82457. */
  82458. scale(ratio: number): void;
  82459. /**
  82460. * Get if the texture can rescale.
  82461. */
  82462. readonly canRescale: boolean;
  82463. /** @hidden */
  82464. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  82465. /** @hidden */
  82466. _rebuild(): void;
  82467. /**
  82468. * Triggers the load sequence in delayed load mode.
  82469. */
  82470. delayLoad(): void;
  82471. /**
  82472. * Clones the texture.
  82473. * @returns the cloned texture
  82474. */
  82475. clone(): Nullable<BaseTexture>;
  82476. /**
  82477. * Get the texture underlying type (INT, FLOAT...)
  82478. */
  82479. readonly textureType: number;
  82480. /**
  82481. * Get the texture underlying format (RGB, RGBA...)
  82482. */
  82483. readonly textureFormat: number;
  82484. /**
  82485. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  82486. * This will returns an RGBA array buffer containing either in values (0-255) or
  82487. * float values (0-1) depending of the underlying buffer type.
  82488. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  82489. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  82490. * @param buffer defines a user defined buffer to fill with data (can be null)
  82491. * @returns The Array buffer containing the pixels data.
  82492. */
  82493. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  82494. /**
  82495. * Release and destroy the underlying lower level texture aka internalTexture.
  82496. */
  82497. releaseInternalTexture(): void;
  82498. /**
  82499. * Get the polynomial representation of the texture data.
  82500. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  82501. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  82502. */
  82503. sphericalPolynomial: Nullable<SphericalPolynomial>;
  82504. /** @hidden */
  82505. readonly _lodTextureHigh: Nullable<BaseTexture>;
  82506. /** @hidden */
  82507. readonly _lodTextureMid: Nullable<BaseTexture>;
  82508. /** @hidden */
  82509. readonly _lodTextureLow: Nullable<BaseTexture>;
  82510. /**
  82511. * Dispose the texture and release its associated resources.
  82512. */
  82513. dispose(): void;
  82514. /**
  82515. * Serialize the texture into a JSON representation that can be parsed later on.
  82516. * @returns the JSON representation of the texture
  82517. */
  82518. serialize(): any;
  82519. /**
  82520. * Helper function to be called back once a list of texture contains only ready textures.
  82521. * @param textures Define the list of textures to wait for
  82522. * @param callback Define the callback triggered once the entire list will be ready
  82523. */
  82524. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  82525. }
  82526. }
  82527. declare module BABYLON {
  82528. /**
  82529. * Uniform buffer objects.
  82530. *
  82531. * Handles blocks of uniform on the GPU.
  82532. *
  82533. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82534. *
  82535. * For more information, please refer to :
  82536. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82537. */
  82538. export class UniformBuffer {
  82539. private _engine;
  82540. private _buffer;
  82541. private _data;
  82542. private _bufferData;
  82543. private _dynamic?;
  82544. private _uniformLocations;
  82545. private _uniformSizes;
  82546. private _uniformLocationPointer;
  82547. private _needSync;
  82548. private _noUBO;
  82549. private _currentEffect;
  82550. private static _MAX_UNIFORM_SIZE;
  82551. private static _tempBuffer;
  82552. /**
  82553. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  82554. * This is dynamic to allow compat with webgl 1 and 2.
  82555. * You will need to pass the name of the uniform as well as the value.
  82556. */
  82557. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  82558. /**
  82559. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  82560. * This is dynamic to allow compat with webgl 1 and 2.
  82561. * You will need to pass the name of the uniform as well as the value.
  82562. */
  82563. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  82564. /**
  82565. * Lambda to Update a single float in a uniform buffer.
  82566. * This is dynamic to allow compat with webgl 1 and 2.
  82567. * You will need to pass the name of the uniform as well as the value.
  82568. */
  82569. updateFloat: (name: string, x: number) => void;
  82570. /**
  82571. * Lambda to Update a vec2 of float in a uniform buffer.
  82572. * This is dynamic to allow compat with webgl 1 and 2.
  82573. * You will need to pass the name of the uniform as well as the value.
  82574. */
  82575. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  82576. /**
  82577. * Lambda to Update a vec3 of float in a uniform buffer.
  82578. * This is dynamic to allow compat with webgl 1 and 2.
  82579. * You will need to pass the name of the uniform as well as the value.
  82580. */
  82581. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  82582. /**
  82583. * Lambda to Update a vec4 of float in a uniform buffer.
  82584. * This is dynamic to allow compat with webgl 1 and 2.
  82585. * You will need to pass the name of the uniform as well as the value.
  82586. */
  82587. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  82588. /**
  82589. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  82590. * This is dynamic to allow compat with webgl 1 and 2.
  82591. * You will need to pass the name of the uniform as well as the value.
  82592. */
  82593. updateMatrix: (name: string, mat: Matrix) => void;
  82594. /**
  82595. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  82596. * This is dynamic to allow compat with webgl 1 and 2.
  82597. * You will need to pass the name of the uniform as well as the value.
  82598. */
  82599. updateVector3: (name: string, vector: Vector3) => void;
  82600. /**
  82601. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  82602. * This is dynamic to allow compat with webgl 1 and 2.
  82603. * You will need to pass the name of the uniform as well as the value.
  82604. */
  82605. updateVector4: (name: string, vector: Vector4) => void;
  82606. /**
  82607. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  82608. * This is dynamic to allow compat with webgl 1 and 2.
  82609. * You will need to pass the name of the uniform as well as the value.
  82610. */
  82611. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  82612. /**
  82613. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  82614. * This is dynamic to allow compat with webgl 1 and 2.
  82615. * You will need to pass the name of the uniform as well as the value.
  82616. */
  82617. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  82618. /**
  82619. * Instantiates a new Uniform buffer objects.
  82620. *
  82621. * Handles blocks of uniform on the GPU.
  82622. *
  82623. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82624. *
  82625. * For more information, please refer to :
  82626. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82627. * @param engine Define the engine the buffer is associated with
  82628. * @param data Define the data contained in the buffer
  82629. * @param dynamic Define if the buffer is updatable
  82630. */
  82631. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  82632. /**
  82633. * Indicates if the buffer is using the WebGL2 UBO implementation,
  82634. * or just falling back on setUniformXXX calls.
  82635. */
  82636. readonly useUbo: boolean;
  82637. /**
  82638. * Indicates if the WebGL underlying uniform buffer is in sync
  82639. * with the javascript cache data.
  82640. */
  82641. readonly isSync: boolean;
  82642. /**
  82643. * Indicates if the WebGL underlying uniform buffer is dynamic.
  82644. * Also, a dynamic UniformBuffer will disable cache verification and always
  82645. * update the underlying WebGL uniform buffer to the GPU.
  82646. * @returns if Dynamic, otherwise false
  82647. */
  82648. isDynamic(): boolean;
  82649. /**
  82650. * The data cache on JS side.
  82651. * @returns the underlying data as a float array
  82652. */
  82653. getData(): Float32Array;
  82654. /**
  82655. * The underlying WebGL Uniform buffer.
  82656. * @returns the webgl buffer
  82657. */
  82658. getBuffer(): Nullable<WebGLBuffer>;
  82659. /**
  82660. * std140 layout specifies how to align data within an UBO structure.
  82661. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  82662. * for specs.
  82663. */
  82664. private _fillAlignment;
  82665. /**
  82666. * Adds an uniform in the buffer.
  82667. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  82668. * for the layout to be correct !
  82669. * @param name Name of the uniform, as used in the uniform block in the shader.
  82670. * @param size Data size, or data directly.
  82671. */
  82672. addUniform(name: string, size: number | number[]): void;
  82673. /**
  82674. * Adds a Matrix 4x4 to the uniform buffer.
  82675. * @param name Name of the uniform, as used in the uniform block in the shader.
  82676. * @param mat A 4x4 matrix.
  82677. */
  82678. addMatrix(name: string, mat: Matrix): void;
  82679. /**
  82680. * Adds a vec2 to the uniform buffer.
  82681. * @param name Name of the uniform, as used in the uniform block in the shader.
  82682. * @param x Define the x component value of the vec2
  82683. * @param y Define the y component value of the vec2
  82684. */
  82685. addFloat2(name: string, x: number, y: number): void;
  82686. /**
  82687. * Adds a vec3 to the uniform buffer.
  82688. * @param name Name of the uniform, as used in the uniform block in the shader.
  82689. * @param x Define the x component value of the vec3
  82690. * @param y Define the y component value of the vec3
  82691. * @param z Define the z component value of the vec3
  82692. */
  82693. addFloat3(name: string, x: number, y: number, z: number): void;
  82694. /**
  82695. * Adds a vec3 to the uniform buffer.
  82696. * @param name Name of the uniform, as used in the uniform block in the shader.
  82697. * @param color Define the vec3 from a Color
  82698. */
  82699. addColor3(name: string, color: Color3): void;
  82700. /**
  82701. * Adds a vec4 to the uniform buffer.
  82702. * @param name Name of the uniform, as used in the uniform block in the shader.
  82703. * @param color Define the rgb components from a Color
  82704. * @param alpha Define the a component of the vec4
  82705. */
  82706. addColor4(name: string, color: Color3, alpha: number): void;
  82707. /**
  82708. * Adds a vec3 to the uniform buffer.
  82709. * @param name Name of the uniform, as used in the uniform block in the shader.
  82710. * @param vector Define the vec3 components from a Vector
  82711. */
  82712. addVector3(name: string, vector: Vector3): void;
  82713. /**
  82714. * Adds a Matrix 3x3 to the uniform buffer.
  82715. * @param name Name of the uniform, as used in the uniform block in the shader.
  82716. */
  82717. addMatrix3x3(name: string): void;
  82718. /**
  82719. * Adds a Matrix 2x2 to the uniform buffer.
  82720. * @param name Name of the uniform, as used in the uniform block in the shader.
  82721. */
  82722. addMatrix2x2(name: string): void;
  82723. /**
  82724. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  82725. */
  82726. create(): void;
  82727. /** @hidden */
  82728. _rebuild(): void;
  82729. /**
  82730. * Updates the WebGL Uniform Buffer on the GPU.
  82731. * If the `dynamic` flag is set to true, no cache comparison is done.
  82732. * Otherwise, the buffer will be updated only if the cache differs.
  82733. */
  82734. update(): void;
  82735. /**
  82736. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  82737. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82738. * @param data Define the flattened data
  82739. * @param size Define the size of the data.
  82740. */
  82741. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  82742. private _updateMatrix3x3ForUniform;
  82743. private _updateMatrix3x3ForEffect;
  82744. private _updateMatrix2x2ForEffect;
  82745. private _updateMatrix2x2ForUniform;
  82746. private _updateFloatForEffect;
  82747. private _updateFloatForUniform;
  82748. private _updateFloat2ForEffect;
  82749. private _updateFloat2ForUniform;
  82750. private _updateFloat3ForEffect;
  82751. private _updateFloat3ForUniform;
  82752. private _updateFloat4ForEffect;
  82753. private _updateFloat4ForUniform;
  82754. private _updateMatrixForEffect;
  82755. private _updateMatrixForUniform;
  82756. private _updateVector3ForEffect;
  82757. private _updateVector3ForUniform;
  82758. private _updateVector4ForEffect;
  82759. private _updateVector4ForUniform;
  82760. private _updateColor3ForEffect;
  82761. private _updateColor3ForUniform;
  82762. private _updateColor4ForEffect;
  82763. private _updateColor4ForUniform;
  82764. /**
  82765. * Sets a sampler uniform on the effect.
  82766. * @param name Define the name of the sampler.
  82767. * @param texture Define the texture to set in the sampler
  82768. */
  82769. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  82770. /**
  82771. * Directly updates the value of the uniform in the cache AND on the GPU.
  82772. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82773. * @param data Define the flattened data
  82774. */
  82775. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  82776. /**
  82777. * Binds this uniform buffer to an effect.
  82778. * @param effect Define the effect to bind the buffer to
  82779. * @param name Name of the uniform block in the shader.
  82780. */
  82781. bindToEffect(effect: Effect, name: string): void;
  82782. /**
  82783. * Disposes the uniform buffer.
  82784. */
  82785. dispose(): void;
  82786. }
  82787. }
  82788. declare module BABYLON {
  82789. /**
  82790. * This represents the required contract to create a new type of texture loader.
  82791. */
  82792. export interface IInternalTextureLoader {
  82793. /**
  82794. * Defines wether the loader supports cascade loading the different faces.
  82795. */
  82796. supportCascades: boolean;
  82797. /**
  82798. * This returns if the loader support the current file information.
  82799. * @param extension defines the file extension of the file being loaded
  82800. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82801. * @param fallback defines the fallback internal texture if any
  82802. * @param isBase64 defines whether the texture is encoded as a base64
  82803. * @param isBuffer defines whether the texture data are stored as a buffer
  82804. * @returns true if the loader can load the specified file
  82805. */
  82806. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  82807. /**
  82808. * Transform the url before loading if required.
  82809. * @param rootUrl the url of the texture
  82810. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82811. * @returns the transformed texture
  82812. */
  82813. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  82814. /**
  82815. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  82816. * @param rootUrl the url of the texture
  82817. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82818. * @returns the fallback texture
  82819. */
  82820. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  82821. /**
  82822. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  82823. * @param data contains the texture data
  82824. * @param texture defines the BabylonJS internal texture
  82825. * @param createPolynomials will be true if polynomials have been requested
  82826. * @param onLoad defines the callback to trigger once the texture is ready
  82827. * @param onError defines the callback to trigger in case of error
  82828. */
  82829. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  82830. /**
  82831. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  82832. * @param data contains the texture data
  82833. * @param texture defines the BabylonJS internal texture
  82834. * @param callback defines the method to call once ready to upload
  82835. */
  82836. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  82837. }
  82838. }
  82839. declare module BABYLON {
  82840. /**
  82841. * Creation options of the multi render target texture.
  82842. */
  82843. export interface IMultiRenderTargetOptions {
  82844. /**
  82845. * Define if the texture needs to create mip maps after render.
  82846. */
  82847. generateMipMaps?: boolean;
  82848. /**
  82849. * Define the types of all the draw buffers we want to create
  82850. */
  82851. types?: number[];
  82852. /**
  82853. * Define the sampling modes of all the draw buffers we want to create
  82854. */
  82855. samplingModes?: number[];
  82856. /**
  82857. * Define if a depth buffer is required
  82858. */
  82859. generateDepthBuffer?: boolean;
  82860. /**
  82861. * Define if a stencil buffer is required
  82862. */
  82863. generateStencilBuffer?: boolean;
  82864. /**
  82865. * Define if a depth texture is required instead of a depth buffer
  82866. */
  82867. generateDepthTexture?: boolean;
  82868. /**
  82869. * Define the number of desired draw buffers
  82870. */
  82871. textureCount?: number;
  82872. /**
  82873. * Define if aspect ratio should be adapted to the texture or stay the scene one
  82874. */
  82875. doNotChangeAspectRatio?: boolean;
  82876. /**
  82877. * Define the default type of the buffers we are creating
  82878. */
  82879. defaultType?: number;
  82880. }
  82881. /**
  82882. * A multi render target, like a render target provides the ability to render to a texture.
  82883. * Unlike the render target, it can render to several draw buffers in one draw.
  82884. * This is specially interesting in deferred rendering or for any effects requiring more than
  82885. * just one color from a single pass.
  82886. */
  82887. export class MultiRenderTarget extends RenderTargetTexture {
  82888. private _internalTextures;
  82889. private _textures;
  82890. private _multiRenderTargetOptions;
  82891. /**
  82892. * Get if draw buffers are currently supported by the used hardware and browser.
  82893. */
  82894. readonly isSupported: boolean;
  82895. /**
  82896. * Get the list of textures generated by the multi render target.
  82897. */
  82898. readonly textures: Texture[];
  82899. /**
  82900. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  82901. */
  82902. readonly depthTexture: Texture;
  82903. /**
  82904. * Set the wrapping mode on U of all the textures we are rendering to.
  82905. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  82906. */
  82907. wrapU: number;
  82908. /**
  82909. * Set the wrapping mode on V of all the textures we are rendering to.
  82910. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  82911. */
  82912. wrapV: number;
  82913. /**
  82914. * Instantiate a new multi render target texture.
  82915. * A multi render target, like a render target provides the ability to render to a texture.
  82916. * Unlike the render target, it can render to several draw buffers in one draw.
  82917. * This is specially interesting in deferred rendering or for any effects requiring more than
  82918. * just one color from a single pass.
  82919. * @param name Define the name of the texture
  82920. * @param size Define the size of the buffers to render to
  82921. * @param count Define the number of target we are rendering into
  82922. * @param scene Define the scene the texture belongs to
  82923. * @param options Define the options used to create the multi render target
  82924. */
  82925. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  82926. /** @hidden */
  82927. _rebuild(): void;
  82928. private _createInternalTextures;
  82929. private _createTextures;
  82930. /**
  82931. * Define the number of samples used if MSAA is enabled.
  82932. */
  82933. samples: number;
  82934. /**
  82935. * Resize all the textures in the multi render target.
  82936. * Be carrefull as it will recreate all the data in the new texture.
  82937. * @param size Define the new size
  82938. */
  82939. resize(size: any): void;
  82940. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  82941. /**
  82942. * Dispose the render targets and their associated resources
  82943. */
  82944. dispose(): void;
  82945. /**
  82946. * Release all the underlying texture used as draw buffers.
  82947. */
  82948. releaseInternalTextures(): void;
  82949. }
  82950. }
  82951. declare module BABYLON {
  82952. /**
  82953. * Class used to work with sound analyzer using fast fourier transform (FFT)
  82954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82955. */
  82956. export class Analyser {
  82957. /**
  82958. * Gets or sets the smoothing
  82959. * @ignorenaming
  82960. */
  82961. SMOOTHING: number;
  82962. /**
  82963. * Gets or sets the FFT table size
  82964. * @ignorenaming
  82965. */
  82966. FFT_SIZE: number;
  82967. /**
  82968. * Gets or sets the bar graph amplitude
  82969. * @ignorenaming
  82970. */
  82971. BARGRAPHAMPLITUDE: number;
  82972. /**
  82973. * Gets or sets the position of the debug canvas
  82974. * @ignorenaming
  82975. */
  82976. DEBUGCANVASPOS: {
  82977. x: number;
  82978. y: number;
  82979. };
  82980. /**
  82981. * Gets or sets the debug canvas size
  82982. * @ignorenaming
  82983. */
  82984. DEBUGCANVASSIZE: {
  82985. width: number;
  82986. height: number;
  82987. };
  82988. private _byteFreqs;
  82989. private _byteTime;
  82990. private _floatFreqs;
  82991. private _webAudioAnalyser;
  82992. private _debugCanvas;
  82993. private _debugCanvasContext;
  82994. private _scene;
  82995. private _registerFunc;
  82996. private _audioEngine;
  82997. /**
  82998. * Creates a new analyser
  82999. * @param scene defines hosting scene
  83000. */
  83001. constructor(scene: Scene);
  83002. /**
  83003. * Get the number of data values you will have to play with for the visualization
  83004. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  83005. * @returns a number
  83006. */
  83007. getFrequencyBinCount(): number;
  83008. /**
  83009. * Gets the current frequency data as a byte array
  83010. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83011. * @returns a Uint8Array
  83012. */
  83013. getByteFrequencyData(): Uint8Array;
  83014. /**
  83015. * Gets the current waveform as a byte array
  83016. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  83017. * @returns a Uint8Array
  83018. */
  83019. getByteTimeDomainData(): Uint8Array;
  83020. /**
  83021. * Gets the current frequency data as a float array
  83022. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83023. * @returns a Float32Array
  83024. */
  83025. getFloatFrequencyData(): Float32Array;
  83026. /**
  83027. * Renders the debug canvas
  83028. */
  83029. drawDebugCanvas(): void;
  83030. /**
  83031. * Stops rendering the debug canvas and removes it
  83032. */
  83033. stopDebugCanvas(): void;
  83034. /**
  83035. * Connects two audio nodes
  83036. * @param inputAudioNode defines first node to connect
  83037. * @param outputAudioNode defines second node to connect
  83038. */
  83039. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  83040. /**
  83041. * Releases all associated resources
  83042. */
  83043. dispose(): void;
  83044. }
  83045. }
  83046. declare module BABYLON {
  83047. /**
  83048. * This represents an audio engine and it is responsible
  83049. * to play, synchronize and analyse sounds throughout the application.
  83050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83051. */
  83052. export interface IAudioEngine extends IDisposable {
  83053. /**
  83054. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83055. */
  83056. readonly canUseWebAudio: boolean;
  83057. /**
  83058. * Gets the current AudioContext if available.
  83059. */
  83060. readonly audioContext: Nullable<AudioContext>;
  83061. /**
  83062. * The master gain node defines the global audio volume of your audio engine.
  83063. */
  83064. readonly masterGain: GainNode;
  83065. /**
  83066. * Gets whether or not mp3 are supported by your browser.
  83067. */
  83068. readonly isMP3supported: boolean;
  83069. /**
  83070. * Gets whether or not ogg are supported by your browser.
  83071. */
  83072. readonly isOGGsupported: boolean;
  83073. /**
  83074. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83075. * @ignoreNaming
  83076. */
  83077. WarnedWebAudioUnsupported: boolean;
  83078. /**
  83079. * Defines if the audio engine relies on a custom unlocked button.
  83080. * In this case, the embedded button will not be displayed.
  83081. */
  83082. useCustomUnlockedButton: boolean;
  83083. /**
  83084. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  83085. */
  83086. readonly unlocked: boolean;
  83087. /**
  83088. * Event raised when audio has been unlocked on the browser.
  83089. */
  83090. onAudioUnlockedObservable: Observable<AudioEngine>;
  83091. /**
  83092. * Event raised when audio has been locked on the browser.
  83093. */
  83094. onAudioLockedObservable: Observable<AudioEngine>;
  83095. /**
  83096. * Flags the audio engine in Locked state.
  83097. * This happens due to new browser policies preventing audio to autoplay.
  83098. */
  83099. lock(): void;
  83100. /**
  83101. * Unlocks the audio engine once a user action has been done on the dom.
  83102. * This is helpful to resume play once browser policies have been satisfied.
  83103. */
  83104. unlock(): void;
  83105. }
  83106. /**
  83107. * This represents the default audio engine used in babylon.
  83108. * It is responsible to play, synchronize and analyse sounds throughout the application.
  83109. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83110. */
  83111. export class AudioEngine implements IAudioEngine {
  83112. private _audioContext;
  83113. private _audioContextInitialized;
  83114. private _muteButton;
  83115. private _hostElement;
  83116. /**
  83117. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83118. */
  83119. canUseWebAudio: boolean;
  83120. /**
  83121. * The master gain node defines the global audio volume of your audio engine.
  83122. */
  83123. masterGain: GainNode;
  83124. /**
  83125. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83126. * @ignoreNaming
  83127. */
  83128. WarnedWebAudioUnsupported: boolean;
  83129. /**
  83130. * Gets whether or not mp3 are supported by your browser.
  83131. */
  83132. isMP3supported: boolean;
  83133. /**
  83134. * Gets whether or not ogg are supported by your browser.
  83135. */
  83136. isOGGsupported: boolean;
  83137. /**
  83138. * Gets whether audio has been unlocked on the device.
  83139. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  83140. * a user interaction has happened.
  83141. */
  83142. unlocked: boolean;
  83143. /**
  83144. * Defines if the audio engine relies on a custom unlocked button.
  83145. * In this case, the embedded button will not be displayed.
  83146. */
  83147. useCustomUnlockedButton: boolean;
  83148. /**
  83149. * Event raised when audio has been unlocked on the browser.
  83150. */
  83151. onAudioUnlockedObservable: Observable<AudioEngine>;
  83152. /**
  83153. * Event raised when audio has been locked on the browser.
  83154. */
  83155. onAudioLockedObservable: Observable<AudioEngine>;
  83156. /**
  83157. * Gets the current AudioContext if available.
  83158. */
  83159. readonly audioContext: Nullable<AudioContext>;
  83160. private _connectedAnalyser;
  83161. /**
  83162. * Instantiates a new audio engine.
  83163. *
  83164. * There should be only one per page as some browsers restrict the number
  83165. * of audio contexts you can create.
  83166. * @param hostElement defines the host element where to display the mute icon if necessary
  83167. */
  83168. constructor(hostElement?: Nullable<HTMLElement>);
  83169. /**
  83170. * Flags the audio engine in Locked state.
  83171. * This happens due to new browser policies preventing audio to autoplay.
  83172. */
  83173. lock(): void;
  83174. /**
  83175. * Unlocks the audio engine once a user action has been done on the dom.
  83176. * This is helpful to resume play once browser policies have been satisfied.
  83177. */
  83178. unlock(): void;
  83179. private _resumeAudioContext;
  83180. private _initializeAudioContext;
  83181. private _tryToRun;
  83182. private _triggerRunningState;
  83183. private _triggerSuspendedState;
  83184. private _displayMuteButton;
  83185. private _moveButtonToTopLeft;
  83186. private _onResize;
  83187. private _hideMuteButton;
  83188. /**
  83189. * Destroy and release the resources associated with the audio ccontext.
  83190. */
  83191. dispose(): void;
  83192. /**
  83193. * Gets the global volume sets on the master gain.
  83194. * @returns the global volume if set or -1 otherwise
  83195. */
  83196. getGlobalVolume(): number;
  83197. /**
  83198. * Sets the global volume of your experience (sets on the master gain).
  83199. * @param newVolume Defines the new global volume of the application
  83200. */
  83201. setGlobalVolume(newVolume: number): void;
  83202. /**
  83203. * Connect the audio engine to an audio analyser allowing some amazing
  83204. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  83205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  83206. * @param analyser The analyser to connect to the engine
  83207. */
  83208. connectToAnalyser(analyser: Analyser): void;
  83209. }
  83210. }
  83211. declare module BABYLON {
  83212. /**
  83213. * Interface used to present a loading screen while loading a scene
  83214. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83215. */
  83216. export interface ILoadingScreen {
  83217. /**
  83218. * Function called to display the loading screen
  83219. */
  83220. displayLoadingUI: () => void;
  83221. /**
  83222. * Function called to hide the loading screen
  83223. */
  83224. hideLoadingUI: () => void;
  83225. /**
  83226. * Gets or sets the color to use for the background
  83227. */
  83228. loadingUIBackgroundColor: string;
  83229. /**
  83230. * Gets or sets the text to display while loading
  83231. */
  83232. loadingUIText: string;
  83233. }
  83234. /**
  83235. * Class used for the default loading screen
  83236. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83237. */
  83238. export class DefaultLoadingScreen implements ILoadingScreen {
  83239. private _renderingCanvas;
  83240. private _loadingText;
  83241. private _loadingDivBackgroundColor;
  83242. private _loadingDiv;
  83243. private _loadingTextDiv;
  83244. /**
  83245. * Creates a new default loading screen
  83246. * @param _renderingCanvas defines the canvas used to render the scene
  83247. * @param _loadingText defines the default text to display
  83248. * @param _loadingDivBackgroundColor defines the default background color
  83249. */
  83250. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  83251. /**
  83252. * Function called to display the loading screen
  83253. */
  83254. displayLoadingUI(): void;
  83255. /**
  83256. * Function called to hide the loading screen
  83257. */
  83258. hideLoadingUI(): void;
  83259. /**
  83260. * Gets or sets the text to display while loading
  83261. */
  83262. loadingUIText: string;
  83263. /**
  83264. * Gets or sets the color to use for the background
  83265. */
  83266. loadingUIBackgroundColor: string;
  83267. private _resizeLoadingUI;
  83268. }
  83269. }
  83270. declare module BABYLON {
  83271. /**
  83272. * Settings for finer control over video usage
  83273. */
  83274. export interface VideoTextureSettings {
  83275. /**
  83276. * Applies `autoplay` to video, if specified
  83277. */
  83278. autoPlay?: boolean;
  83279. /**
  83280. * Applies `loop` to video, if specified
  83281. */
  83282. loop?: boolean;
  83283. /**
  83284. * Automatically updates internal texture from video at every frame in the render loop
  83285. */
  83286. autoUpdateTexture: boolean;
  83287. /**
  83288. * Image src displayed during the video loading or until the user interacts with the video.
  83289. */
  83290. poster?: string;
  83291. }
  83292. /**
  83293. * If you want to display a video in your scene, this is the special texture for that.
  83294. * This special texture works similar to other textures, with the exception of a few parameters.
  83295. * @see https://doc.babylonjs.com/how_to/video_texture
  83296. */
  83297. export class VideoTexture extends Texture {
  83298. /**
  83299. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  83300. */
  83301. readonly autoUpdateTexture: boolean;
  83302. /**
  83303. * The video instance used by the texture internally
  83304. */
  83305. readonly video: HTMLVideoElement;
  83306. private _onUserActionRequestedObservable;
  83307. /**
  83308. * Event triggerd when a dom action is required by the user to play the video.
  83309. * This happens due to recent changes in browser policies preventing video to auto start.
  83310. */
  83311. readonly onUserActionRequestedObservable: Observable<Texture>;
  83312. private _generateMipMaps;
  83313. private _engine;
  83314. private _stillImageCaptured;
  83315. private _displayingPosterTexture;
  83316. private _settings;
  83317. private _createInternalTextureOnEvent;
  83318. /**
  83319. * Creates a video texture.
  83320. * If you want to display a video in your scene, this is the special texture for that.
  83321. * This special texture works similar to other textures, with the exception of a few parameters.
  83322. * @see https://doc.babylonjs.com/how_to/video_texture
  83323. * @param name optional name, will detect from video source, if not defined
  83324. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  83325. * @param scene is obviously the current scene.
  83326. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  83327. * @param invertY is false by default but can be used to invert video on Y axis
  83328. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  83329. * @param settings allows finer control over video usage
  83330. */
  83331. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  83332. private _getName;
  83333. private _getVideo;
  83334. private _createInternalTexture;
  83335. private reset;
  83336. /**
  83337. * @hidden Internal method to initiate `update`.
  83338. */
  83339. _rebuild(): void;
  83340. /**
  83341. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  83342. */
  83343. update(): void;
  83344. /**
  83345. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  83346. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  83347. */
  83348. updateTexture(isVisible: boolean): void;
  83349. protected _updateInternalTexture: () => void;
  83350. /**
  83351. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  83352. * @param url New url.
  83353. */
  83354. updateURL(url: string): void;
  83355. /**
  83356. * Dispose the texture and release its associated resources.
  83357. */
  83358. dispose(): void;
  83359. /**
  83360. * Creates a video texture straight from a stream.
  83361. * @param scene Define the scene the texture should be created in
  83362. * @param stream Define the stream the texture should be created from
  83363. * @returns The created video texture as a promise
  83364. */
  83365. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  83366. /**
  83367. * Creates a video texture straight from your WebCam video feed.
  83368. * @param scene Define the scene the texture should be created in
  83369. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83370. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83371. * @returns The created video texture as a promise
  83372. */
  83373. static CreateFromWebCamAsync(scene: Scene, constraints: {
  83374. minWidth: number;
  83375. maxWidth: number;
  83376. minHeight: number;
  83377. maxHeight: number;
  83378. deviceId: string;
  83379. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  83380. /**
  83381. * Creates a video texture straight from your WebCam video feed.
  83382. * @param scene Define the scene the texture should be created in
  83383. * @param onReady Define a callback to triggered once the texture will be ready
  83384. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83385. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83386. */
  83387. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  83388. minWidth: number;
  83389. maxWidth: number;
  83390. minHeight: number;
  83391. maxHeight: number;
  83392. deviceId: string;
  83393. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  83394. }
  83395. }
  83396. declare module BABYLON {
  83397. /**
  83398. * Interface for attribute information associated with buffer instanciation
  83399. */
  83400. export class InstancingAttributeInfo {
  83401. /**
  83402. * Index/offset of the attribute in the vertex shader
  83403. */
  83404. index: number;
  83405. /**
  83406. * size of the attribute, 1, 2, 3 or 4
  83407. */
  83408. attributeSize: number;
  83409. /**
  83410. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  83411. * default is FLOAT
  83412. */
  83413. attribyteType: number;
  83414. /**
  83415. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  83416. */
  83417. normalized: boolean;
  83418. /**
  83419. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  83420. */
  83421. offset: number;
  83422. /**
  83423. * Name of the GLSL attribute, for debugging purpose only
  83424. */
  83425. attributeName: string;
  83426. }
  83427. /**
  83428. * Define options used to create a depth texture
  83429. */
  83430. export class DepthTextureCreationOptions {
  83431. /** Specifies whether or not a stencil should be allocated in the texture */
  83432. generateStencil?: boolean;
  83433. /** Specifies whether or not bilinear filtering is enable on the texture */
  83434. bilinearFiltering?: boolean;
  83435. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83436. comparisonFunction?: number;
  83437. /** Specifies if the created texture is a cube texture */
  83438. isCube?: boolean;
  83439. }
  83440. /**
  83441. * Class used to describe the capabilities of the engine relatively to the current browser
  83442. */
  83443. export class EngineCapabilities {
  83444. /** Maximum textures units per fragment shader */
  83445. maxTexturesImageUnits: number;
  83446. /** Maximum texture units per vertex shader */
  83447. maxVertexTextureImageUnits: number;
  83448. /** Maximum textures units in the entire pipeline */
  83449. maxCombinedTexturesImageUnits: number;
  83450. /** Maximum texture size */
  83451. maxTextureSize: number;
  83452. /** Maximum cube texture size */
  83453. maxCubemapTextureSize: number;
  83454. /** Maximum render texture size */
  83455. maxRenderTextureSize: number;
  83456. /** Maximum number of vertex attributes */
  83457. maxVertexAttribs: number;
  83458. /** Maximum number of varyings */
  83459. maxVaryingVectors: number;
  83460. /** Maximum number of uniforms per vertex shader */
  83461. maxVertexUniformVectors: number;
  83462. /** Maximum number of uniforms per fragment shader */
  83463. maxFragmentUniformVectors: number;
  83464. /** Defines if standard derivates (dx/dy) are supported */
  83465. standardDerivatives: boolean;
  83466. /** Defines if s3tc texture compression is supported */
  83467. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  83468. /** Defines if pvrtc texture compression is supported */
  83469. pvrtc: any;
  83470. /** Defines if etc1 texture compression is supported */
  83471. etc1: any;
  83472. /** Defines if etc2 texture compression is supported */
  83473. etc2: any;
  83474. /** Defines if astc texture compression is supported */
  83475. astc: any;
  83476. /** Defines if float textures are supported */
  83477. textureFloat: boolean;
  83478. /** Defines if vertex array objects are supported */
  83479. vertexArrayObject: boolean;
  83480. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  83481. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  83482. /** Gets the maximum level of anisotropy supported */
  83483. maxAnisotropy: number;
  83484. /** Defines if instancing is supported */
  83485. instancedArrays: boolean;
  83486. /** Defines if 32 bits indices are supported */
  83487. uintIndices: boolean;
  83488. /** Defines if high precision shaders are supported */
  83489. highPrecisionShaderSupported: boolean;
  83490. /** Defines if depth reading in the fragment shader is supported */
  83491. fragmentDepthSupported: boolean;
  83492. /** Defines if float texture linear filtering is supported*/
  83493. textureFloatLinearFiltering: boolean;
  83494. /** Defines if rendering to float textures is supported */
  83495. textureFloatRender: boolean;
  83496. /** Defines if half float textures are supported*/
  83497. textureHalfFloat: boolean;
  83498. /** Defines if half float texture linear filtering is supported*/
  83499. textureHalfFloatLinearFiltering: boolean;
  83500. /** Defines if rendering to half float textures is supported */
  83501. textureHalfFloatRender: boolean;
  83502. /** Defines if textureLOD shader command is supported */
  83503. textureLOD: boolean;
  83504. /** Defines if draw buffers extension is supported */
  83505. drawBuffersExtension: boolean;
  83506. /** Defines if depth textures are supported */
  83507. depthTextureExtension: boolean;
  83508. /** Defines if float color buffer are supported */
  83509. colorBufferFloat: boolean;
  83510. /** Gets disjoint timer query extension (null if not supported) */
  83511. timerQuery: EXT_disjoint_timer_query;
  83512. /** Defines if timestamp can be used with timer query */
  83513. canUseTimestampForTimerQuery: boolean;
  83514. /** Function used to let the system compiles shaders in background */
  83515. parallelShaderCompile: {
  83516. MAX_SHADER_COMPILER_THREADS_KHR: number;
  83517. maxShaderCompilerThreadsKHR: (thread: number) => void;
  83518. COMPLETION_STATUS_KHR: number;
  83519. };
  83520. }
  83521. /** Interface defining initialization parameters for Engine class */
  83522. export interface EngineOptions extends WebGLContextAttributes {
  83523. /**
  83524. * Defines if the engine should no exceed a specified device ratio
  83525. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  83526. */
  83527. limitDeviceRatio?: number;
  83528. /**
  83529. * Defines if webvr should be enabled automatically
  83530. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83531. */
  83532. autoEnableWebVR?: boolean;
  83533. /**
  83534. * Defines if webgl2 should be turned off even if supported
  83535. * @see http://doc.babylonjs.com/features/webgl2
  83536. */
  83537. disableWebGL2Support?: boolean;
  83538. /**
  83539. * Defines if webaudio should be initialized as well
  83540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83541. */
  83542. audioEngine?: boolean;
  83543. /**
  83544. * Defines if animations should run using a deterministic lock step
  83545. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83546. */
  83547. deterministicLockstep?: boolean;
  83548. /** Defines the maximum steps to use with deterministic lock step mode */
  83549. lockstepMaxSteps?: number;
  83550. /**
  83551. * Defines that engine should ignore context lost events
  83552. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  83553. */
  83554. doNotHandleContextLost?: boolean;
  83555. /**
  83556. * Defines that engine should ignore modifying touch action attribute and style
  83557. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  83558. */
  83559. doNotHandleTouchAction?: boolean;
  83560. }
  83561. /**
  83562. * Defines the interface used by display changed events
  83563. */
  83564. export interface IDisplayChangedEventArgs {
  83565. /** Gets the vrDisplay object (if any) */
  83566. vrDisplay: Nullable<any>;
  83567. /** Gets a boolean indicating if webVR is supported */
  83568. vrSupported: boolean;
  83569. }
  83570. /**
  83571. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  83572. */
  83573. export class Engine {
  83574. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  83575. static ExceptionList: ({
  83576. key: string;
  83577. capture: string;
  83578. captureConstraint: number;
  83579. targets: string[];
  83580. } | {
  83581. key: string;
  83582. capture: null;
  83583. captureConstraint: null;
  83584. targets: string[];
  83585. })[];
  83586. /** Gets the list of created engines */
  83587. static readonly Instances: Engine[];
  83588. /**
  83589. * Gets the latest created engine
  83590. */
  83591. static readonly LastCreatedEngine: Nullable<Engine>;
  83592. /**
  83593. * Gets the latest created scene
  83594. */
  83595. static readonly LastCreatedScene: Nullable<Scene>;
  83596. /**
  83597. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  83598. * @param flag defines which part of the materials must be marked as dirty
  83599. * @param predicate defines a predicate used to filter which materials should be affected
  83600. */
  83601. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  83602. /**
  83603. * Hidden
  83604. */
  83605. static _TextureLoaders: IInternalTextureLoader[];
  83606. /** Defines that alpha blending is disabled */
  83607. static readonly ALPHA_DISABLE: number;
  83608. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  83609. static readonly ALPHA_ADD: number;
  83610. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  83611. static readonly ALPHA_COMBINE: number;
  83612. /** Defines that alpha blending to DEST - SRC * DEST */
  83613. static readonly ALPHA_SUBTRACT: number;
  83614. /** Defines that alpha blending to SRC * DEST */
  83615. static readonly ALPHA_MULTIPLY: number;
  83616. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  83617. static readonly ALPHA_MAXIMIZED: number;
  83618. /** Defines that alpha blending to SRC + DEST */
  83619. static readonly ALPHA_ONEONE: number;
  83620. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  83621. static readonly ALPHA_PREMULTIPLIED: number;
  83622. /**
  83623. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  83624. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  83625. */
  83626. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  83627. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  83628. static readonly ALPHA_INTERPOLATE: number;
  83629. /**
  83630. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  83631. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  83632. */
  83633. static readonly ALPHA_SCREENMODE: number;
  83634. /** Defines that the ressource is not delayed*/
  83635. static readonly DELAYLOADSTATE_NONE: number;
  83636. /** Defines that the ressource was successfully delay loaded */
  83637. static readonly DELAYLOADSTATE_LOADED: number;
  83638. /** Defines that the ressource is currently delay loading */
  83639. static readonly DELAYLOADSTATE_LOADING: number;
  83640. /** Defines that the ressource is delayed and has not started loading */
  83641. static readonly DELAYLOADSTATE_NOTLOADED: number;
  83642. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  83643. static readonly NEVER: number;
  83644. /** 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 */
  83645. static readonly ALWAYS: number;
  83646. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  83647. static readonly LESS: number;
  83648. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  83649. static readonly EQUAL: number;
  83650. /** 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 */
  83651. static readonly LEQUAL: number;
  83652. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  83653. static readonly GREATER: number;
  83654. /** 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 */
  83655. static readonly GEQUAL: number;
  83656. /** 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 */
  83657. static readonly NOTEQUAL: number;
  83658. /** Passed to stencilOperation to specify that stencil value must be kept */
  83659. static readonly KEEP: number;
  83660. /** Passed to stencilOperation to specify that stencil value must be replaced */
  83661. static readonly REPLACE: number;
  83662. /** Passed to stencilOperation to specify that stencil value must be incremented */
  83663. static readonly INCR: number;
  83664. /** Passed to stencilOperation to specify that stencil value must be decremented */
  83665. static readonly DECR: number;
  83666. /** Passed to stencilOperation to specify that stencil value must be inverted */
  83667. static readonly INVERT: number;
  83668. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  83669. static readonly INCR_WRAP: number;
  83670. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  83671. static readonly DECR_WRAP: number;
  83672. /** Texture is not repeating outside of 0..1 UVs */
  83673. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  83674. /** Texture is repeating outside of 0..1 UVs */
  83675. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  83676. /** Texture is repeating and mirrored */
  83677. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  83678. /** ALPHA */
  83679. static readonly TEXTUREFORMAT_ALPHA: number;
  83680. /** LUMINANCE */
  83681. static readonly TEXTUREFORMAT_LUMINANCE: number;
  83682. /** LUMINANCE_ALPHA */
  83683. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  83684. /** RGB */
  83685. static readonly TEXTUREFORMAT_RGB: number;
  83686. /** RGBA */
  83687. static readonly TEXTUREFORMAT_RGBA: number;
  83688. /** RED */
  83689. static readonly TEXTUREFORMAT_RED: number;
  83690. /** RED (2nd reference) */
  83691. static readonly TEXTUREFORMAT_R: number;
  83692. /** RG */
  83693. static readonly TEXTUREFORMAT_RG: number;
  83694. /** RED_INTEGER */
  83695. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  83696. /** RED_INTEGER (2nd reference) */
  83697. static readonly TEXTUREFORMAT_R_INTEGER: number;
  83698. /** RG_INTEGER */
  83699. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  83700. /** RGB_INTEGER */
  83701. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  83702. /** RGBA_INTEGER */
  83703. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  83704. /** UNSIGNED_BYTE */
  83705. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  83706. /** UNSIGNED_BYTE (2nd reference) */
  83707. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  83708. /** FLOAT */
  83709. static readonly TEXTURETYPE_FLOAT: number;
  83710. /** HALF_FLOAT */
  83711. static readonly TEXTURETYPE_HALF_FLOAT: number;
  83712. /** BYTE */
  83713. static readonly TEXTURETYPE_BYTE: number;
  83714. /** SHORT */
  83715. static readonly TEXTURETYPE_SHORT: number;
  83716. /** UNSIGNED_SHORT */
  83717. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  83718. /** INT */
  83719. static readonly TEXTURETYPE_INT: number;
  83720. /** UNSIGNED_INT */
  83721. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  83722. /** UNSIGNED_SHORT_4_4_4_4 */
  83723. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  83724. /** UNSIGNED_SHORT_5_5_5_1 */
  83725. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  83726. /** UNSIGNED_SHORT_5_6_5 */
  83727. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  83728. /** UNSIGNED_INT_2_10_10_10_REV */
  83729. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  83730. /** UNSIGNED_INT_24_8 */
  83731. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  83732. /** UNSIGNED_INT_10F_11F_11F_REV */
  83733. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  83734. /** UNSIGNED_INT_5_9_9_9_REV */
  83735. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  83736. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  83737. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  83738. /** nearest is mag = nearest and min = nearest and mip = linear */
  83739. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  83740. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83741. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  83742. /** Trilinear is mag = linear and min = linear and mip = linear */
  83743. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  83744. /** nearest is mag = nearest and min = nearest and mip = linear */
  83745. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  83746. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83747. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  83748. /** Trilinear is mag = linear and min = linear and mip = linear */
  83749. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  83750. /** mag = nearest and min = nearest and mip = nearest */
  83751. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  83752. /** mag = nearest and min = linear and mip = nearest */
  83753. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  83754. /** mag = nearest and min = linear and mip = linear */
  83755. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  83756. /** mag = nearest and min = linear and mip = none */
  83757. static readonly TEXTURE_NEAREST_LINEAR: number;
  83758. /** mag = nearest and min = nearest and mip = none */
  83759. static readonly TEXTURE_NEAREST_NEAREST: number;
  83760. /** mag = linear and min = nearest and mip = nearest */
  83761. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  83762. /** mag = linear and min = nearest and mip = linear */
  83763. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  83764. /** mag = linear and min = linear and mip = none */
  83765. static readonly TEXTURE_LINEAR_LINEAR: number;
  83766. /** mag = linear and min = nearest and mip = none */
  83767. static readonly TEXTURE_LINEAR_NEAREST: number;
  83768. /** Explicit coordinates mode */
  83769. static readonly TEXTURE_EXPLICIT_MODE: number;
  83770. /** Spherical coordinates mode */
  83771. static readonly TEXTURE_SPHERICAL_MODE: number;
  83772. /** Planar coordinates mode */
  83773. static readonly TEXTURE_PLANAR_MODE: number;
  83774. /** Cubic coordinates mode */
  83775. static readonly TEXTURE_CUBIC_MODE: number;
  83776. /** Projection coordinates mode */
  83777. static readonly TEXTURE_PROJECTION_MODE: number;
  83778. /** Skybox coordinates mode */
  83779. static readonly TEXTURE_SKYBOX_MODE: number;
  83780. /** Inverse Cubic coordinates mode */
  83781. static readonly TEXTURE_INVCUBIC_MODE: number;
  83782. /** Equirectangular coordinates mode */
  83783. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  83784. /** Equirectangular Fixed coordinates mode */
  83785. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  83786. /** Equirectangular Fixed Mirrored coordinates mode */
  83787. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83788. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  83789. static readonly SCALEMODE_FLOOR: number;
  83790. /** Defines that texture rescaling will look for the nearest power of 2 size */
  83791. static readonly SCALEMODE_NEAREST: number;
  83792. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  83793. static readonly SCALEMODE_CEILING: number;
  83794. /**
  83795. * Returns the current version of the framework
  83796. */
  83797. static readonly Version: string;
  83798. /**
  83799. * Returns a string describing the current engine
  83800. */
  83801. readonly description: string;
  83802. /**
  83803. * Gets or sets the epsilon value used by collision engine
  83804. */
  83805. static CollisionsEpsilon: number;
  83806. /**
  83807. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  83808. */
  83809. static ShadersRepository: string;
  83810. /**
  83811. * Method called to create the default loading screen.
  83812. * This can be overriden in your own app.
  83813. * @param canvas The rendering canvas element
  83814. * @returns The loading screen
  83815. */
  83816. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  83817. /**
  83818. * Method called to create the default rescale post process on each engine.
  83819. */
  83820. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  83821. /**
  83822. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  83823. */
  83824. forcePOTTextures: boolean;
  83825. /**
  83826. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  83827. */
  83828. isFullscreen: boolean;
  83829. /**
  83830. * Gets a boolean indicating if the pointer is currently locked
  83831. */
  83832. isPointerLock: boolean;
  83833. /**
  83834. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  83835. */
  83836. cullBackFaces: boolean;
  83837. /**
  83838. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  83839. */
  83840. renderEvenInBackground: boolean;
  83841. /**
  83842. * Gets or sets a boolean indicating that cache can be kept between frames
  83843. */
  83844. preventCacheWipeBetweenFrames: boolean;
  83845. /**
  83846. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  83847. **/
  83848. enableOfflineSupport: boolean;
  83849. /**
  83850. * 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)
  83851. **/
  83852. disableManifestCheck: boolean;
  83853. /**
  83854. * Gets the list of created scenes
  83855. */
  83856. scenes: Scene[];
  83857. /**
  83858. * Event raised when a new scene is created
  83859. */
  83860. onNewSceneAddedObservable: Observable<Scene>;
  83861. /**
  83862. * Gets the list of created postprocesses
  83863. */
  83864. postProcesses: PostProcess[];
  83865. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  83866. validateShaderPrograms: boolean;
  83867. /**
  83868. * Observable event triggered each time the rendering canvas is resized
  83869. */
  83870. onResizeObservable: Observable<Engine>;
  83871. /**
  83872. * Observable event triggered each time the canvas loses focus
  83873. */
  83874. onCanvasBlurObservable: Observable<Engine>;
  83875. /**
  83876. * Observable event triggered each time the canvas gains focus
  83877. */
  83878. onCanvasFocusObservable: Observable<Engine>;
  83879. /**
  83880. * Observable event triggered each time the canvas receives pointerout event
  83881. */
  83882. onCanvasPointerOutObservable: Observable<PointerEvent>;
  83883. /**
  83884. * Observable event triggered before each texture is initialized
  83885. */
  83886. onBeforeTextureInitObservable: Observable<Texture>;
  83887. private _vrDisplay;
  83888. private _vrSupported;
  83889. private _oldSize;
  83890. private _oldHardwareScaleFactor;
  83891. private _vrExclusivePointerMode;
  83892. private _webVRInitPromise;
  83893. /**
  83894. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83895. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83896. */
  83897. readonly isInVRExclusivePointerMode: boolean;
  83898. /**
  83899. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  83900. */
  83901. disableUniformBuffers: boolean;
  83902. /** @hidden */
  83903. _uniformBuffers: UniformBuffer[];
  83904. /**
  83905. * Gets a boolean indicating that the engine supports uniform buffers
  83906. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83907. */
  83908. readonly supportsUniformBuffers: boolean;
  83909. /**
  83910. * Observable raised when the engine begins a new frame
  83911. */
  83912. onBeginFrameObservable: Observable<Engine>;
  83913. /**
  83914. * If set, will be used to request the next animation frame for the render loop
  83915. */
  83916. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  83917. /**
  83918. * Observable raised when the engine ends the current frame
  83919. */
  83920. onEndFrameObservable: Observable<Engine>;
  83921. /**
  83922. * Observable raised when the engine is about to compile a shader
  83923. */
  83924. onBeforeShaderCompilationObservable: Observable<Engine>;
  83925. /**
  83926. * Observable raised when the engine has jsut compiled a shader
  83927. */
  83928. onAfterShaderCompilationObservable: Observable<Engine>;
  83929. /** @hidden */
  83930. _gl: WebGLRenderingContext;
  83931. private _renderingCanvas;
  83932. private _windowIsBackground;
  83933. private _webGLVersion;
  83934. /**
  83935. * Gets a boolean indicating that only power of 2 textures are supported
  83936. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  83937. */
  83938. readonly needPOTTextures: boolean;
  83939. /** @hidden */
  83940. _badOS: boolean;
  83941. /** @hidden */
  83942. _badDesktopOS: boolean;
  83943. /**
  83944. * Gets or sets a value indicating if we want to disable texture binding optimization.
  83945. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  83946. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  83947. */
  83948. disableTextureBindingOptimization: boolean;
  83949. /**
  83950. * Gets the audio engine
  83951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83952. * @ignorenaming
  83953. */
  83954. static audioEngine: IAudioEngine;
  83955. /**
  83956. * Default AudioEngine factory responsible of creating the Audio Engine.
  83957. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  83958. */
  83959. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  83960. /**
  83961. * Default offline support factory responsible of creating a tool used to store data locally.
  83962. * By default, this will create a Database object if the workload has been embedded.
  83963. */
  83964. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  83965. private _onFocus;
  83966. private _onBlur;
  83967. private _onCanvasPointerOut;
  83968. private _onCanvasBlur;
  83969. private _onCanvasFocus;
  83970. private _onFullscreenChange;
  83971. private _onPointerLockChange;
  83972. private _onVRDisplayPointerRestricted;
  83973. private _onVRDisplayPointerUnrestricted;
  83974. private _onVrDisplayConnect;
  83975. private _onVrDisplayDisconnect;
  83976. private _onVrDisplayPresentChange;
  83977. /**
  83978. * Observable signaled when VR display mode changes
  83979. */
  83980. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83981. /**
  83982. * Observable signaled when VR request present is complete
  83983. */
  83984. onVRRequestPresentComplete: Observable<boolean>;
  83985. /**
  83986. * Observable signaled when VR request present starts
  83987. */
  83988. onVRRequestPresentStart: Observable<Engine>;
  83989. private _hardwareScalingLevel;
  83990. /** @hidden */
  83991. protected _caps: EngineCapabilities;
  83992. private _pointerLockRequested;
  83993. private _isStencilEnable;
  83994. private _colorWrite;
  83995. private _loadingScreen;
  83996. /** @hidden */
  83997. _drawCalls: PerfCounter;
  83998. /** @hidden */
  83999. _textureCollisions: PerfCounter;
  84000. private _glVersion;
  84001. private _glRenderer;
  84002. private _glVendor;
  84003. private _videoTextureSupported;
  84004. private _renderingQueueLaunched;
  84005. private _activeRenderLoops;
  84006. private _deterministicLockstep;
  84007. private _lockstepMaxSteps;
  84008. /**
  84009. * Observable signaled when a context lost event is raised
  84010. */
  84011. onContextLostObservable: Observable<Engine>;
  84012. /**
  84013. * Observable signaled when a context restored event is raised
  84014. */
  84015. onContextRestoredObservable: Observable<Engine>;
  84016. private _onContextLost;
  84017. private _onContextRestored;
  84018. private _contextWasLost;
  84019. private _doNotHandleContextLost;
  84020. /**
  84021. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  84022. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  84023. */
  84024. doNotHandleContextLost: boolean;
  84025. private _performanceMonitor;
  84026. private _fps;
  84027. private _deltaTime;
  84028. /**
  84029. * Turn this value on if you want to pause FPS computation when in background
  84030. */
  84031. disablePerformanceMonitorInBackground: boolean;
  84032. /**
  84033. * Gets the performance monitor attached to this engine
  84034. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  84035. */
  84036. readonly performanceMonitor: PerformanceMonitor;
  84037. /** @hidden */
  84038. protected _depthCullingState: _DepthCullingState;
  84039. /** @hidden */
  84040. protected _stencilState: _StencilState;
  84041. /** @hidden */
  84042. protected _alphaState: _AlphaState;
  84043. /** @hidden */
  84044. protected _alphaMode: number;
  84045. protected _internalTexturesCache: InternalTexture[];
  84046. /** @hidden */
  84047. protected _activeChannel: number;
  84048. private _currentTextureChannel;
  84049. /** @hidden */
  84050. protected _boundTexturesCache: {
  84051. [key: string]: Nullable<InternalTexture>;
  84052. };
  84053. /** @hidden */
  84054. protected _currentEffect: Nullable<Effect>;
  84055. /** @hidden */
  84056. protected _currentProgram: Nullable<WebGLProgram>;
  84057. private _compiledEffects;
  84058. private _vertexAttribArraysEnabled;
  84059. /** @hidden */
  84060. protected _cachedViewport: Nullable<Viewport>;
  84061. private _cachedVertexArrayObject;
  84062. /** @hidden */
  84063. protected _cachedVertexBuffers: any;
  84064. /** @hidden */
  84065. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  84066. /** @hidden */
  84067. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  84068. /** @hidden */
  84069. protected _currentRenderTarget: Nullable<InternalTexture>;
  84070. private _uintIndicesCurrentlySet;
  84071. private _currentBoundBuffer;
  84072. /** @hidden */
  84073. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  84074. private _currentBufferPointers;
  84075. private _currentInstanceLocations;
  84076. private _currentInstanceBuffers;
  84077. private _textureUnits;
  84078. private _firstBoundInternalTextureTracker;
  84079. private _lastBoundInternalTextureTracker;
  84080. private _workingCanvas;
  84081. private _workingContext;
  84082. private _rescalePostProcess;
  84083. private _dummyFramebuffer;
  84084. private _externalData;
  84085. private _bindedRenderFunction;
  84086. private _vaoRecordInProgress;
  84087. private _mustWipeVertexAttributes;
  84088. private _emptyTexture;
  84089. private _emptyCubeTexture;
  84090. private _emptyTexture3D;
  84091. /** @hidden */
  84092. _frameHandler: number;
  84093. private _nextFreeTextureSlots;
  84094. private _maxSimultaneousTextures;
  84095. private _activeRequests;
  84096. private _texturesSupported;
  84097. private _textureFormatInUse;
  84098. /**
  84099. * Gets the list of texture formats supported
  84100. */
  84101. readonly texturesSupported: Array<string>;
  84102. /**
  84103. * Gets the list of texture formats in use
  84104. */
  84105. readonly textureFormatInUse: Nullable<string>;
  84106. /**
  84107. * Gets the current viewport
  84108. */
  84109. readonly currentViewport: Nullable<Viewport>;
  84110. /**
  84111. * Gets the default empty texture
  84112. */
  84113. readonly emptyTexture: InternalTexture;
  84114. /**
  84115. * Gets the default empty 3D texture
  84116. */
  84117. readonly emptyTexture3D: InternalTexture;
  84118. /**
  84119. * Gets the default empty cube texture
  84120. */
  84121. readonly emptyCubeTexture: InternalTexture;
  84122. /**
  84123. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  84124. */
  84125. readonly premultipliedAlpha: boolean;
  84126. /**
  84127. * Creates a new engine
  84128. * @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
  84129. * @param antialias defines enable antialiasing (default: false)
  84130. * @param options defines further options to be sent to the getContext() function
  84131. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  84132. */
  84133. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  84134. private _disableTouchAction;
  84135. private _rebuildInternalTextures;
  84136. private _rebuildEffects;
  84137. /**
  84138. * Gets a boolean indicating if all created effects are ready
  84139. * @returns true if all effects are ready
  84140. */
  84141. areAllEffectsReady(): boolean;
  84142. private _rebuildBuffers;
  84143. private _initGLContext;
  84144. /**
  84145. * Gets version of the current webGL context
  84146. */
  84147. readonly webGLVersion: number;
  84148. /**
  84149. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  84150. */
  84151. readonly isStencilEnable: boolean;
  84152. private _prepareWorkingCanvas;
  84153. /**
  84154. * Reset the texture cache to empty state
  84155. */
  84156. resetTextureCache(): void;
  84157. /**
  84158. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  84159. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84160. * @returns true if engine is in deterministic lock step mode
  84161. */
  84162. isDeterministicLockStep(): boolean;
  84163. /**
  84164. * Gets the max steps when engine is running in deterministic lock step
  84165. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84166. * @returns the max steps
  84167. */
  84168. getLockstepMaxSteps(): number;
  84169. /**
  84170. * Gets an object containing information about the current webGL context
  84171. * @returns an object containing the vender, the renderer and the version of the current webGL context
  84172. */
  84173. getGlInfo(): {
  84174. vendor: string;
  84175. renderer: string;
  84176. version: string;
  84177. };
  84178. /**
  84179. * Gets current aspect ratio
  84180. * @param camera defines the camera to use to get the aspect ratio
  84181. * @param useScreen defines if screen size must be used (or the current render target if any)
  84182. * @returns a number defining the aspect ratio
  84183. */
  84184. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  84185. /**
  84186. * Gets current screen aspect ratio
  84187. * @returns a number defining the aspect ratio
  84188. */
  84189. getScreenAspectRatio(): number;
  84190. /**
  84191. * Gets the current render width
  84192. * @param useScreen defines if screen size must be used (or the current render target if any)
  84193. * @returns a number defining the current render width
  84194. */
  84195. getRenderWidth(useScreen?: boolean): number;
  84196. /**
  84197. * Gets the current render height
  84198. * @param useScreen defines if screen size must be used (or the current render target if any)
  84199. * @returns a number defining the current render height
  84200. */
  84201. getRenderHeight(useScreen?: boolean): number;
  84202. /**
  84203. * Gets the HTML canvas attached with the current webGL context
  84204. * @returns a HTML canvas
  84205. */
  84206. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  84207. /**
  84208. * Gets the client rect of the HTML canvas attached with the current webGL context
  84209. * @returns a client rectanglee
  84210. */
  84211. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  84212. /**
  84213. * Defines the hardware scaling level.
  84214. * By default the hardware scaling level is computed from the window device ratio.
  84215. * 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.
  84216. * @param level defines the level to use
  84217. */
  84218. setHardwareScalingLevel(level: number): void;
  84219. /**
  84220. * Gets the current hardware scaling level.
  84221. * By default the hardware scaling level is computed from the window device ratio.
  84222. * 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.
  84223. * @returns a number indicating the current hardware scaling level
  84224. */
  84225. getHardwareScalingLevel(): number;
  84226. /**
  84227. * Gets the list of loaded textures
  84228. * @returns an array containing all loaded textures
  84229. */
  84230. getLoadedTexturesCache(): InternalTexture[];
  84231. /**
  84232. * Gets the object containing all engine capabilities
  84233. * @returns the EngineCapabilities object
  84234. */
  84235. getCaps(): EngineCapabilities;
  84236. /**
  84237. * Gets the current depth function
  84238. * @returns a number defining the depth function
  84239. */
  84240. getDepthFunction(): Nullable<number>;
  84241. /**
  84242. * Sets the current depth function
  84243. * @param depthFunc defines the function to use
  84244. */
  84245. setDepthFunction(depthFunc: number): void;
  84246. /**
  84247. * Sets the current depth function to GREATER
  84248. */
  84249. setDepthFunctionToGreater(): void;
  84250. /**
  84251. * Sets the current depth function to GEQUAL
  84252. */
  84253. setDepthFunctionToGreaterOrEqual(): void;
  84254. /**
  84255. * Sets the current depth function to LESS
  84256. */
  84257. setDepthFunctionToLess(): void;
  84258. /**
  84259. * Sets the current depth function to LEQUAL
  84260. */
  84261. setDepthFunctionToLessOrEqual(): void;
  84262. /**
  84263. * Gets a boolean indicating if stencil buffer is enabled
  84264. * @returns the current stencil buffer state
  84265. */
  84266. getStencilBuffer(): boolean;
  84267. /**
  84268. * Enable or disable the stencil buffer
  84269. * @param enable defines if the stencil buffer must be enabled or disabled
  84270. */
  84271. setStencilBuffer(enable: boolean): void;
  84272. /**
  84273. * Gets the current stencil mask
  84274. * @returns a number defining the new stencil mask to use
  84275. */
  84276. getStencilMask(): number;
  84277. /**
  84278. * Sets the current stencil mask
  84279. * @param mask defines the new stencil mask to use
  84280. */
  84281. setStencilMask(mask: number): void;
  84282. /**
  84283. * Gets the current stencil function
  84284. * @returns a number defining the stencil function to use
  84285. */
  84286. getStencilFunction(): number;
  84287. /**
  84288. * Gets the current stencil reference value
  84289. * @returns a number defining the stencil reference value to use
  84290. */
  84291. getStencilFunctionReference(): number;
  84292. /**
  84293. * Gets the current stencil mask
  84294. * @returns a number defining the stencil mask to use
  84295. */
  84296. getStencilFunctionMask(): number;
  84297. /**
  84298. * Sets the current stencil function
  84299. * @param stencilFunc defines the new stencil function to use
  84300. */
  84301. setStencilFunction(stencilFunc: number): void;
  84302. /**
  84303. * Sets the current stencil reference
  84304. * @param reference defines the new stencil reference to use
  84305. */
  84306. setStencilFunctionReference(reference: number): void;
  84307. /**
  84308. * Sets the current stencil mask
  84309. * @param mask defines the new stencil mask to use
  84310. */
  84311. setStencilFunctionMask(mask: number): void;
  84312. /**
  84313. * Gets the current stencil operation when stencil fails
  84314. * @returns a number defining stencil operation to use when stencil fails
  84315. */
  84316. getStencilOperationFail(): number;
  84317. /**
  84318. * Gets the current stencil operation when depth fails
  84319. * @returns a number defining stencil operation to use when depth fails
  84320. */
  84321. getStencilOperationDepthFail(): number;
  84322. /**
  84323. * Gets the current stencil operation when stencil passes
  84324. * @returns a number defining stencil operation to use when stencil passes
  84325. */
  84326. getStencilOperationPass(): number;
  84327. /**
  84328. * Sets the stencil operation to use when stencil fails
  84329. * @param operation defines the stencil operation to use when stencil fails
  84330. */
  84331. setStencilOperationFail(operation: number): void;
  84332. /**
  84333. * Sets the stencil operation to use when depth fails
  84334. * @param operation defines the stencil operation to use when depth fails
  84335. */
  84336. setStencilOperationDepthFail(operation: number): void;
  84337. /**
  84338. * Sets the stencil operation to use when stencil passes
  84339. * @param operation defines the stencil operation to use when stencil passes
  84340. */
  84341. setStencilOperationPass(operation: number): void;
  84342. /**
  84343. * Sets a boolean indicating if the dithering state is enabled or disabled
  84344. * @param value defines the dithering state
  84345. */
  84346. setDitheringState(value: boolean): void;
  84347. /**
  84348. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  84349. * @param value defines the rasterizer state
  84350. */
  84351. setRasterizerState(value: boolean): void;
  84352. /**
  84353. * stop executing a render loop function and remove it from the execution array
  84354. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  84355. */
  84356. stopRenderLoop(renderFunction?: () => void): void;
  84357. /** @hidden */
  84358. _renderLoop(): void;
  84359. /**
  84360. * Register and execute a render loop. The engine can have more than one render function
  84361. * @param renderFunction defines the function to continuously execute
  84362. */
  84363. runRenderLoop(renderFunction: () => void): void;
  84364. /**
  84365. * Toggle full screen mode
  84366. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84367. */
  84368. switchFullscreen(requestPointerLock: boolean): void;
  84369. /**
  84370. * Enters full screen mode
  84371. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84372. */
  84373. enterFullscreen(requestPointerLock: boolean): void;
  84374. /**
  84375. * Exits full screen mode
  84376. */
  84377. exitFullscreen(): void;
  84378. /**
  84379. * Clear the current render buffer or the current render target (if any is set up)
  84380. * @param color defines the color to use
  84381. * @param backBuffer defines if the back buffer must be cleared
  84382. * @param depth defines if the depth buffer must be cleared
  84383. * @param stencil defines if the stencil buffer must be cleared
  84384. */
  84385. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  84386. /**
  84387. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  84388. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84389. * @param y defines the y-coordinate of the corner of the clear rectangle
  84390. * @param width defines the width of the clear rectangle
  84391. * @param height defines the height of the clear rectangle
  84392. * @param clearColor defines the clear color
  84393. */
  84394. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  84395. /**
  84396. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  84397. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84398. * @param y defines the y-coordinate of the corner of the clear rectangle
  84399. * @param width defines the width of the clear rectangle
  84400. * @param height defines the height of the clear rectangle
  84401. */
  84402. enableScissor(x: number, y: number, width: number, height: number): void;
  84403. /**
  84404. * Disable previously set scissor test rectangle
  84405. */
  84406. disableScissor(): void;
  84407. private _viewportCached;
  84408. /** @hidden */
  84409. _viewport(x: number, y: number, width: number, height: number): void;
  84410. /**
  84411. * Set the WebGL's viewport
  84412. * @param viewport defines the viewport element to be used
  84413. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  84414. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  84415. */
  84416. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  84417. /**
  84418. * Directly set the WebGL Viewport
  84419. * @param x defines the x coordinate of the viewport (in screen space)
  84420. * @param y defines the y coordinate of the viewport (in screen space)
  84421. * @param width defines the width of the viewport (in screen space)
  84422. * @param height defines the height of the viewport (in screen space)
  84423. * @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
  84424. */
  84425. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  84426. /**
  84427. * Begin a new frame
  84428. */
  84429. beginFrame(): void;
  84430. /**
  84431. * Enf the current frame
  84432. */
  84433. endFrame(): void;
  84434. /**
  84435. * Resize the view according to the canvas' size
  84436. */
  84437. resize(): void;
  84438. /**
  84439. * Force a specific size of the canvas
  84440. * @param width defines the new canvas' width
  84441. * @param height defines the new canvas' height
  84442. */
  84443. setSize(width: number, height: number): void;
  84444. /**
  84445. * Gets a boolean indicating if a webVR device was detected
  84446. * @returns true if a webVR device was detected
  84447. */
  84448. isVRDevicePresent(): boolean;
  84449. /**
  84450. * Gets the current webVR device
  84451. * @returns the current webVR device (or null)
  84452. */
  84453. getVRDevice(): any;
  84454. /**
  84455. * Initializes a webVR display and starts listening to display change events
  84456. * The onVRDisplayChangedObservable will be notified upon these changes
  84457. * @returns The onVRDisplayChangedObservable
  84458. */
  84459. initWebVR(): Observable<IDisplayChangedEventArgs>;
  84460. /**
  84461. * Initializes a webVR display and starts listening to display change events
  84462. * The onVRDisplayChangedObservable will be notified upon these changes
  84463. * @returns A promise containing a VRDisplay and if vr is supported
  84464. */
  84465. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  84466. /**
  84467. * Call this function to switch to webVR mode
  84468. * Will do nothing if webVR is not supported or if there is no webVR device
  84469. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84470. */
  84471. enableVR(): void;
  84472. /**
  84473. * Call this function to leave webVR mode
  84474. * Will do nothing if webVR is not supported or if there is no webVR device
  84475. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84476. */
  84477. disableVR(): void;
  84478. private _onVRFullScreenTriggered;
  84479. private _getVRDisplaysAsync;
  84480. /**
  84481. * Binds the frame buffer to the specified texture.
  84482. * @param texture The texture to render to or null for the default canvas
  84483. * @param faceIndex The face of the texture to render to in case of cube texture
  84484. * @param requiredWidth The width of the target to render to
  84485. * @param requiredHeight The height of the target to render to
  84486. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  84487. * @param depthStencilTexture The depth stencil texture to use to render
  84488. * @param lodLevel defines le lod level to bind to the frame buffer
  84489. */
  84490. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  84491. private bindUnboundFramebuffer;
  84492. /**
  84493. * Unbind the current render target texture from the webGL context
  84494. * @param texture defines the render target texture to unbind
  84495. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84496. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84497. */
  84498. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84499. /**
  84500. * Unbind a list of render target textures from the webGL context
  84501. * This is used only when drawBuffer extension or webGL2 are active
  84502. * @param textures defines the render target textures to unbind
  84503. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84504. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84505. */
  84506. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84507. /**
  84508. * Force the mipmap generation for the given render target texture
  84509. * @param texture defines the render target texture to use
  84510. */
  84511. generateMipMapsForCubemap(texture: InternalTexture): void;
  84512. /**
  84513. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  84514. */
  84515. flushFramebuffer(): void;
  84516. /**
  84517. * Unbind the current render target and bind the default framebuffer
  84518. */
  84519. restoreDefaultFramebuffer(): void;
  84520. /**
  84521. * Create an uniform buffer
  84522. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84523. * @param elements defines the content of the uniform buffer
  84524. * @returns the webGL uniform buffer
  84525. */
  84526. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  84527. /**
  84528. * Create a dynamic uniform buffer
  84529. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84530. * @param elements defines the content of the uniform buffer
  84531. * @returns the webGL uniform buffer
  84532. */
  84533. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  84534. /**
  84535. * Update an existing uniform buffer
  84536. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84537. * @param uniformBuffer defines the target uniform buffer
  84538. * @param elements defines the content to update
  84539. * @param offset defines the offset in the uniform buffer where update should start
  84540. * @param count defines the size of the data to update
  84541. */
  84542. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84543. private _resetVertexBufferBinding;
  84544. /**
  84545. * Creates a vertex buffer
  84546. * @param data the data for the vertex buffer
  84547. * @returns the new WebGL static buffer
  84548. */
  84549. createVertexBuffer(data: DataArray): WebGLBuffer;
  84550. /**
  84551. * Creates a dynamic vertex buffer
  84552. * @param data the data for the dynamic vertex buffer
  84553. * @returns the new WebGL dynamic buffer
  84554. */
  84555. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  84556. /**
  84557. * Update a dynamic index buffer
  84558. * @param indexBuffer defines the target index buffer
  84559. * @param indices defines the data to update
  84560. * @param offset defines the offset in the target index buffer where update should start
  84561. */
  84562. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  84563. /**
  84564. * Updates a dynamic vertex buffer.
  84565. * @param vertexBuffer the vertex buffer to update
  84566. * @param data the data used to update the vertex buffer
  84567. * @param byteOffset the byte offset of the data
  84568. * @param byteLength the byte length of the data
  84569. */
  84570. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  84571. private _resetIndexBufferBinding;
  84572. /**
  84573. * Creates a new index buffer
  84574. * @param indices defines the content of the index buffer
  84575. * @param updatable defines if the index buffer must be updatable
  84576. * @returns a new webGL buffer
  84577. */
  84578. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  84579. /**
  84580. * Bind a webGL buffer to the webGL context
  84581. * @param buffer defines the buffer to bind
  84582. */
  84583. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  84584. /**
  84585. * Bind an uniform buffer to the current webGL context
  84586. * @param buffer defines the buffer to bind
  84587. */
  84588. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  84589. /**
  84590. * Bind a buffer to the current webGL context at a given location
  84591. * @param buffer defines the buffer to bind
  84592. * @param location defines the index where to bind the buffer
  84593. */
  84594. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  84595. /**
  84596. * Bind a specific block at a given index in a specific shader program
  84597. * @param shaderProgram defines the shader program
  84598. * @param blockName defines the block name
  84599. * @param index defines the index where to bind the block
  84600. */
  84601. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  84602. private bindIndexBuffer;
  84603. private bindBuffer;
  84604. /**
  84605. * update the bound buffer with the given data
  84606. * @param data defines the data to update
  84607. */
  84608. updateArrayBuffer(data: Float32Array): void;
  84609. private _vertexAttribPointer;
  84610. private _bindIndexBufferWithCache;
  84611. private _bindVertexBuffersAttributes;
  84612. /**
  84613. * Records a vertex array object
  84614. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84615. * @param vertexBuffers defines the list of vertex buffers to store
  84616. * @param indexBuffer defines the index buffer to store
  84617. * @param effect defines the effect to store
  84618. * @returns the new vertex array object
  84619. */
  84620. recordVertexArrayObject(vertexBuffers: {
  84621. [key: string]: VertexBuffer;
  84622. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  84623. /**
  84624. * Bind a specific vertex array object
  84625. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84626. * @param vertexArrayObject defines the vertex array object to bind
  84627. * @param indexBuffer defines the index buffer to bind
  84628. */
  84629. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  84630. /**
  84631. * Bind webGl buffers directly to the webGL context
  84632. * @param vertexBuffer defines the vertex buffer to bind
  84633. * @param indexBuffer defines the index buffer to bind
  84634. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  84635. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  84636. * @param effect defines the effect associated with the vertex buffer
  84637. */
  84638. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  84639. private _unbindVertexArrayObject;
  84640. /**
  84641. * Bind a list of vertex buffers to the webGL context
  84642. * @param vertexBuffers defines the list of vertex buffers to bind
  84643. * @param indexBuffer defines the index buffer to bind
  84644. * @param effect defines the effect associated with the vertex buffers
  84645. */
  84646. bindBuffers(vertexBuffers: {
  84647. [key: string]: Nullable<VertexBuffer>;
  84648. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  84649. /**
  84650. * Unbind all instance attributes
  84651. */
  84652. unbindInstanceAttributes(): void;
  84653. /**
  84654. * Release and free the memory of a vertex array object
  84655. * @param vao defines the vertex array object to delete
  84656. */
  84657. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  84658. /** @hidden */
  84659. _releaseBuffer(buffer: WebGLBuffer): boolean;
  84660. /**
  84661. * Creates a webGL buffer to use with instanciation
  84662. * @param capacity defines the size of the buffer
  84663. * @returns the webGL buffer
  84664. */
  84665. createInstancesBuffer(capacity: number): WebGLBuffer;
  84666. /**
  84667. * Delete a webGL buffer used with instanciation
  84668. * @param buffer defines the webGL buffer to delete
  84669. */
  84670. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  84671. /**
  84672. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  84673. * @param instancesBuffer defines the webGL buffer to update and bind
  84674. * @param data defines the data to store in the buffer
  84675. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  84676. */
  84677. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  84678. /**
  84679. * Apply all cached states (depth, culling, stencil and alpha)
  84680. */
  84681. applyStates(): void;
  84682. /**
  84683. * Send a draw order
  84684. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84685. * @param indexStart defines the starting index
  84686. * @param indexCount defines the number of index to draw
  84687. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84688. */
  84689. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  84690. /**
  84691. * Draw a list of points
  84692. * @param verticesStart defines the index of first vertex to draw
  84693. * @param verticesCount defines the count of vertices to draw
  84694. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84695. */
  84696. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84697. /**
  84698. * Draw a list of unindexed primitives
  84699. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84700. * @param verticesStart defines the index of first vertex to draw
  84701. * @param verticesCount defines the count of vertices to draw
  84702. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84703. */
  84704. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84705. /**
  84706. * Draw a list of indexed primitives
  84707. * @param fillMode defines the primitive to use
  84708. * @param indexStart defines the starting index
  84709. * @param indexCount defines the number of index to draw
  84710. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84711. */
  84712. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  84713. /**
  84714. * Draw a list of unindexed primitives
  84715. * @param fillMode defines the primitive to use
  84716. * @param verticesStart defines the index of first vertex to draw
  84717. * @param verticesCount defines the count of vertices to draw
  84718. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84719. */
  84720. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84721. private _drawMode;
  84722. /** @hidden */
  84723. _releaseEffect(effect: Effect): void;
  84724. /** @hidden */
  84725. _deleteProgram(program: WebGLProgram): void;
  84726. /**
  84727. * Create a new effect (used to store vertex/fragment shaders)
  84728. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  84729. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  84730. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  84731. * @param samplers defines an array of string used to represent textures
  84732. * @param defines defines the string containing the defines to use to compile the shaders
  84733. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  84734. * @param onCompiled defines a function to call when the effect creation is successful
  84735. * @param onError defines a function to call when the effect creation has failed
  84736. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  84737. * @returns the new Effect
  84738. */
  84739. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  84740. private _compileShader;
  84741. private _compileRawShader;
  84742. /**
  84743. * Directly creates a webGL program
  84744. * @param vertexCode defines the vertex shader code to use
  84745. * @param fragmentCode defines the fragment shader code to use
  84746. * @param context defines the webGL context to use (if not set, the current one will be used)
  84747. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84748. * @returns the new webGL program
  84749. */
  84750. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84751. /**
  84752. * Creates a webGL program
  84753. * @param vertexCode defines the vertex shader code to use
  84754. * @param fragmentCode defines the fragment shader code to use
  84755. * @param defines defines the string containing the defines to use to compile the shaders
  84756. * @param context defines the webGL context to use (if not set, the current one will be used)
  84757. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84758. * @returns the new webGL program
  84759. */
  84760. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84761. private _createShaderProgram;
  84762. private _finalizeProgram;
  84763. /** @hidden */
  84764. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  84765. /** @hidden */
  84766. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  84767. /**
  84768. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  84769. * @param shaderProgram defines the webGL program to use
  84770. * @param uniformsNames defines the list of uniform names
  84771. * @returns an array of webGL uniform locations
  84772. */
  84773. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  84774. /**
  84775. * Gets the lsit of active attributes for a given webGL program
  84776. * @param shaderProgram defines the webGL program to use
  84777. * @param attributesNames defines the list of attribute names to get
  84778. * @returns an array of indices indicating the offset of each attribute
  84779. */
  84780. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  84781. /**
  84782. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  84783. * @param effect defines the effect to activate
  84784. */
  84785. enableEffect(effect: Nullable<Effect>): void;
  84786. /**
  84787. * Set the value of an uniform to an array of int32
  84788. * @param uniform defines the webGL uniform location where to store the value
  84789. * @param array defines the array of int32 to store
  84790. */
  84791. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84792. /**
  84793. * Set the value of an uniform to an array of int32 (stored as vec2)
  84794. * @param uniform defines the webGL uniform location where to store the value
  84795. * @param array defines the array of int32 to store
  84796. */
  84797. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84798. /**
  84799. * Set the value of an uniform to an array of int32 (stored as vec3)
  84800. * @param uniform defines the webGL uniform location where to store the value
  84801. * @param array defines the array of int32 to store
  84802. */
  84803. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84804. /**
  84805. * Set the value of an uniform to an array of int32 (stored as vec4)
  84806. * @param uniform defines the webGL uniform location where to store the value
  84807. * @param array defines the array of int32 to store
  84808. */
  84809. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84810. /**
  84811. * Set the value of an uniform to an array of float32
  84812. * @param uniform defines the webGL uniform location where to store the value
  84813. * @param array defines the array of float32 to store
  84814. */
  84815. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84816. /**
  84817. * Set the value of an uniform to an array of float32 (stored as vec2)
  84818. * @param uniform defines the webGL uniform location where to store the value
  84819. * @param array defines the array of float32 to store
  84820. */
  84821. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84822. /**
  84823. * Set the value of an uniform to an array of float32 (stored as vec3)
  84824. * @param uniform defines the webGL uniform location where to store the value
  84825. * @param array defines the array of float32 to store
  84826. */
  84827. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84828. /**
  84829. * Set the value of an uniform to an array of float32 (stored as vec4)
  84830. * @param uniform defines the webGL uniform location where to store the value
  84831. * @param array defines the array of float32 to store
  84832. */
  84833. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84834. /**
  84835. * Set the value of an uniform to an array of number
  84836. * @param uniform defines the webGL uniform location where to store the value
  84837. * @param array defines the array of number to store
  84838. */
  84839. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84840. /**
  84841. * Set the value of an uniform to an array of number (stored as vec2)
  84842. * @param uniform defines the webGL uniform location where to store the value
  84843. * @param array defines the array of number to store
  84844. */
  84845. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84846. /**
  84847. * Set the value of an uniform to an array of number (stored as vec3)
  84848. * @param uniform defines the webGL uniform location where to store the value
  84849. * @param array defines the array of number to store
  84850. */
  84851. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84852. /**
  84853. * Set the value of an uniform to an array of number (stored as vec4)
  84854. * @param uniform defines the webGL uniform location where to store the value
  84855. * @param array defines the array of number to store
  84856. */
  84857. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84858. /**
  84859. * Set the value of an uniform to an array of float32 (stored as matrices)
  84860. * @param uniform defines the webGL uniform location where to store the value
  84861. * @param matrices defines the array of float32 to store
  84862. */
  84863. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  84864. /**
  84865. * Set the value of an uniform to a matrix
  84866. * @param uniform defines the webGL uniform location where to store the value
  84867. * @param matrix defines the matrix to store
  84868. */
  84869. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  84870. /**
  84871. * Set the value of an uniform to a matrix (3x3)
  84872. * @param uniform defines the webGL uniform location where to store the value
  84873. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  84874. */
  84875. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  84876. /**
  84877. * Set the value of an uniform to a matrix (2x2)
  84878. * @param uniform defines the webGL uniform location where to store the value
  84879. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  84880. */
  84881. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  84882. /**
  84883. * Set the value of an uniform to a number (int)
  84884. * @param uniform defines the webGL uniform location where to store the value
  84885. * @param value defines the int number to store
  84886. */
  84887. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  84888. /**
  84889. * Set the value of an uniform to a number (float)
  84890. * @param uniform defines the webGL uniform location where to store the value
  84891. * @param value defines the float number to store
  84892. */
  84893. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  84894. /**
  84895. * Set the value of an uniform to a vec2
  84896. * @param uniform defines the webGL uniform location where to store the value
  84897. * @param x defines the 1st component of the value
  84898. * @param y defines the 2nd component of the value
  84899. */
  84900. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  84901. /**
  84902. * Set the value of an uniform to a vec3
  84903. * @param uniform defines the webGL uniform location where to store the value
  84904. * @param x defines the 1st component of the value
  84905. * @param y defines the 2nd component of the value
  84906. * @param z defines the 3rd component of the value
  84907. */
  84908. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  84909. /**
  84910. * Set the value of an uniform to a boolean
  84911. * @param uniform defines the webGL uniform location where to store the value
  84912. * @param bool defines the boolean to store
  84913. */
  84914. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  84915. /**
  84916. * Set the value of an uniform to a vec4
  84917. * @param uniform defines the webGL uniform location where to store the value
  84918. * @param x defines the 1st component of the value
  84919. * @param y defines the 2nd component of the value
  84920. * @param z defines the 3rd component of the value
  84921. * @param w defines the 4th component of the value
  84922. */
  84923. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  84924. /**
  84925. * Set the value of an uniform to a Color3
  84926. * @param uniform defines the webGL uniform location where to store the value
  84927. * @param color3 defines the color to store
  84928. */
  84929. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  84930. /**
  84931. * Set the value of an uniform to a Color3 and an alpha value
  84932. * @param uniform defines the webGL uniform location where to store the value
  84933. * @param color3 defines the color to store
  84934. * @param alpha defines the alpha component to store
  84935. */
  84936. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  84937. /**
  84938. * Sets a Color4 on a uniform variable
  84939. * @param uniform defines the uniform location
  84940. * @param color4 defines the value to be set
  84941. */
  84942. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  84943. /**
  84944. * Set various states to the webGL context
  84945. * @param culling defines backface culling state
  84946. * @param zOffset defines the value to apply to zOffset (0 by default)
  84947. * @param force defines if states must be applied even if cache is up to date
  84948. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  84949. */
  84950. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  84951. /**
  84952. * Set the z offset to apply to current rendering
  84953. * @param value defines the offset to apply
  84954. */
  84955. setZOffset(value: number): void;
  84956. /**
  84957. * Gets the current value of the zOffset
  84958. * @returns the current zOffset state
  84959. */
  84960. getZOffset(): number;
  84961. /**
  84962. * Enable or disable depth buffering
  84963. * @param enable defines the state to set
  84964. */
  84965. setDepthBuffer(enable: boolean): void;
  84966. /**
  84967. * Gets a boolean indicating if depth writing is enabled
  84968. * @returns the current depth writing state
  84969. */
  84970. getDepthWrite(): boolean;
  84971. /**
  84972. * Enable or disable depth writing
  84973. * @param enable defines the state to set
  84974. */
  84975. setDepthWrite(enable: boolean): void;
  84976. /**
  84977. * Enable or disable color writing
  84978. * @param enable defines the state to set
  84979. */
  84980. setColorWrite(enable: boolean): void;
  84981. /**
  84982. * Gets a boolean indicating if color writing is enabled
  84983. * @returns the current color writing state
  84984. */
  84985. getColorWrite(): boolean;
  84986. /**
  84987. * Sets alpha constants used by some alpha blending modes
  84988. * @param r defines the red component
  84989. * @param g defines the green component
  84990. * @param b defines the blue component
  84991. * @param a defines the alpha component
  84992. */
  84993. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  84994. /**
  84995. * Sets the current alpha mode
  84996. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  84997. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  84998. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  84999. */
  85000. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  85001. /**
  85002. * Gets the current alpha mode
  85003. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85004. * @returns the current alpha mode
  85005. */
  85006. getAlphaMode(): number;
  85007. /**
  85008. * Clears the list of texture accessible through engine.
  85009. * This can help preventing texture load conflict due to name collision.
  85010. */
  85011. clearInternalTexturesCache(): void;
  85012. /**
  85013. * Force the entire cache to be cleared
  85014. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  85015. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  85016. */
  85017. wipeCaches(bruteForce?: boolean): void;
  85018. /**
  85019. * Set the compressed texture format to use, based on the formats you have, and the formats
  85020. * supported by the hardware / browser.
  85021. *
  85022. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  85023. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  85024. * to API arguments needed to compressed textures. This puts the burden on the container
  85025. * generator to house the arcane code for determining these for current & future formats.
  85026. *
  85027. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  85028. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  85029. *
  85030. * Note: The result of this call is not taken into account when a texture is base64.
  85031. *
  85032. * @param formatsAvailable defines the list of those format families you have created
  85033. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  85034. *
  85035. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  85036. * @returns The extension selected.
  85037. */
  85038. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  85039. private _getSamplingParameters;
  85040. private _partialLoadImg;
  85041. private _cascadeLoadImgs;
  85042. /** @hidden */
  85043. _createTexture(): WebGLTexture;
  85044. /**
  85045. * Usually called from Texture.ts.
  85046. * Passed information to create a WebGLTexture
  85047. * @param urlArg defines a value which contains one of the following:
  85048. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  85049. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  85050. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  85051. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  85052. * @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)
  85053. * @param scene needed for loading to the correct scene
  85054. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  85055. * @param onLoad optional callback to be called upon successful completion
  85056. * @param onError optional callback to be called upon failure
  85057. * @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
  85058. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  85059. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  85060. * @param forcedExtension defines the extension to use to pick the right loader
  85061. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  85062. * @returns a InternalTexture for assignment back into BABYLON.Texture
  85063. */
  85064. 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;
  85065. private _rescaleTexture;
  85066. /**
  85067. * Update a raw texture
  85068. * @param texture defines the texture to update
  85069. * @param data defines the data to store in the texture
  85070. * @param format defines the format of the data
  85071. * @param invertY defines if data must be stored with Y axis inverted
  85072. * @param compression defines the compression used (null by default)
  85073. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85074. */
  85075. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  85076. /**
  85077. * Creates a raw texture
  85078. * @param data defines the data to store in the texture
  85079. * @param width defines the width of the texture
  85080. * @param height defines the height of the texture
  85081. * @param format defines the format of the data
  85082. * @param generateMipMaps defines if the engine should generate the mip levels
  85083. * @param invertY defines if data must be stored with Y axis inverted
  85084. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85085. * @param compression defines the compression used (null by default)
  85086. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85087. * @returns the raw texture inside an InternalTexture
  85088. */
  85089. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  85090. private _unpackFlipYCached;
  85091. /**
  85092. * In case you are sharing the context with other applications, it might
  85093. * be interested to not cache the unpack flip y state to ensure a consistent
  85094. * value would be set.
  85095. */
  85096. enableUnpackFlipYCached: boolean;
  85097. /** @hidden */
  85098. _unpackFlipY(value: boolean): void;
  85099. /** @hidden */
  85100. _getUnpackAlignement(): number;
  85101. /**
  85102. * Creates a dynamic texture
  85103. * @param width defines the width of the texture
  85104. * @param height defines the height of the texture
  85105. * @param generateMipMaps defines if the engine should generate the mip levels
  85106. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85107. * @returns the dynamic texture inside an InternalTexture
  85108. */
  85109. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85110. /**
  85111. * Update the sampling mode of a given texture
  85112. * @param samplingMode defines the required sampling mode
  85113. * @param texture defines the texture to update
  85114. */
  85115. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  85116. /**
  85117. * Update the content of a dynamic texture
  85118. * @param texture defines the texture to update
  85119. * @param canvas defines the canvas containing the source
  85120. * @param invertY defines if data must be stored with Y axis inverted
  85121. * @param premulAlpha defines if alpha is stored as premultiplied
  85122. * @param format defines the format of the data
  85123. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85124. */
  85125. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85126. /**
  85127. * Update a video texture
  85128. * @param texture defines the texture to update
  85129. * @param video defines the video element to use
  85130. * @param invertY defines if data must be stored with Y axis inverted
  85131. */
  85132. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  85133. /**
  85134. * Updates a depth texture Comparison Mode and Function.
  85135. * If the comparison Function is equal to 0, the mode will be set to none.
  85136. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  85137. * @param texture The texture to set the comparison function for
  85138. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  85139. */
  85140. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  85141. private _setupDepthStencilTexture;
  85142. /**
  85143. * Creates a depth stencil texture.
  85144. * This is only available in WebGL 2 or with the depth texture extension available.
  85145. * @param size The size of face edge in the texture.
  85146. * @param options The options defining the texture.
  85147. * @returns The texture
  85148. */
  85149. createDepthStencilTexture(size: number | {
  85150. width: number;
  85151. height: number;
  85152. }, options: DepthTextureCreationOptions): InternalTexture;
  85153. /**
  85154. * Creates a depth stencil texture.
  85155. * This is only available in WebGL 2 or with the depth texture extension available.
  85156. * @param size The size of face edge in the texture.
  85157. * @param options The options defining the texture.
  85158. * @returns The texture
  85159. */
  85160. private _createDepthStencilTexture;
  85161. /**
  85162. * Creates a depth stencil cube texture.
  85163. * This is only available in WebGL 2.
  85164. * @param size The size of face edge in the cube texture.
  85165. * @param options The options defining the cube texture.
  85166. * @returns The cube texture
  85167. */
  85168. private _createDepthStencilCubeTexture;
  85169. /**
  85170. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  85171. * @param renderTarget The render target to set the frame buffer for
  85172. */
  85173. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  85174. /**
  85175. * Creates a new render target texture
  85176. * @param size defines the size of the texture
  85177. * @param options defines the options used to create the texture
  85178. * @returns a new render target texture stored in an InternalTexture
  85179. */
  85180. createRenderTargetTexture(size: number | {
  85181. width: number;
  85182. height: number;
  85183. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85184. /**
  85185. * Create a multi render target texture
  85186. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  85187. * @param size defines the size of the texture
  85188. * @param options defines the creation options
  85189. * @returns the cube texture as an InternalTexture
  85190. */
  85191. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  85192. private _setupFramebufferDepthAttachments;
  85193. /**
  85194. * Updates the sample count of a render target texture
  85195. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85196. * @param texture defines the texture to update
  85197. * @param samples defines the sample count to set
  85198. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85199. */
  85200. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  85201. /**
  85202. * Update the sample count for a given multiple render target texture
  85203. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85204. * @param textures defines the textures to update
  85205. * @param samples defines the sample count to set
  85206. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85207. */
  85208. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  85209. /** @hidden */
  85210. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85211. /** @hidden */
  85212. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85213. /** @hidden */
  85214. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85215. /** @hidden */
  85216. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  85217. /**
  85218. * Creates a new render target cube texture
  85219. * @param size defines the size of the texture
  85220. * @param options defines the options used to create the texture
  85221. * @returns a new render target cube texture stored in an InternalTexture
  85222. */
  85223. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85224. /**
  85225. * Creates a cube texture
  85226. * @param rootUrl defines the url where the files to load is located
  85227. * @param scene defines the current scene
  85228. * @param files defines the list of files to load (1 per face)
  85229. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85230. * @param onLoad defines an optional callback raised when the texture is loaded
  85231. * @param onError defines an optional callback raised if there is an issue to load the texture
  85232. * @param format defines the format of the data
  85233. * @param forcedExtension defines the extension to use to pick the right loader
  85234. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85235. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85236. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85237. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85238. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  85239. * @returns the cube texture as an InternalTexture
  85240. */
  85241. 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;
  85242. /**
  85243. * @hidden
  85244. */
  85245. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85246. /**
  85247. * Update a raw cube texture
  85248. * @param texture defines the texture to udpdate
  85249. * @param data defines the data to store
  85250. * @param format defines the data format
  85251. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85252. * @param invertY defines if data must be stored with Y axis inverted
  85253. * @param compression defines the compression used (null by default)
  85254. * @param level defines which level of the texture to update
  85255. */
  85256. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  85257. /**
  85258. * Creates a new raw cube texture
  85259. * @param data defines the array of data to use to create each face
  85260. * @param size defines the size of the textures
  85261. * @param format defines the format of the data
  85262. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85263. * @param generateMipMaps defines if the engine should generate the mip levels
  85264. * @param invertY defines if data must be stored with Y axis inverted
  85265. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85266. * @param compression defines the compression used (null by default)
  85267. * @returns the cube texture as an InternalTexture
  85268. */
  85269. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  85270. /**
  85271. * Creates a new raw cube texture from a specified url
  85272. * @param url defines the url where the data is located
  85273. * @param scene defines the current scene
  85274. * @param size defines the size of the textures
  85275. * @param format defines the format of the data
  85276. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85277. * @param noMipmap defines if the engine should avoid generating the mip levels
  85278. * @param callback defines a callback used to extract texture data from loaded data
  85279. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85280. * @param onLoad defines a callback called when texture is loaded
  85281. * @param onError defines a callback called if there is an error
  85282. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85283. * @param invertY defines if data must be stored with Y axis inverted
  85284. * @returns the cube texture as an InternalTexture
  85285. */
  85286. 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;
  85287. /**
  85288. * Update a raw 3D texture
  85289. * @param texture defines the texture to update
  85290. * @param data defines the data to store
  85291. * @param format defines the data format
  85292. * @param invertY defines if data must be stored with Y axis inverted
  85293. * @param compression defines the used compression (can be null)
  85294. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85295. */
  85296. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  85297. /**
  85298. * Creates a new raw 3D texture
  85299. * @param data defines the data used to create the texture
  85300. * @param width defines the width of the texture
  85301. * @param height defines the height of the texture
  85302. * @param depth defines the depth of the texture
  85303. * @param format defines the format of the texture
  85304. * @param generateMipMaps defines if the engine must generate mip levels
  85305. * @param invertY defines if data must be stored with Y axis inverted
  85306. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85307. * @param compression defines the compressed used (can be null)
  85308. * @param textureType defines the compressed used (can be null)
  85309. * @returns a new raw 3D texture (stored in an InternalTexture)
  85310. */
  85311. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  85312. private _prepareWebGLTextureContinuation;
  85313. private _prepareWebGLTexture;
  85314. private _convertRGBtoRGBATextureData;
  85315. /** @hidden */
  85316. _releaseFramebufferObjects(texture: InternalTexture): void;
  85317. /** @hidden */
  85318. _releaseTexture(texture: InternalTexture): void;
  85319. private setProgram;
  85320. private _boundUniforms;
  85321. /**
  85322. * Binds an effect to the webGL context
  85323. * @param effect defines the effect to bind
  85324. */
  85325. bindSamplers(effect: Effect): void;
  85326. private _moveBoundTextureOnTop;
  85327. private _getCorrectTextureChannel;
  85328. private _linkTrackers;
  85329. private _removeDesignatedSlot;
  85330. private _activateCurrentTexture;
  85331. /** @hidden */
  85332. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  85333. /** @hidden */
  85334. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  85335. /**
  85336. * Sets a texture to the webGL context from a postprocess
  85337. * @param channel defines the channel to use
  85338. * @param postProcess defines the source postprocess
  85339. */
  85340. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  85341. /**
  85342. * Binds the output of the passed in post process to the texture channel specified
  85343. * @param channel The channel the texture should be bound to
  85344. * @param postProcess The post process which's output should be bound
  85345. */
  85346. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  85347. /**
  85348. * Unbind all textures from the webGL context
  85349. */
  85350. unbindAllTextures(): void;
  85351. /**
  85352. * Sets a texture to the according uniform.
  85353. * @param channel The texture channel
  85354. * @param uniform The uniform to set
  85355. * @param texture The texture to apply
  85356. */
  85357. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  85358. /**
  85359. * Sets a depth stencil texture from a render target to the according uniform.
  85360. * @param channel The texture channel
  85361. * @param uniform The uniform to set
  85362. * @param texture The render target texture containing the depth stencil texture to apply
  85363. */
  85364. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  85365. private _bindSamplerUniformToChannel;
  85366. private _getTextureWrapMode;
  85367. private _setTexture;
  85368. /**
  85369. * Sets an array of texture to the webGL context
  85370. * @param channel defines the channel where the texture array must be set
  85371. * @param uniform defines the associated uniform location
  85372. * @param textures defines the array of textures to bind
  85373. */
  85374. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  85375. /** @hidden */
  85376. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  85377. private _setTextureParameterFloat;
  85378. private _setTextureParameterInteger;
  85379. /**
  85380. * Reads pixels from the current frame buffer. Please note that this function can be slow
  85381. * @param x defines the x coordinate of the rectangle where pixels must be read
  85382. * @param y defines the y coordinate of the rectangle where pixels must be read
  85383. * @param width defines the width of the rectangle where pixels must be read
  85384. * @param height defines the height of the rectangle where pixels must be read
  85385. * @returns a Uint8Array containing RGBA colors
  85386. */
  85387. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  85388. /**
  85389. * Add an externaly attached data from its key.
  85390. * This method call will fail and return false, if such key already exists.
  85391. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  85392. * @param key the unique key that identifies the data
  85393. * @param data the data object to associate to the key for this Engine instance
  85394. * @return true if no such key were already present and the data was added successfully, false otherwise
  85395. */
  85396. addExternalData<T>(key: string, data: T): boolean;
  85397. /**
  85398. * Get an externaly attached data from its key
  85399. * @param key the unique key that identifies the data
  85400. * @return the associated data, if present (can be null), or undefined if not present
  85401. */
  85402. getExternalData<T>(key: string): T;
  85403. /**
  85404. * Get an externaly attached data from its key, create it using a factory if it's not already present
  85405. * @param key the unique key that identifies the data
  85406. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  85407. * @return the associated data, can be null if the factory returned null.
  85408. */
  85409. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  85410. /**
  85411. * Remove an externaly attached data from the Engine instance
  85412. * @param key the unique key that identifies the data
  85413. * @return true if the data was successfully removed, false if it doesn't exist
  85414. */
  85415. removeExternalData(key: string): boolean;
  85416. /**
  85417. * Unbind all vertex attributes from the webGL context
  85418. */
  85419. unbindAllAttributes(): void;
  85420. /**
  85421. * 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
  85422. */
  85423. releaseEffects(): void;
  85424. /**
  85425. * Dispose and release all associated resources
  85426. */
  85427. dispose(): void;
  85428. /**
  85429. * Display the loading screen
  85430. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85431. */
  85432. displayLoadingUI(): void;
  85433. /**
  85434. * Hide the loading screen
  85435. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85436. */
  85437. hideLoadingUI(): void;
  85438. /**
  85439. * Gets the current loading screen object
  85440. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85441. */
  85442. /**
  85443. * Sets the current loading screen object
  85444. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85445. */
  85446. loadingScreen: ILoadingScreen;
  85447. /**
  85448. * Sets the current loading screen text
  85449. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85450. */
  85451. loadingUIText: string;
  85452. /**
  85453. * Sets the current loading screen background color
  85454. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85455. */
  85456. loadingUIBackgroundColor: string;
  85457. /**
  85458. * Attach a new callback raised when context lost event is fired
  85459. * @param callback defines the callback to call
  85460. */
  85461. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85462. /**
  85463. * Attach a new callback raised when context restored event is fired
  85464. * @param callback defines the callback to call
  85465. */
  85466. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85467. /**
  85468. * Gets the source code of the vertex shader associated with a specific webGL program
  85469. * @param program defines the program to use
  85470. * @returns a string containing the source code of the vertex shader associated with the program
  85471. */
  85472. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  85473. /**
  85474. * Gets the source code of the fragment shader associated with a specific webGL program
  85475. * @param program defines the program to use
  85476. * @returns a string containing the source code of the fragment shader associated with the program
  85477. */
  85478. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  85479. /**
  85480. * Get the current error code of the webGL context
  85481. * @returns the error code
  85482. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  85483. */
  85484. getError(): number;
  85485. /**
  85486. * Gets the current framerate
  85487. * @returns a number representing the framerate
  85488. */
  85489. getFps(): number;
  85490. /**
  85491. * Gets the time spent between current and previous frame
  85492. * @returns a number representing the delta time in ms
  85493. */
  85494. getDeltaTime(): number;
  85495. private _measureFps;
  85496. /** @hidden */
  85497. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  85498. private _canRenderToFloatFramebuffer;
  85499. private _canRenderToHalfFloatFramebuffer;
  85500. private _canRenderToFramebuffer;
  85501. /** @hidden */
  85502. _getWebGLTextureType(type: number): number;
  85503. private _getInternalFormat;
  85504. /** @hidden */
  85505. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  85506. /** @hidden */
  85507. _getRGBAMultiSampleBufferFormat(type: number): number;
  85508. /** @hidden */
  85509. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  85510. /** @hidden */
  85511. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  85512. private _partialLoadFile;
  85513. private _cascadeLoadFiles;
  85514. /**
  85515. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  85516. * @returns true if the engine can be created
  85517. * @ignorenaming
  85518. */
  85519. static isSupported(): boolean;
  85520. }
  85521. }
  85522. declare module BABYLON {
  85523. /**
  85524. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  85525. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  85526. */
  85527. export class EffectFallbacks {
  85528. private _defines;
  85529. private _currentRank;
  85530. private _maxRank;
  85531. private _mesh;
  85532. /**
  85533. * Removes the fallback from the bound mesh.
  85534. */
  85535. unBindMesh(): void;
  85536. /**
  85537. * Adds a fallback on the specified property.
  85538. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85539. * @param define The name of the define in the shader
  85540. */
  85541. addFallback(rank: number, define: string): void;
  85542. /**
  85543. * Sets the mesh to use CPU skinning when needing to fallback.
  85544. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85545. * @param mesh The mesh to use the fallbacks.
  85546. */
  85547. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  85548. /**
  85549. * Checks to see if more fallbacks are still availible.
  85550. */
  85551. readonly isMoreFallbacks: boolean;
  85552. /**
  85553. * Removes the defines that shoould be removed when falling back.
  85554. * @param currentDefines defines the current define statements for the shader.
  85555. * @param effect defines the current effect we try to compile
  85556. * @returns The resulting defines with defines of the current rank removed.
  85557. */
  85558. reduce(currentDefines: string, effect: Effect): string;
  85559. }
  85560. /**
  85561. * Options to be used when creating an effect.
  85562. */
  85563. export class EffectCreationOptions {
  85564. /**
  85565. * Atrributes that will be used in the shader.
  85566. */
  85567. attributes: string[];
  85568. /**
  85569. * Uniform varible names that will be set in the shader.
  85570. */
  85571. uniformsNames: string[];
  85572. /**
  85573. * Uniform buffer varible names that will be set in the shader.
  85574. */
  85575. uniformBuffersNames: string[];
  85576. /**
  85577. * Sampler texture variable names that will be set in the shader.
  85578. */
  85579. samplers: string[];
  85580. /**
  85581. * Define statements that will be set in the shader.
  85582. */
  85583. defines: any;
  85584. /**
  85585. * Possible fallbacks for this effect to improve performance when needed.
  85586. */
  85587. fallbacks: Nullable<EffectFallbacks>;
  85588. /**
  85589. * Callback that will be called when the shader is compiled.
  85590. */
  85591. onCompiled: Nullable<(effect: Effect) => void>;
  85592. /**
  85593. * Callback that will be called if an error occurs during shader compilation.
  85594. */
  85595. onError: Nullable<(effect: Effect, errors: string) => void>;
  85596. /**
  85597. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85598. */
  85599. indexParameters: any;
  85600. /**
  85601. * Max number of lights that can be used in the shader.
  85602. */
  85603. maxSimultaneousLights: number;
  85604. /**
  85605. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  85606. */
  85607. transformFeedbackVaryings: Nullable<string[]>;
  85608. }
  85609. /**
  85610. * Effect containing vertex and fragment shader that can be executed on an object.
  85611. */
  85612. export class Effect {
  85613. /**
  85614. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85615. */
  85616. static ShadersRepository: string;
  85617. /**
  85618. * Name of the effect.
  85619. */
  85620. name: any;
  85621. /**
  85622. * String container all the define statements that should be set on the shader.
  85623. */
  85624. defines: string;
  85625. /**
  85626. * Callback that will be called when the shader is compiled.
  85627. */
  85628. onCompiled: Nullable<(effect: Effect) => void>;
  85629. /**
  85630. * Callback that will be called if an error occurs during shader compilation.
  85631. */
  85632. onError: Nullable<(effect: Effect, errors: string) => void>;
  85633. /**
  85634. * Callback that will be called when effect is bound.
  85635. */
  85636. onBind: Nullable<(effect: Effect) => void>;
  85637. /**
  85638. * Unique ID of the effect.
  85639. */
  85640. uniqueId: number;
  85641. /**
  85642. * Observable that will be called when the shader is compiled.
  85643. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  85644. */
  85645. onCompileObservable: Observable<Effect>;
  85646. /**
  85647. * Observable that will be called if an error occurs during shader compilation.
  85648. */
  85649. onErrorObservable: Observable<Effect>;
  85650. /** @hidden */
  85651. _onBindObservable: Nullable<Observable<Effect>>;
  85652. /**
  85653. * Observable that will be called when effect is bound.
  85654. */
  85655. readonly onBindObservable: Observable<Effect>;
  85656. /** @hidden */
  85657. _bonesComputationForcedToCPU: boolean;
  85658. private static _uniqueIdSeed;
  85659. private _engine;
  85660. private _uniformBuffersNames;
  85661. private _uniformsNames;
  85662. private _samplers;
  85663. private _isReady;
  85664. private _compilationError;
  85665. private _attributesNames;
  85666. private _attributes;
  85667. private _uniforms;
  85668. /**
  85669. * Key for the effect.
  85670. * @hidden
  85671. */
  85672. _key: string;
  85673. private _indexParameters;
  85674. private _fallbacks;
  85675. private _vertexSourceCode;
  85676. private _fragmentSourceCode;
  85677. private _vertexSourceCodeOverride;
  85678. private _fragmentSourceCodeOverride;
  85679. private _transformFeedbackVaryings;
  85680. /**
  85681. * Compiled shader to webGL program.
  85682. * @hidden
  85683. */
  85684. _program: WebGLProgram;
  85685. private _valueCache;
  85686. private static _baseCache;
  85687. /**
  85688. * Instantiates an effect.
  85689. * An effect can be used to create/manage/execute vertex and fragment shaders.
  85690. * @param baseName Name of the effect.
  85691. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  85692. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  85693. * @param samplers List of sampler variables that will be passed to the shader.
  85694. * @param engine Engine to be used to render the effect
  85695. * @param defines Define statements to be added to the shader.
  85696. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  85697. * @param onCompiled Callback that will be called when the shader is compiled.
  85698. * @param onError Callback that will be called if an error occurs during shader compilation.
  85699. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85700. */
  85701. 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);
  85702. /**
  85703. * Unique key for this effect
  85704. */
  85705. readonly key: string;
  85706. /**
  85707. * If the effect has been compiled and prepared.
  85708. * @returns if the effect is compiled and prepared.
  85709. */
  85710. isReady(): boolean;
  85711. /**
  85712. * The engine the effect was initialized with.
  85713. * @returns the engine.
  85714. */
  85715. getEngine(): Engine;
  85716. /**
  85717. * The compiled webGL program for the effect
  85718. * @returns the webGL program.
  85719. */
  85720. getProgram(): WebGLProgram;
  85721. /**
  85722. * The set of names of attribute variables for the shader.
  85723. * @returns An array of attribute names.
  85724. */
  85725. getAttributesNames(): string[];
  85726. /**
  85727. * Returns the attribute at the given index.
  85728. * @param index The index of the attribute.
  85729. * @returns The location of the attribute.
  85730. */
  85731. getAttributeLocation(index: number): number;
  85732. /**
  85733. * Returns the attribute based on the name of the variable.
  85734. * @param name of the attribute to look up.
  85735. * @returns the attribute location.
  85736. */
  85737. getAttributeLocationByName(name: string): number;
  85738. /**
  85739. * The number of attributes.
  85740. * @returns the numnber of attributes.
  85741. */
  85742. getAttributesCount(): number;
  85743. /**
  85744. * Gets the index of a uniform variable.
  85745. * @param uniformName of the uniform to look up.
  85746. * @returns the index.
  85747. */
  85748. getUniformIndex(uniformName: string): number;
  85749. /**
  85750. * Returns the attribute based on the name of the variable.
  85751. * @param uniformName of the uniform to look up.
  85752. * @returns the location of the uniform.
  85753. */
  85754. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  85755. /**
  85756. * Returns an array of sampler variable names
  85757. * @returns The array of sampler variable neames.
  85758. */
  85759. getSamplers(): string[];
  85760. /**
  85761. * The error from the last compilation.
  85762. * @returns the error string.
  85763. */
  85764. getCompilationError(): string;
  85765. /**
  85766. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  85767. * @param func The callback to be used.
  85768. */
  85769. executeWhenCompiled(func: (effect: Effect) => void): void;
  85770. private _checkIsReady;
  85771. /** @hidden */
  85772. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  85773. /** @hidden */
  85774. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  85775. /** @hidden */
  85776. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  85777. private _processShaderConversion;
  85778. private _processIncludes;
  85779. private _processPrecision;
  85780. /**
  85781. * Recompiles the webGL program
  85782. * @param vertexSourceCode The source code for the vertex shader.
  85783. * @param fragmentSourceCode The source code for the fragment shader.
  85784. * @param onCompiled Callback called when completed.
  85785. * @param onError Callback called on error.
  85786. * @hidden
  85787. */
  85788. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  85789. /**
  85790. * Gets the uniform locations of the the specified variable names
  85791. * @param names THe names of the variables to lookup.
  85792. * @returns Array of locations in the same order as variable names.
  85793. */
  85794. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  85795. /**
  85796. * Prepares the effect
  85797. * @hidden
  85798. */
  85799. _prepareEffect(): void;
  85800. /**
  85801. * Checks if the effect is supported. (Must be called after compilation)
  85802. */
  85803. readonly isSupported: boolean;
  85804. /**
  85805. * Binds a texture to the engine to be used as output of the shader.
  85806. * @param channel Name of the output variable.
  85807. * @param texture Texture to bind.
  85808. * @hidden
  85809. */
  85810. _bindTexture(channel: string, texture: InternalTexture): void;
  85811. /**
  85812. * Sets a texture on the engine to be used in the shader.
  85813. * @param channel Name of the sampler variable.
  85814. * @param texture Texture to set.
  85815. */
  85816. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  85817. /**
  85818. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  85819. * @param channel Name of the sampler variable.
  85820. * @param texture Texture to set.
  85821. */
  85822. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  85823. /**
  85824. * Sets an array of textures on the engine to be used in the shader.
  85825. * @param channel Name of the variable.
  85826. * @param textures Textures to set.
  85827. */
  85828. setTextureArray(channel: string, textures: BaseTexture[]): void;
  85829. /**
  85830. * 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)
  85831. * @param channel Name of the sampler variable.
  85832. * @param postProcess Post process to get the input texture from.
  85833. */
  85834. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  85835. /**
  85836. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  85837. * 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)
  85838. * @param channel Name of the sampler variable.
  85839. * @param postProcess Post process to get the output texture from.
  85840. */
  85841. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  85842. /** @hidden */
  85843. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  85844. /** @hidden */
  85845. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  85846. /** @hidden */
  85847. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  85848. /** @hidden */
  85849. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  85850. /**
  85851. * Binds a buffer to a uniform.
  85852. * @param buffer Buffer to bind.
  85853. * @param name Name of the uniform variable to bind to.
  85854. */
  85855. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  85856. /**
  85857. * Binds block to a uniform.
  85858. * @param blockName Name of the block to bind.
  85859. * @param index Index to bind.
  85860. */
  85861. bindUniformBlock(blockName: string, index: number): void;
  85862. /**
  85863. * Sets an interger value on a uniform variable.
  85864. * @param uniformName Name of the variable.
  85865. * @param value Value to be set.
  85866. * @returns this effect.
  85867. */
  85868. setInt(uniformName: string, value: number): Effect;
  85869. /**
  85870. * Sets an int array on a uniform variable.
  85871. * @param uniformName Name of the variable.
  85872. * @param array array to be set.
  85873. * @returns this effect.
  85874. */
  85875. setIntArray(uniformName: string, array: Int32Array): Effect;
  85876. /**
  85877. * 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)
  85878. * @param uniformName Name of the variable.
  85879. * @param array array to be set.
  85880. * @returns this effect.
  85881. */
  85882. setIntArray2(uniformName: string, array: Int32Array): Effect;
  85883. /**
  85884. * 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)
  85885. * @param uniformName Name of the variable.
  85886. * @param array array to be set.
  85887. * @returns this effect.
  85888. */
  85889. setIntArray3(uniformName: string, array: Int32Array): Effect;
  85890. /**
  85891. * 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)
  85892. * @param uniformName Name of the variable.
  85893. * @param array array to be set.
  85894. * @returns this effect.
  85895. */
  85896. setIntArray4(uniformName: string, array: Int32Array): Effect;
  85897. /**
  85898. * Sets an float array on a uniform variable.
  85899. * @param uniformName Name of the variable.
  85900. * @param array array to be set.
  85901. * @returns this effect.
  85902. */
  85903. setFloatArray(uniformName: string, array: Float32Array): Effect;
  85904. /**
  85905. * 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)
  85906. * @param uniformName Name of the variable.
  85907. * @param array array to be set.
  85908. * @returns this effect.
  85909. */
  85910. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  85911. /**
  85912. * 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)
  85913. * @param uniformName Name of the variable.
  85914. * @param array array to be set.
  85915. * @returns this effect.
  85916. */
  85917. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  85918. /**
  85919. * 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)
  85920. * @param uniformName Name of the variable.
  85921. * @param array array to be set.
  85922. * @returns this effect.
  85923. */
  85924. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  85925. /**
  85926. * Sets an array on a uniform variable.
  85927. * @param uniformName Name of the variable.
  85928. * @param array array to be set.
  85929. * @returns this effect.
  85930. */
  85931. setArray(uniformName: string, array: number[]): Effect;
  85932. /**
  85933. * 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)
  85934. * @param uniformName Name of the variable.
  85935. * @param array array to be set.
  85936. * @returns this effect.
  85937. */
  85938. setArray2(uniformName: string, array: number[]): Effect;
  85939. /**
  85940. * 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)
  85941. * @param uniformName Name of the variable.
  85942. * @param array array to be set.
  85943. * @returns this effect.
  85944. */
  85945. setArray3(uniformName: string, array: number[]): Effect;
  85946. /**
  85947. * 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)
  85948. * @param uniformName Name of the variable.
  85949. * @param array array to be set.
  85950. * @returns this effect.
  85951. */
  85952. setArray4(uniformName: string, array: number[]): Effect;
  85953. /**
  85954. * Sets matrices on a uniform variable.
  85955. * @param uniformName Name of the variable.
  85956. * @param matrices matrices to be set.
  85957. * @returns this effect.
  85958. */
  85959. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  85960. /**
  85961. * Sets matrix on a uniform variable.
  85962. * @param uniformName Name of the variable.
  85963. * @param matrix matrix to be set.
  85964. * @returns this effect.
  85965. */
  85966. setMatrix(uniformName: string, matrix: Matrix): Effect;
  85967. /**
  85968. * 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)
  85969. * @param uniformName Name of the variable.
  85970. * @param matrix matrix to be set.
  85971. * @returns this effect.
  85972. */
  85973. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  85974. /**
  85975. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  85976. * @param uniformName Name of the variable.
  85977. * @param matrix matrix to be set.
  85978. * @returns this effect.
  85979. */
  85980. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  85981. /**
  85982. * Sets a float on a uniform variable.
  85983. * @param uniformName Name of the variable.
  85984. * @param value value to be set.
  85985. * @returns this effect.
  85986. */
  85987. setFloat(uniformName: string, value: number): Effect;
  85988. /**
  85989. * Sets a boolean on a uniform variable.
  85990. * @param uniformName Name of the variable.
  85991. * @param bool value to be set.
  85992. * @returns this effect.
  85993. */
  85994. setBool(uniformName: string, bool: boolean): Effect;
  85995. /**
  85996. * Sets a Vector2 on a uniform variable.
  85997. * @param uniformName Name of the variable.
  85998. * @param vector2 vector2 to be set.
  85999. * @returns this effect.
  86000. */
  86001. setVector2(uniformName: string, vector2: Vector2): Effect;
  86002. /**
  86003. * Sets a float2 on a uniform variable.
  86004. * @param uniformName Name of the variable.
  86005. * @param x First float in float2.
  86006. * @param y Second float in float2.
  86007. * @returns this effect.
  86008. */
  86009. setFloat2(uniformName: string, x: number, y: number): Effect;
  86010. /**
  86011. * Sets a Vector3 on a uniform variable.
  86012. * @param uniformName Name of the variable.
  86013. * @param vector3 Value to be set.
  86014. * @returns this effect.
  86015. */
  86016. setVector3(uniformName: string, vector3: Vector3): Effect;
  86017. /**
  86018. * Sets a float3 on a uniform variable.
  86019. * @param uniformName Name of the variable.
  86020. * @param x First float in float3.
  86021. * @param y Second float in float3.
  86022. * @param z Third float in float3.
  86023. * @returns this effect.
  86024. */
  86025. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  86026. /**
  86027. * Sets a Vector4 on a uniform variable.
  86028. * @param uniformName Name of the variable.
  86029. * @param vector4 Value to be set.
  86030. * @returns this effect.
  86031. */
  86032. setVector4(uniformName: string, vector4: Vector4): Effect;
  86033. /**
  86034. * Sets a float4 on a uniform variable.
  86035. * @param uniformName Name of the variable.
  86036. * @param x First float in float4.
  86037. * @param y Second float in float4.
  86038. * @param z Third float in float4.
  86039. * @param w Fourth float in float4.
  86040. * @returns this effect.
  86041. */
  86042. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  86043. /**
  86044. * Sets a Color3 on a uniform variable.
  86045. * @param uniformName Name of the variable.
  86046. * @param color3 Value to be set.
  86047. * @returns this effect.
  86048. */
  86049. setColor3(uniformName: string, color3: Color3): Effect;
  86050. /**
  86051. * Sets a Color4 on a uniform variable.
  86052. * @param uniformName Name of the variable.
  86053. * @param color3 Value to be set.
  86054. * @param alpha Alpha value to be set.
  86055. * @returns this effect.
  86056. */
  86057. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  86058. /**
  86059. * Sets a Color4 on a uniform variable
  86060. * @param uniformName defines the name of the variable
  86061. * @param color4 defines the value to be set
  86062. * @returns this effect.
  86063. */
  86064. setDirectColor4(uniformName: string, color4: Color4): Effect;
  86065. /**
  86066. * This function will add a new shader to the shader store
  86067. * @param name the name of the shader
  86068. * @param pixelShader optional pixel shader content
  86069. * @param vertexShader optional vertex shader content
  86070. */
  86071. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  86072. /**
  86073. * Store of each shader (The can be looked up using effect.key)
  86074. */
  86075. static ShadersStore: {
  86076. [key: string]: string;
  86077. };
  86078. /**
  86079. * Store of each included file for a shader (The can be looked up using effect.key)
  86080. */
  86081. static IncludesShadersStore: {
  86082. [key: string]: string;
  86083. };
  86084. /**
  86085. * Resets the cache of effects.
  86086. */
  86087. static ResetCache(): void;
  86088. }
  86089. }
  86090. declare module BABYLON {
  86091. /**
  86092. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86093. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86094. * 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;
  86095. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86096. */
  86097. export class ColorCurves {
  86098. private _dirty;
  86099. private _tempColor;
  86100. private _globalCurve;
  86101. private _highlightsCurve;
  86102. private _midtonesCurve;
  86103. private _shadowsCurve;
  86104. private _positiveCurve;
  86105. private _negativeCurve;
  86106. private _globalHue;
  86107. private _globalDensity;
  86108. private _globalSaturation;
  86109. private _globalExposure;
  86110. /**
  86111. * Gets the global Hue value.
  86112. * 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).
  86113. */
  86114. /**
  86115. * Sets the global Hue value.
  86116. * 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).
  86117. */
  86118. globalHue: number;
  86119. /**
  86120. * Gets the global Density value.
  86121. * 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.
  86122. * Values less than zero provide a filter of opposite hue.
  86123. */
  86124. /**
  86125. * Sets the global Density value.
  86126. * 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.
  86127. * Values less than zero provide a filter of opposite hue.
  86128. */
  86129. globalDensity: number;
  86130. /**
  86131. * Gets the global Saturation value.
  86132. * 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.
  86133. */
  86134. /**
  86135. * Sets the global Saturation value.
  86136. * 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.
  86137. */
  86138. globalSaturation: number;
  86139. /**
  86140. * Gets the global Exposure value.
  86141. * 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.
  86142. */
  86143. /**
  86144. * Sets the global Exposure value.
  86145. * 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.
  86146. */
  86147. globalExposure: number;
  86148. private _highlightsHue;
  86149. private _highlightsDensity;
  86150. private _highlightsSaturation;
  86151. private _highlightsExposure;
  86152. /**
  86153. * Gets the highlights Hue value.
  86154. * 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).
  86155. */
  86156. /**
  86157. * Sets the highlights Hue value.
  86158. * 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).
  86159. */
  86160. highlightsHue: number;
  86161. /**
  86162. * Gets the highlights Density value.
  86163. * 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.
  86164. * Values less than zero provide a filter of opposite hue.
  86165. */
  86166. /**
  86167. * Sets the highlights Density value.
  86168. * 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.
  86169. * Values less than zero provide a filter of opposite hue.
  86170. */
  86171. highlightsDensity: number;
  86172. /**
  86173. * Gets the highlights Saturation value.
  86174. * 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.
  86175. */
  86176. /**
  86177. * Sets the highlights Saturation value.
  86178. * 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.
  86179. */
  86180. highlightsSaturation: number;
  86181. /**
  86182. * Gets the highlights Exposure value.
  86183. * 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.
  86184. */
  86185. /**
  86186. * Sets the highlights Exposure value.
  86187. * 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.
  86188. */
  86189. highlightsExposure: number;
  86190. private _midtonesHue;
  86191. private _midtonesDensity;
  86192. private _midtonesSaturation;
  86193. private _midtonesExposure;
  86194. /**
  86195. * Gets the midtones Hue value.
  86196. * 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).
  86197. */
  86198. /**
  86199. * Sets the midtones Hue value.
  86200. * 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).
  86201. */
  86202. midtonesHue: number;
  86203. /**
  86204. * Gets the midtones Density value.
  86205. * 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.
  86206. * Values less than zero provide a filter of opposite hue.
  86207. */
  86208. /**
  86209. * Sets the midtones Density value.
  86210. * 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.
  86211. * Values less than zero provide a filter of opposite hue.
  86212. */
  86213. midtonesDensity: number;
  86214. /**
  86215. * Gets the midtones Saturation value.
  86216. * 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.
  86217. */
  86218. /**
  86219. * Sets the midtones Saturation value.
  86220. * 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.
  86221. */
  86222. midtonesSaturation: number;
  86223. /**
  86224. * Gets the midtones Exposure value.
  86225. * 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.
  86226. */
  86227. /**
  86228. * Sets the midtones Exposure value.
  86229. * 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.
  86230. */
  86231. midtonesExposure: number;
  86232. private _shadowsHue;
  86233. private _shadowsDensity;
  86234. private _shadowsSaturation;
  86235. private _shadowsExposure;
  86236. /**
  86237. * Gets the shadows Hue value.
  86238. * 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).
  86239. */
  86240. /**
  86241. * Sets the shadows Hue value.
  86242. * 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).
  86243. */
  86244. shadowsHue: number;
  86245. /**
  86246. * Gets the shadows Density value.
  86247. * 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.
  86248. * Values less than zero provide a filter of opposite hue.
  86249. */
  86250. /**
  86251. * Sets the shadows Density value.
  86252. * 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.
  86253. * Values less than zero provide a filter of opposite hue.
  86254. */
  86255. shadowsDensity: number;
  86256. /**
  86257. * Gets the shadows Saturation value.
  86258. * 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.
  86259. */
  86260. /**
  86261. * Sets the shadows Saturation value.
  86262. * 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.
  86263. */
  86264. shadowsSaturation: number;
  86265. /**
  86266. * Gets the shadows Exposure value.
  86267. * 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.
  86268. */
  86269. /**
  86270. * Sets the shadows Exposure value.
  86271. * 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.
  86272. */
  86273. shadowsExposure: number;
  86274. /**
  86275. * Returns the class name
  86276. * @returns The class name
  86277. */
  86278. getClassName(): string;
  86279. /**
  86280. * Binds the color curves to the shader.
  86281. * @param colorCurves The color curve to bind
  86282. * @param effect The effect to bind to
  86283. * @param positiveUniform The positive uniform shader parameter
  86284. * @param neutralUniform The neutral uniform shader parameter
  86285. * @param negativeUniform The negative uniform shader parameter
  86286. */
  86287. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86288. /**
  86289. * Prepare the list of uniforms associated with the ColorCurves effects.
  86290. * @param uniformsList The list of uniforms used in the effect
  86291. */
  86292. static PrepareUniforms(uniformsList: string[]): void;
  86293. /**
  86294. * Returns color grading data based on a hue, density, saturation and exposure value.
  86295. * @param filterHue The hue of the color filter.
  86296. * @param filterDensity The density of the color filter.
  86297. * @param saturation The saturation.
  86298. * @param exposure The exposure.
  86299. * @param result The result data container.
  86300. */
  86301. private getColorGradingDataToRef;
  86302. /**
  86303. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86304. * @param value The input slider value in range [-100,100].
  86305. * @returns Adjusted value.
  86306. */
  86307. private static applyColorGradingSliderNonlinear;
  86308. /**
  86309. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86310. * @param hue The hue (H) input.
  86311. * @param saturation The saturation (S) input.
  86312. * @param brightness The brightness (B) input.
  86313. * @result An RGBA color represented as Vector4.
  86314. */
  86315. private static fromHSBToRef;
  86316. /**
  86317. * Returns a value clamped between min and max
  86318. * @param value The value to clamp
  86319. * @param min The minimum of value
  86320. * @param max The maximum of value
  86321. * @returns The clamped value.
  86322. */
  86323. private static clamp;
  86324. /**
  86325. * Clones the current color curve instance.
  86326. * @return The cloned curves
  86327. */
  86328. clone(): ColorCurves;
  86329. /**
  86330. * Serializes the current color curve instance to a json representation.
  86331. * @return a JSON representation
  86332. */
  86333. serialize(): any;
  86334. /**
  86335. * Parses the color curve from a json representation.
  86336. * @param source the JSON source to parse
  86337. * @return The parsed curves
  86338. */
  86339. static Parse(source: any): ColorCurves;
  86340. }
  86341. }
  86342. declare module BABYLON {
  86343. /**
  86344. * Interface to follow in your material defines to integrate easily the
  86345. * Image proccessing functions.
  86346. * @hidden
  86347. */
  86348. export interface IImageProcessingConfigurationDefines {
  86349. IMAGEPROCESSING: boolean;
  86350. VIGNETTE: boolean;
  86351. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86352. VIGNETTEBLENDMODEOPAQUE: boolean;
  86353. TONEMAPPING: boolean;
  86354. TONEMAPPING_ACES: boolean;
  86355. CONTRAST: boolean;
  86356. EXPOSURE: boolean;
  86357. COLORCURVES: boolean;
  86358. COLORGRADING: boolean;
  86359. COLORGRADING3D: boolean;
  86360. SAMPLER3DGREENDEPTH: boolean;
  86361. SAMPLER3DBGRMAP: boolean;
  86362. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86363. }
  86364. /**
  86365. * @hidden
  86366. */
  86367. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86368. IMAGEPROCESSING: boolean;
  86369. VIGNETTE: boolean;
  86370. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86371. VIGNETTEBLENDMODEOPAQUE: boolean;
  86372. TONEMAPPING: boolean;
  86373. TONEMAPPING_ACES: boolean;
  86374. CONTRAST: boolean;
  86375. COLORCURVES: boolean;
  86376. COLORGRADING: boolean;
  86377. COLORGRADING3D: boolean;
  86378. SAMPLER3DGREENDEPTH: boolean;
  86379. SAMPLER3DBGRMAP: boolean;
  86380. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86381. EXPOSURE: boolean;
  86382. constructor();
  86383. }
  86384. /**
  86385. * This groups together the common properties used for image processing either in direct forward pass
  86386. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86387. * or not.
  86388. */
  86389. export class ImageProcessingConfiguration {
  86390. /**
  86391. * Default tone mapping applied in BabylonJS.
  86392. */
  86393. static readonly TONEMAPPING_STANDARD: number;
  86394. /**
  86395. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86396. * to other engines rendering to increase portability.
  86397. */
  86398. static readonly TONEMAPPING_ACES: number;
  86399. /**
  86400. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86401. */
  86402. colorCurves: Nullable<ColorCurves>;
  86403. private _colorCurvesEnabled;
  86404. /**
  86405. * Gets wether the color curves effect is enabled.
  86406. */
  86407. /**
  86408. * Sets wether the color curves effect is enabled.
  86409. */
  86410. colorCurvesEnabled: boolean;
  86411. private _colorGradingTexture;
  86412. /**
  86413. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86414. */
  86415. /**
  86416. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86417. */
  86418. colorGradingTexture: Nullable<BaseTexture>;
  86419. private _colorGradingEnabled;
  86420. /**
  86421. * Gets wether the color grading effect is enabled.
  86422. */
  86423. /**
  86424. * Sets wether the color grading effect is enabled.
  86425. */
  86426. colorGradingEnabled: boolean;
  86427. private _colorGradingWithGreenDepth;
  86428. /**
  86429. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86430. */
  86431. /**
  86432. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86433. */
  86434. colorGradingWithGreenDepth: boolean;
  86435. private _colorGradingBGR;
  86436. /**
  86437. * Gets wether the color grading texture contains BGR values.
  86438. */
  86439. /**
  86440. * Sets wether the color grading texture contains BGR values.
  86441. */
  86442. colorGradingBGR: boolean;
  86443. /** @hidden */
  86444. _exposure: number;
  86445. /**
  86446. * Gets the Exposure used in the effect.
  86447. */
  86448. /**
  86449. * Sets the Exposure used in the effect.
  86450. */
  86451. exposure: number;
  86452. private _toneMappingEnabled;
  86453. /**
  86454. * Gets wether the tone mapping effect is enabled.
  86455. */
  86456. /**
  86457. * Sets wether the tone mapping effect is enabled.
  86458. */
  86459. toneMappingEnabled: boolean;
  86460. private _toneMappingType;
  86461. /**
  86462. * Gets the type of tone mapping effect.
  86463. */
  86464. /**
  86465. * Sets the type of tone mapping effect used in BabylonJS.
  86466. */
  86467. toneMappingType: number;
  86468. protected _contrast: number;
  86469. /**
  86470. * Gets the contrast used in the effect.
  86471. */
  86472. /**
  86473. * Sets the contrast used in the effect.
  86474. */
  86475. contrast: number;
  86476. /**
  86477. * Vignette stretch size.
  86478. */
  86479. vignetteStretch: number;
  86480. /**
  86481. * Vignette centre X Offset.
  86482. */
  86483. vignetteCentreX: number;
  86484. /**
  86485. * Vignette centre Y Offset.
  86486. */
  86487. vignetteCentreY: number;
  86488. /**
  86489. * Vignette weight or intensity of the vignette effect.
  86490. */
  86491. vignetteWeight: number;
  86492. /**
  86493. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86494. * if vignetteEnabled is set to true.
  86495. */
  86496. vignetteColor: Color4;
  86497. /**
  86498. * Camera field of view used by the Vignette effect.
  86499. */
  86500. vignetteCameraFov: number;
  86501. private _vignetteBlendMode;
  86502. /**
  86503. * Gets the vignette blend mode allowing different kind of effect.
  86504. */
  86505. /**
  86506. * Sets the vignette blend mode allowing different kind of effect.
  86507. */
  86508. vignetteBlendMode: number;
  86509. private _vignetteEnabled;
  86510. /**
  86511. * Gets wether the vignette effect is enabled.
  86512. */
  86513. /**
  86514. * Sets wether the vignette effect is enabled.
  86515. */
  86516. vignetteEnabled: boolean;
  86517. private _applyByPostProcess;
  86518. /**
  86519. * Gets wether the image processing is applied through a post process or not.
  86520. */
  86521. /**
  86522. * Sets wether the image processing is applied through a post process or not.
  86523. */
  86524. applyByPostProcess: boolean;
  86525. private _isEnabled;
  86526. /**
  86527. * Gets wether the image processing is enabled or not.
  86528. */
  86529. /**
  86530. * Sets wether the image processing is enabled or not.
  86531. */
  86532. isEnabled: boolean;
  86533. /**
  86534. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86535. */
  86536. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86537. /**
  86538. * Method called each time the image processing information changes requires to recompile the effect.
  86539. */
  86540. protected _updateParameters(): void;
  86541. /**
  86542. * Gets the current class name.
  86543. * @return "ImageProcessingConfiguration"
  86544. */
  86545. getClassName(): string;
  86546. /**
  86547. * Prepare the list of uniforms associated with the Image Processing effects.
  86548. * @param uniforms The list of uniforms used in the effect
  86549. * @param defines the list of defines currently in use
  86550. */
  86551. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86552. /**
  86553. * Prepare the list of samplers associated with the Image Processing effects.
  86554. * @param samplersList The list of uniforms used in the effect
  86555. * @param defines the list of defines currently in use
  86556. */
  86557. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86558. /**
  86559. * Prepare the list of defines associated to the shader.
  86560. * @param defines the list of defines to complete
  86561. * @param forPostProcess Define if we are currently in post process mode or not
  86562. */
  86563. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86564. /**
  86565. * Returns true if all the image processing information are ready.
  86566. * @returns True if ready, otherwise, false
  86567. */
  86568. isReady(): boolean;
  86569. /**
  86570. * Binds the image processing to the shader.
  86571. * @param effect The effect to bind to
  86572. * @param aspectRatio Define the current aspect ratio of the effect
  86573. */
  86574. bind(effect: Effect, aspectRatio?: number): void;
  86575. /**
  86576. * Clones the current image processing instance.
  86577. * @return The cloned image processing
  86578. */
  86579. clone(): ImageProcessingConfiguration;
  86580. /**
  86581. * Serializes the current image processing instance to a json representation.
  86582. * @return a JSON representation
  86583. */
  86584. serialize(): any;
  86585. /**
  86586. * Parses the image processing from a json representation.
  86587. * @param source the JSON source to parse
  86588. * @return The parsed image processing
  86589. */
  86590. static Parse(source: any): ImageProcessingConfiguration;
  86591. private static _VIGNETTEMODE_MULTIPLY;
  86592. private static _VIGNETTEMODE_OPAQUE;
  86593. /**
  86594. * Used to apply the vignette as a mix with the pixel color.
  86595. */
  86596. static readonly VIGNETTEMODE_MULTIPLY: number;
  86597. /**
  86598. * Used to apply the vignette as a replacement of the pixel color.
  86599. */
  86600. static readonly VIGNETTEMODE_OPAQUE: number;
  86601. }
  86602. }
  86603. declare module BABYLON {
  86604. /**
  86605. * This represents all the required information to add a fresnel effect on a material:
  86606. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  86607. */
  86608. export class FresnelParameters {
  86609. private _isEnabled;
  86610. /**
  86611. * Define if the fresnel effect is enable or not.
  86612. */
  86613. isEnabled: boolean;
  86614. /**
  86615. * Define the color used on edges (grazing angle)
  86616. */
  86617. leftColor: Color3;
  86618. /**
  86619. * Define the color used on center
  86620. */
  86621. rightColor: Color3;
  86622. /**
  86623. * Define bias applied to computed fresnel term
  86624. */
  86625. bias: number;
  86626. /**
  86627. * Defined the power exponent applied to fresnel term
  86628. */
  86629. power: number;
  86630. /**
  86631. * Clones the current fresnel and its valuues
  86632. * @returns a clone fresnel configuration
  86633. */
  86634. clone(): FresnelParameters;
  86635. /**
  86636. * Serializes the current fresnel parameters to a JSON representation.
  86637. * @return the JSON serialization
  86638. */
  86639. serialize(): any;
  86640. /**
  86641. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  86642. * @param parsedFresnelParameters Define the JSON representation
  86643. * @returns the parsed parameters
  86644. */
  86645. static Parse(parsedFresnelParameters: any): FresnelParameters;
  86646. }
  86647. }
  86648. declare module BABYLON {
  86649. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  86650. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86651. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86652. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86653. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86654. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86655. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86656. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86657. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86658. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86659. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86660. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86661. /**
  86662. * Decorator used to define property that can be serialized as reference to a camera
  86663. * @param sourceName defines the name of the property to decorate
  86664. */
  86665. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86666. /**
  86667. * Class used to help serialization objects
  86668. */
  86669. export class SerializationHelper {
  86670. /** hidden */
  86671. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  86672. /** hidden */
  86673. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  86674. /** hidden */
  86675. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  86676. /** hidden */
  86677. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  86678. /**
  86679. * Appends the serialized animations from the source animations
  86680. * @param source Source containing the animations
  86681. * @param destination Target to store the animations
  86682. */
  86683. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  86684. /**
  86685. * Static function used to serialized a specific entity
  86686. * @param entity defines the entity to serialize
  86687. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  86688. * @returns a JSON compatible object representing the serialization of the entity
  86689. */
  86690. static Serialize<T>(entity: T, serializationObject?: any): any;
  86691. /**
  86692. * Creates a new entity from a serialization data object
  86693. * @param creationFunction defines a function used to instanciated the new entity
  86694. * @param source defines the source serialization data
  86695. * @param scene defines the hosting scene
  86696. * @param rootUrl defines the root url for resources
  86697. * @returns a new entity
  86698. */
  86699. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  86700. /**
  86701. * Clones an object
  86702. * @param creationFunction defines the function used to instanciate the new object
  86703. * @param source defines the source object
  86704. * @returns the cloned object
  86705. */
  86706. static Clone<T>(creationFunction: () => T, source: T): T;
  86707. /**
  86708. * Instanciates a new object based on a source one (some data will be shared between both object)
  86709. * @param creationFunction defines the function used to instanciate the new object
  86710. * @param source defines the source object
  86711. * @returns the new object
  86712. */
  86713. static Instanciate<T>(creationFunction: () => T, source: T): T;
  86714. }
  86715. }
  86716. declare module BABYLON {
  86717. /**
  86718. * This is the base class of all the camera used in the application.
  86719. * @see http://doc.babylonjs.com/features/cameras
  86720. */
  86721. export class Camera extends Node {
  86722. /** @hidden */
  86723. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  86724. /**
  86725. * This is the default projection mode used by the cameras.
  86726. * It helps recreating a feeling of perspective and better appreciate depth.
  86727. * This is the best way to simulate real life cameras.
  86728. */
  86729. static readonly PERSPECTIVE_CAMERA: number;
  86730. /**
  86731. * This helps creating camera with an orthographic mode.
  86732. * 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.
  86733. */
  86734. static readonly ORTHOGRAPHIC_CAMERA: number;
  86735. /**
  86736. * This is the default FOV mode for perspective cameras.
  86737. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  86738. */
  86739. static readonly FOVMODE_VERTICAL_FIXED: number;
  86740. /**
  86741. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  86742. */
  86743. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  86744. /**
  86745. * This specifies ther is no need for a camera rig.
  86746. * Basically only one eye is rendered corresponding to the camera.
  86747. */
  86748. static readonly RIG_MODE_NONE: number;
  86749. /**
  86750. * Simulates a camera Rig with one blue eye and one red eye.
  86751. * This can be use with 3d blue and red glasses.
  86752. */
  86753. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  86754. /**
  86755. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  86756. */
  86757. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  86758. /**
  86759. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  86760. */
  86761. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  86762. /**
  86763. * Defines that both eyes of the camera will be rendered over under each other.
  86764. */
  86765. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  86766. /**
  86767. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  86768. */
  86769. static readonly RIG_MODE_VR: number;
  86770. /**
  86771. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  86772. */
  86773. static readonly RIG_MODE_WEBVR: number;
  86774. /**
  86775. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  86776. */
  86777. static readonly RIG_MODE_CUSTOM: number;
  86778. /**
  86779. * Defines if by default attaching controls should prevent the default javascript event to continue.
  86780. */
  86781. static ForceAttachControlToAlwaysPreventDefault: boolean;
  86782. /**
  86783. * @hidden
  86784. * Might be removed once multiview will be a thing
  86785. */
  86786. static UseAlternateWebVRRendering: boolean;
  86787. /**
  86788. * Define the input manager associated with the camera.
  86789. */
  86790. inputs: CameraInputsManager<Camera>;
  86791. /** @hidden */
  86792. _position: Vector3;
  86793. /**
  86794. * Define the current local position of the camera in the scene
  86795. */
  86796. position: Vector3;
  86797. /**
  86798. * The vector the camera should consider as up.
  86799. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  86800. */
  86801. upVector: Vector3;
  86802. /**
  86803. * Define the current limit on the left side for an orthographic camera
  86804. * In scene unit
  86805. */
  86806. orthoLeft: Nullable<number>;
  86807. /**
  86808. * Define the current limit on the right side for an orthographic camera
  86809. * In scene unit
  86810. */
  86811. orthoRight: Nullable<number>;
  86812. /**
  86813. * Define the current limit on the bottom side for an orthographic camera
  86814. * In scene unit
  86815. */
  86816. orthoBottom: Nullable<number>;
  86817. /**
  86818. * Define the current limit on the top side for an orthographic camera
  86819. * In scene unit
  86820. */
  86821. orthoTop: Nullable<number>;
  86822. /**
  86823. * Field Of View is set in Radians. (default is 0.8)
  86824. */
  86825. fov: number;
  86826. /**
  86827. * Define the minimum distance the camera can see from.
  86828. * This is important to note that the depth buffer are not infinite and the closer it starts
  86829. * the more your scene might encounter depth fighting issue.
  86830. */
  86831. minZ: number;
  86832. /**
  86833. * Define the maximum distance the camera can see to.
  86834. * This is important to note that the depth buffer are not infinite and the further it end
  86835. * the more your scene might encounter depth fighting issue.
  86836. */
  86837. maxZ: number;
  86838. /**
  86839. * Define the default inertia of the camera.
  86840. * This helps giving a smooth feeling to the camera movement.
  86841. */
  86842. inertia: number;
  86843. /**
  86844. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  86845. */
  86846. mode: number;
  86847. /**
  86848. * Define wether the camera is intermediate.
  86849. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  86850. */
  86851. isIntermediate: boolean;
  86852. /**
  86853. * Define the viewport of the camera.
  86854. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  86855. */
  86856. viewport: Viewport;
  86857. /**
  86858. * Restricts the camera to viewing objects with the same layerMask.
  86859. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  86860. */
  86861. layerMask: number;
  86862. /**
  86863. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  86864. */
  86865. fovMode: number;
  86866. /**
  86867. * Rig mode of the camera.
  86868. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  86869. * This is normally controlled byt the camera themselves as internal use.
  86870. */
  86871. cameraRigMode: number;
  86872. /**
  86873. * Defines the distance between both "eyes" in case of a RIG
  86874. */
  86875. interaxialDistance: number;
  86876. /**
  86877. * Defines if stereoscopic rendering is done side by side or over under.
  86878. */
  86879. isStereoscopicSideBySide: boolean;
  86880. /**
  86881. * 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
  86882. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  86883. * else in the scene.
  86884. */
  86885. customRenderTargets: RenderTargetTexture[];
  86886. /**
  86887. * When set, the camera will render to this render target instead of the default canvas
  86888. */
  86889. outputRenderTarget: Nullable<RenderTargetTexture>;
  86890. /**
  86891. * Observable triggered when the camera view matrix has changed.
  86892. */
  86893. onViewMatrixChangedObservable: Observable<Camera>;
  86894. /**
  86895. * Observable triggered when the camera Projection matrix has changed.
  86896. */
  86897. onProjectionMatrixChangedObservable: Observable<Camera>;
  86898. /**
  86899. * Observable triggered when the inputs have been processed.
  86900. */
  86901. onAfterCheckInputsObservable: Observable<Camera>;
  86902. /**
  86903. * Observable triggered when reset has been called and applied to the camera.
  86904. */
  86905. onRestoreStateObservable: Observable<Camera>;
  86906. /** @hidden */
  86907. _cameraRigParams: any;
  86908. /** @hidden */
  86909. _rigCameras: Camera[];
  86910. /** @hidden */
  86911. _rigPostProcess: Nullable<PostProcess>;
  86912. protected _webvrViewMatrix: Matrix;
  86913. /** @hidden */
  86914. _skipRendering: boolean;
  86915. /** @hidden */
  86916. _alternateCamera: Camera;
  86917. /** @hidden */
  86918. _projectionMatrix: Matrix;
  86919. /** @hidden */
  86920. _postProcesses: Nullable<PostProcess>[];
  86921. /** @hidden */
  86922. _activeMeshes: SmartArray<AbstractMesh>;
  86923. protected _globalPosition: Vector3;
  86924. /** hidden */
  86925. _computedViewMatrix: Matrix;
  86926. private _doNotComputeProjectionMatrix;
  86927. private _transformMatrix;
  86928. private _frustumPlanes;
  86929. private _refreshFrustumPlanes;
  86930. private _storedFov;
  86931. private _stateStored;
  86932. /**
  86933. * Instantiates a new camera object.
  86934. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  86935. * @see http://doc.babylonjs.com/features/cameras
  86936. * @param name Defines the name of the camera in the scene
  86937. * @param position Defines the position of the camera
  86938. * @param scene Defines the scene the camera belongs too
  86939. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  86940. */
  86941. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  86942. /**
  86943. * Store current camera state (fov, position, etc..)
  86944. * @returns the camera
  86945. */
  86946. storeState(): Camera;
  86947. /**
  86948. * Restores the camera state values if it has been stored. You must call storeState() first
  86949. */
  86950. protected _restoreStateValues(): boolean;
  86951. /**
  86952. * Restored camera state. You must call storeState() first.
  86953. * @returns true if restored and false otherwise
  86954. */
  86955. restoreState(): boolean;
  86956. /**
  86957. * Gets the class name of the camera.
  86958. * @returns the class name
  86959. */
  86960. getClassName(): string;
  86961. /** @hidden */
  86962. readonly _isCamera: boolean;
  86963. /**
  86964. * Gets a string representation of the camera useful for debug purpose.
  86965. * @param fullDetails Defines that a more verboe level of logging is required
  86966. * @returns the string representation
  86967. */
  86968. toString(fullDetails?: boolean): string;
  86969. /**
  86970. * Gets the current world space position of the camera.
  86971. */
  86972. readonly globalPosition: Vector3;
  86973. /**
  86974. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  86975. * @returns the active meshe list
  86976. */
  86977. getActiveMeshes(): SmartArray<AbstractMesh>;
  86978. /**
  86979. * Check wether a mesh is part of the current active mesh list of the camera
  86980. * @param mesh Defines the mesh to check
  86981. * @returns true if active, false otherwise
  86982. */
  86983. isActiveMesh(mesh: Mesh): boolean;
  86984. /**
  86985. * Is this camera ready to be used/rendered
  86986. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  86987. * @return true if the camera is ready
  86988. */
  86989. isReady(completeCheck?: boolean): boolean;
  86990. /** @hidden */
  86991. _initCache(): void;
  86992. /** @hidden */
  86993. _updateCache(ignoreParentClass?: boolean): void;
  86994. /** @hidden */
  86995. _isSynchronized(): boolean;
  86996. /** @hidden */
  86997. _isSynchronizedViewMatrix(): boolean;
  86998. /** @hidden */
  86999. _isSynchronizedProjectionMatrix(): boolean;
  87000. /**
  87001. * Attach the input controls to a specific dom element to get the input from.
  87002. * @param element Defines the element the controls should be listened from
  87003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87004. */
  87005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87006. /**
  87007. * Detach the current controls from the specified dom element.
  87008. * @param element Defines the element to stop listening the inputs from
  87009. */
  87010. detachControl(element: HTMLElement): void;
  87011. /**
  87012. * Update the camera state according to the different inputs gathered during the frame.
  87013. */
  87014. update(): void;
  87015. /** @hidden */
  87016. _checkInputs(): void;
  87017. /** @hidden */
  87018. readonly rigCameras: Camera[];
  87019. /**
  87020. * Gets the post process used by the rig cameras
  87021. */
  87022. readonly rigPostProcess: Nullable<PostProcess>;
  87023. /**
  87024. * Internal, gets the first post proces.
  87025. * @returns the first post process to be run on this camera.
  87026. */
  87027. _getFirstPostProcess(): Nullable<PostProcess>;
  87028. private _cascadePostProcessesToRigCams;
  87029. /**
  87030. * Attach a post process to the camera.
  87031. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87032. * @param postProcess The post process to attach to the camera
  87033. * @param insertAt The position of the post process in case several of them are in use in the scene
  87034. * @returns the position the post process has been inserted at
  87035. */
  87036. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  87037. /**
  87038. * Detach a post process to the camera.
  87039. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87040. * @param postProcess The post process to detach from the camera
  87041. */
  87042. detachPostProcess(postProcess: PostProcess): void;
  87043. /**
  87044. * Gets the current world matrix of the camera
  87045. */
  87046. getWorldMatrix(): Matrix;
  87047. /** @hidden */
  87048. _getViewMatrix(): Matrix;
  87049. /**
  87050. * Gets the current view matrix of the camera.
  87051. * @param force forces the camera to recompute the matrix without looking at the cached state
  87052. * @returns the view matrix
  87053. */
  87054. getViewMatrix(force?: boolean): Matrix;
  87055. /**
  87056. * Freeze the projection matrix.
  87057. * It will prevent the cache check of the camera projection compute and can speed up perf
  87058. * if no parameter of the camera are meant to change
  87059. * @param projection Defines manually a projection if necessary
  87060. */
  87061. freezeProjectionMatrix(projection?: Matrix): void;
  87062. /**
  87063. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  87064. */
  87065. unfreezeProjectionMatrix(): void;
  87066. /**
  87067. * Gets the current projection matrix of the camera.
  87068. * @param force forces the camera to recompute the matrix without looking at the cached state
  87069. * @returns the projection matrix
  87070. */
  87071. getProjectionMatrix(force?: boolean): Matrix;
  87072. /**
  87073. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  87074. * @returns a Matrix
  87075. */
  87076. getTransformationMatrix(): Matrix;
  87077. private _updateFrustumPlanes;
  87078. /**
  87079. * Checks if a cullable object (mesh...) is in the camera frustum
  87080. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  87081. * @param target The object to check
  87082. * @returns true if the object is in frustum otherwise false
  87083. */
  87084. isInFrustum(target: ICullable): boolean;
  87085. /**
  87086. * Checks if a cullable object (mesh...) is in the camera frustum
  87087. * Unlike isInFrustum this cheks the full bounding box
  87088. * @param target The object to check
  87089. * @returns true if the object is in frustum otherwise false
  87090. */
  87091. isCompletelyInFrustum(target: ICullable): boolean;
  87092. /**
  87093. * Gets a ray in the forward direction from the camera.
  87094. * @param length Defines the length of the ray to create
  87095. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  87096. * @param origin Defines the start point of the ray which defaults to the camera position
  87097. * @returns the forward ray
  87098. */
  87099. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  87100. /**
  87101. * Releases resources associated with this node.
  87102. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87103. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87104. */
  87105. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87106. /** @hidden */
  87107. _isLeftCamera: boolean;
  87108. /**
  87109. * Gets the left camera of a rig setup in case of Rigged Camera
  87110. */
  87111. readonly isLeftCamera: boolean;
  87112. /** @hidden */
  87113. _isRightCamera: boolean;
  87114. /**
  87115. * Gets the right camera of a rig setup in case of Rigged Camera
  87116. */
  87117. readonly isRightCamera: boolean;
  87118. /**
  87119. * Gets the left camera of a rig setup in case of Rigged Camera
  87120. */
  87121. readonly leftCamera: Nullable<FreeCamera>;
  87122. /**
  87123. * Gets the right camera of a rig setup in case of Rigged Camera
  87124. */
  87125. readonly rightCamera: Nullable<FreeCamera>;
  87126. /**
  87127. * Gets the left camera target of a rig setup in case of Rigged Camera
  87128. * @returns the target position
  87129. */
  87130. getLeftTarget(): Nullable<Vector3>;
  87131. /**
  87132. * Gets the right camera target of a rig setup in case of Rigged Camera
  87133. * @returns the target position
  87134. */
  87135. getRightTarget(): Nullable<Vector3>;
  87136. /**
  87137. * @hidden
  87138. */
  87139. setCameraRigMode(mode: number, rigParams: any): void;
  87140. /** @hidden */
  87141. static _setStereoscopicRigMode(camera: Camera): void;
  87142. /** @hidden */
  87143. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  87144. /** @hidden */
  87145. static _setVRRigMode(camera: Camera, rigParams: any): void;
  87146. /** @hidden */
  87147. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  87148. /** @hidden */
  87149. _getVRProjectionMatrix(): Matrix;
  87150. protected _updateCameraRotationMatrix(): void;
  87151. protected _updateWebVRCameraRotationMatrix(): void;
  87152. /**
  87153. * This function MUST be overwritten by the different WebVR cameras available.
  87154. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87155. * @hidden
  87156. */
  87157. _getWebVRProjectionMatrix(): Matrix;
  87158. /**
  87159. * This function MUST be overwritten by the different WebVR cameras available.
  87160. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87161. * @hidden
  87162. */
  87163. _getWebVRViewMatrix(): Matrix;
  87164. /** @hidden */
  87165. setCameraRigParameter(name: string, value: any): void;
  87166. /**
  87167. * needs to be overridden by children so sub has required properties to be copied
  87168. * @hidden
  87169. */
  87170. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  87171. /**
  87172. * May need to be overridden by children
  87173. * @hidden
  87174. */
  87175. _updateRigCameras(): void;
  87176. /** @hidden */
  87177. _setupInputs(): void;
  87178. /**
  87179. * Serialiaze the camera setup to a json represention
  87180. * @returns the JSON representation
  87181. */
  87182. serialize(): any;
  87183. /**
  87184. * Clones the current camera.
  87185. * @param name The cloned camera name
  87186. * @returns the cloned camera
  87187. */
  87188. clone(name: string): Camera;
  87189. /**
  87190. * Gets the direction of the camera relative to a given local axis.
  87191. * @param localAxis Defines the reference axis to provide a relative direction.
  87192. * @return the direction
  87193. */
  87194. getDirection(localAxis: Vector3): Vector3;
  87195. /**
  87196. * Gets the direction of the camera relative to a given local axis into a passed vector.
  87197. * @param localAxis Defines the reference axis to provide a relative direction.
  87198. * @param result Defines the vector to store the result in
  87199. */
  87200. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  87201. /**
  87202. * Gets a camera constructor for a given camera type
  87203. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  87204. * @param name The name of the camera the result will be able to instantiate
  87205. * @param scene The scene the result will construct the camera in
  87206. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  87207. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  87208. * @returns a factory method to construc the camera
  87209. */
  87210. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  87211. /**
  87212. * Compute the world matrix of the camera.
  87213. * @returns the camera workd matrix
  87214. */
  87215. computeWorldMatrix(): Matrix;
  87216. /**
  87217. * Parse a JSON and creates the camera from the parsed information
  87218. * @param parsedCamera The JSON to parse
  87219. * @param scene The scene to instantiate the camera in
  87220. * @returns the newly constructed camera
  87221. */
  87222. static Parse(parsedCamera: any, scene: Scene): Camera;
  87223. }
  87224. }
  87225. declare module BABYLON {
  87226. /**
  87227. * Interface for any object that can request an animation frame
  87228. */
  87229. export interface ICustomAnimationFrameRequester {
  87230. /**
  87231. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  87232. */
  87233. renderFunction?: Function;
  87234. /**
  87235. * Called to request the next frame to render to
  87236. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  87237. */
  87238. requestAnimationFrame: Function;
  87239. /**
  87240. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  87241. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  87242. */
  87243. requestID?: number;
  87244. }
  87245. /**
  87246. * Interface containing an array of animations
  87247. */
  87248. export interface IAnimatable {
  87249. /**
  87250. * Array of animations
  87251. */
  87252. animations: Array<Animation>;
  87253. }
  87254. /** Interface used by value gradients (color, factor, ...) */
  87255. export interface IValueGradient {
  87256. /**
  87257. * Gets or sets the gradient value (between 0 and 1)
  87258. */
  87259. gradient: number;
  87260. }
  87261. /** Class used to store color4 gradient */
  87262. export class ColorGradient implements IValueGradient {
  87263. /**
  87264. * Gets or sets the gradient value (between 0 and 1)
  87265. */
  87266. gradient: number;
  87267. /**
  87268. * Gets or sets first associated color
  87269. */
  87270. color1: Color4;
  87271. /**
  87272. * Gets or sets second associated color
  87273. */
  87274. color2?: Color4;
  87275. /**
  87276. * Will get a color picked randomly between color1 and color2.
  87277. * If color2 is undefined then color1 will be used
  87278. * @param result defines the target Color4 to store the result in
  87279. */
  87280. getColorToRef(result: Color4): void;
  87281. }
  87282. /** Class used to store color 3 gradient */
  87283. export class Color3Gradient implements IValueGradient {
  87284. /**
  87285. * Gets or sets the gradient value (between 0 and 1)
  87286. */
  87287. gradient: number;
  87288. /**
  87289. * Gets or sets the associated color
  87290. */
  87291. color: Color3;
  87292. }
  87293. /** Class used to store factor gradient */
  87294. export class FactorGradient implements IValueGradient {
  87295. /**
  87296. * Gets or sets the gradient value (between 0 and 1)
  87297. */
  87298. gradient: number;
  87299. /**
  87300. * Gets or sets first associated factor
  87301. */
  87302. factor1: number;
  87303. /**
  87304. * Gets or sets second associated factor
  87305. */
  87306. factor2?: number;
  87307. /**
  87308. * Will get a number picked randomly between factor1 and factor2.
  87309. * If factor2 is undefined then factor1 will be used
  87310. * @returns the picked number
  87311. */
  87312. getFactor(): number;
  87313. }
  87314. /**
  87315. * @ignore
  87316. * Application error to support additional information when loading a file
  87317. */
  87318. export class LoadFileError extends Error {
  87319. /** defines the optional XHR request */
  87320. request?: XMLHttpRequest | undefined;
  87321. private static _setPrototypeOf;
  87322. /**
  87323. * Creates a new LoadFileError
  87324. * @param message defines the message of the error
  87325. * @param request defines the optional XHR request
  87326. */
  87327. constructor(message: string,
  87328. /** defines the optional XHR request */
  87329. request?: XMLHttpRequest | undefined);
  87330. }
  87331. /**
  87332. * Class used to define a retry strategy when error happens while loading assets
  87333. */
  87334. export class RetryStrategy {
  87335. /**
  87336. * Function used to defines an exponential back off strategy
  87337. * @param maxRetries defines the maximum number of retries (3 by default)
  87338. * @param baseInterval defines the interval between retries
  87339. * @returns the strategy function to use
  87340. */
  87341. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87342. }
  87343. /**
  87344. * File request interface
  87345. */
  87346. export interface IFileRequest {
  87347. /**
  87348. * Raised when the request is complete (success or error).
  87349. */
  87350. onCompleteObservable: Observable<IFileRequest>;
  87351. /**
  87352. * Aborts the request for a file.
  87353. */
  87354. abort: () => void;
  87355. }
  87356. /**
  87357. * Class containing a set of static utilities functions
  87358. */
  87359. export class Tools {
  87360. /**
  87361. * Gets or sets the base URL to use to load assets
  87362. */
  87363. static BaseUrl: string;
  87364. /**
  87365. * Enable/Disable Custom HTTP Request Headers globally.
  87366. * default = false
  87367. * @see CustomRequestHeaders
  87368. */
  87369. static UseCustomRequestHeaders: boolean;
  87370. /**
  87371. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  87372. * i.e. when loading files, where the server/service expects an Authorization header.
  87373. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  87374. */
  87375. static CustomRequestHeaders: {
  87376. [key: string]: string;
  87377. };
  87378. /**
  87379. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  87380. */
  87381. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87382. /**
  87383. * Default behaviour for cors in the application.
  87384. * It can be a string if the expected behavior is identical in the entire app.
  87385. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  87386. */
  87387. static CorsBehavior: string | ((url: string | string[]) => string);
  87388. /**
  87389. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  87390. * @ignorenaming
  87391. */
  87392. static UseFallbackTexture: boolean;
  87393. /**
  87394. * Use this object to register external classes like custom textures or material
  87395. * to allow the laoders to instantiate them
  87396. */
  87397. static RegisteredExternalClasses: {
  87398. [key: string]: Object;
  87399. };
  87400. /**
  87401. * Texture content used if a texture cannot loaded
  87402. * @ignorenaming
  87403. */
  87404. static fallbackTexture: string;
  87405. /**
  87406. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  87407. * @param u defines the coordinate on X axis
  87408. * @param v defines the coordinate on Y axis
  87409. * @param width defines the width of the source data
  87410. * @param height defines the height of the source data
  87411. * @param pixels defines the source byte array
  87412. * @param color defines the output color
  87413. */
  87414. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  87415. /**
  87416. * Interpolates between a and b via alpha
  87417. * @param a The lower value (returned when alpha = 0)
  87418. * @param b The upper value (returned when alpha = 1)
  87419. * @param alpha The interpolation-factor
  87420. * @return The mixed value
  87421. */
  87422. static Mix(a: number, b: number, alpha: number): number;
  87423. /**
  87424. * Tries to instantiate a new object from a given class name
  87425. * @param className defines the class name to instantiate
  87426. * @returns the new object or null if the system was not able to do the instantiation
  87427. */
  87428. static Instantiate(className: string): any;
  87429. /**
  87430. * Provides a slice function that will work even on IE
  87431. * @param data defines the array to slice
  87432. * @param start defines the start of the data (optional)
  87433. * @param end defines the end of the data (optional)
  87434. * @returns the new sliced array
  87435. */
  87436. static Slice<T>(data: T, start?: number, end?: number): T;
  87437. /**
  87438. * Polyfill for setImmediate
  87439. * @param action defines the action to execute after the current execution block
  87440. */
  87441. static SetImmediate(action: () => void): void;
  87442. /**
  87443. * Function indicating if a number is an exponent of 2
  87444. * @param value defines the value to test
  87445. * @returns true if the value is an exponent of 2
  87446. */
  87447. static IsExponentOfTwo(value: number): boolean;
  87448. private static _tmpFloatArray;
  87449. /**
  87450. * Returns the nearest 32-bit single precision float representation of a Number
  87451. * @param value A Number. If the parameter is of a different type, it will get converted
  87452. * to a number or to NaN if it cannot be converted
  87453. * @returns number
  87454. */
  87455. static FloatRound(value: number): number;
  87456. /**
  87457. * Find the next highest power of two.
  87458. * @param x Number to start search from.
  87459. * @return Next highest power of two.
  87460. */
  87461. static CeilingPOT(x: number): number;
  87462. /**
  87463. * Find the next lowest power of two.
  87464. * @param x Number to start search from.
  87465. * @return Next lowest power of two.
  87466. */
  87467. static FloorPOT(x: number): number;
  87468. /**
  87469. * Find the nearest power of two.
  87470. * @param x Number to start search from.
  87471. * @return Next nearest power of two.
  87472. */
  87473. static NearestPOT(x: number): number;
  87474. /**
  87475. * Get the closest exponent of two
  87476. * @param value defines the value to approximate
  87477. * @param max defines the maximum value to return
  87478. * @param mode defines how to define the closest value
  87479. * @returns closest exponent of two of the given value
  87480. */
  87481. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  87482. /**
  87483. * Extracts the filename from a path
  87484. * @param path defines the path to use
  87485. * @returns the filename
  87486. */
  87487. static GetFilename(path: string): string;
  87488. /**
  87489. * Extracts the "folder" part of a path (everything before the filename).
  87490. * @param uri The URI to extract the info from
  87491. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  87492. * @returns The "folder" part of the path
  87493. */
  87494. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  87495. /**
  87496. * Extracts text content from a DOM element hierarchy
  87497. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  87498. */
  87499. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  87500. /**
  87501. * Convert an angle in radians to degrees
  87502. * @param angle defines the angle to convert
  87503. * @returns the angle in degrees
  87504. */
  87505. static ToDegrees(angle: number): number;
  87506. /**
  87507. * Convert an angle in degrees to radians
  87508. * @param angle defines the angle to convert
  87509. * @returns the angle in radians
  87510. */
  87511. static ToRadians(angle: number): number;
  87512. /**
  87513. * Encode a buffer to a base64 string
  87514. * @param buffer defines the buffer to encode
  87515. * @returns the encoded string
  87516. */
  87517. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  87518. /**
  87519. * Extracts minimum and maximum values from a list of indexed positions
  87520. * @param positions defines the positions to use
  87521. * @param indices defines the indices to the positions
  87522. * @param indexStart defines the start index
  87523. * @param indexCount defines the end index
  87524. * @param bias defines bias value to add to the result
  87525. * @return minimum and maximum values
  87526. */
  87527. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87528. minimum: Vector3;
  87529. maximum: Vector3;
  87530. };
  87531. /**
  87532. * Extracts minimum and maximum values from a list of positions
  87533. * @param positions defines the positions to use
  87534. * @param start defines the start index in the positions array
  87535. * @param count defines the number of positions to handle
  87536. * @param bias defines bias value to add to the result
  87537. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87538. * @return minimum and maximum values
  87539. */
  87540. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87541. minimum: Vector3;
  87542. maximum: Vector3;
  87543. };
  87544. /**
  87545. * Returns an array if obj is not an array
  87546. * @param obj defines the object to evaluate as an array
  87547. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  87548. * @returns either obj directly if obj is an array or a new array containing obj
  87549. */
  87550. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  87551. /**
  87552. * Gets the pointer prefix to use
  87553. * @returns "pointer" if touch is enabled. Else returns "mouse"
  87554. */
  87555. static GetPointerPrefix(): string;
  87556. /**
  87557. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  87558. * @param func - the function to be called
  87559. * @param requester - the object that will request the next frame. Falls back to window.
  87560. * @returns frame number
  87561. */
  87562. static QueueNewFrame(func: () => void, requester?: any): number;
  87563. /**
  87564. * Ask the browser to promote the current element to fullscreen rendering mode
  87565. * @param element defines the DOM element to promote
  87566. */
  87567. static RequestFullscreen(element: HTMLElement): void;
  87568. /**
  87569. * Asks the browser to exit fullscreen mode
  87570. */
  87571. static ExitFullscreen(): void;
  87572. /**
  87573. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  87574. * @param url define the url we are trying
  87575. * @param element define the dom element where to configure the cors policy
  87576. */
  87577. static SetCorsBehavior(url: string | string[], element: {
  87578. crossOrigin: string | null;
  87579. }): void;
  87580. /**
  87581. * Removes unwanted characters from an url
  87582. * @param url defines the url to clean
  87583. * @returns the cleaned url
  87584. */
  87585. static CleanUrl(url: string): string;
  87586. /**
  87587. * Gets or sets a function used to pre-process url before using them to load assets
  87588. */
  87589. static PreprocessUrl: (url: string) => string;
  87590. /**
  87591. * Loads an image as an HTMLImageElement.
  87592. * @param input url string, ArrayBuffer, or Blob to load
  87593. * @param onLoad callback called when the image successfully loads
  87594. * @param onError callback called when the image fails to load
  87595. * @param offlineProvider offline provider for caching
  87596. * @returns the HTMLImageElement of the loaded image
  87597. */
  87598. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  87599. /**
  87600. * Loads a file
  87601. * @param url url string, ArrayBuffer, or Blob to load
  87602. * @param onSuccess callback called when the file successfully loads
  87603. * @param onProgress callback called while file is loading (if the server supports this mode)
  87604. * @param offlineProvider defines the offline provider for caching
  87605. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  87606. * @param onError callback called when the file fails to load
  87607. * @returns a file request object
  87608. */
  87609. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  87610. /**
  87611. * Load a script (identified by an url). When the url returns, the
  87612. * content of this file is added into a new script element, attached to the DOM (body element)
  87613. * @param scriptUrl defines the url of the script to laod
  87614. * @param onSuccess defines the callback called when the script is loaded
  87615. * @param onError defines the callback to call if an error occurs
  87616. */
  87617. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  87618. /**
  87619. * Loads a file from a blob
  87620. * @param fileToLoad defines the blob to use
  87621. * @param callback defines the callback to call when data is loaded
  87622. * @param progressCallback defines the callback to call during loading process
  87623. * @returns a file request object
  87624. */
  87625. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  87626. /**
  87627. * Loads a file
  87628. * @param fileToLoad defines the file to load
  87629. * @param callback defines the callback to call when data is loaded
  87630. * @param progressCallBack defines the callback to call during loading process
  87631. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  87632. * @returns a file request object
  87633. */
  87634. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  87635. /**
  87636. * Creates a data url from a given string content
  87637. * @param content defines the content to convert
  87638. * @returns the new data url link
  87639. */
  87640. static FileAsURL(content: string): string;
  87641. /**
  87642. * Format the given number to a specific decimal format
  87643. * @param value defines the number to format
  87644. * @param decimals defines the number of decimals to use
  87645. * @returns the formatted string
  87646. */
  87647. static Format(value: number, decimals?: number): string;
  87648. /**
  87649. * Checks if a given vector is inside a specific range
  87650. * @param v defines the vector to test
  87651. * @param min defines the minimum range
  87652. * @param max defines the maximum range
  87653. */
  87654. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  87655. /**
  87656. * Tries to copy an object by duplicating every property
  87657. * @param source defines the source object
  87658. * @param destination defines the target object
  87659. * @param doNotCopyList defines a list of properties to avoid
  87660. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  87661. */
  87662. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  87663. /**
  87664. * Gets a boolean indicating if the given object has no own property
  87665. * @param obj defines the object to test
  87666. * @returns true if object has no own property
  87667. */
  87668. static IsEmpty(obj: any): boolean;
  87669. /**
  87670. * Function used to register events at window level
  87671. * @param events defines the events to register
  87672. */
  87673. static RegisterTopRootEvents(events: {
  87674. name: string;
  87675. handler: Nullable<(e: FocusEvent) => any>;
  87676. }[]): void;
  87677. /**
  87678. * Function used to unregister events from window level
  87679. * @param events defines the events to unregister
  87680. */
  87681. static UnregisterTopRootEvents(events: {
  87682. name: string;
  87683. handler: Nullable<(e: FocusEvent) => any>;
  87684. }[]): void;
  87685. /**
  87686. * @ignore
  87687. */
  87688. static _ScreenshotCanvas: HTMLCanvasElement;
  87689. /**
  87690. * Dumps the current bound framebuffer
  87691. * @param width defines the rendering width
  87692. * @param height defines the rendering height
  87693. * @param engine defines the hosting engine
  87694. * @param successCallback defines the callback triggered once the data are available
  87695. * @param mimeType defines the mime type of the result
  87696. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  87697. */
  87698. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87699. /**
  87700. * Converts the canvas data to blob.
  87701. * This acts as a polyfill for browsers not supporting the to blob function.
  87702. * @param canvas Defines the canvas to extract the data from
  87703. * @param successCallback Defines the callback triggered once the data are available
  87704. * @param mimeType Defines the mime type of the result
  87705. */
  87706. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  87707. /**
  87708. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  87709. * @param successCallback defines the callback triggered once the data are available
  87710. * @param mimeType defines the mime type of the result
  87711. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  87712. */
  87713. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87714. /**
  87715. * Downloads a blob in the browser
  87716. * @param blob defines the blob to download
  87717. * @param fileName defines the name of the downloaded file
  87718. */
  87719. static Download(blob: Blob, fileName: string): void;
  87720. /**
  87721. * Captures a screenshot of the current rendering
  87722. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87723. * @param engine defines the rendering engine
  87724. * @param camera defines the source camera
  87725. * @param size This parameter can be set to a single number or to an object with the
  87726. * following (optional) properties: precision, width, height. If a single number is passed,
  87727. * it will be used for both width and height. If an object is passed, the screenshot size
  87728. * will be derived from the parameters. The precision property is a multiplier allowing
  87729. * rendering at a higher or lower resolution
  87730. * @param successCallback defines the callback receives a single parameter which contains the
  87731. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87732. * src parameter of an <img> to display it
  87733. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  87734. * Check your browser for supported MIME types
  87735. */
  87736. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  87737. /**
  87738. * Generates an image screenshot from the specified camera.
  87739. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87740. * @param engine The engine to use for rendering
  87741. * @param camera The camera to use for rendering
  87742. * @param size This parameter can be set to a single number or to an object with the
  87743. * following (optional) properties: precision, width, height. If a single number is passed,
  87744. * it will be used for both width and height. If an object is passed, the screenshot size
  87745. * will be derived from the parameters. The precision property is a multiplier allowing
  87746. * rendering at a higher or lower resolution
  87747. * @param successCallback The callback receives a single parameter which contains the
  87748. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87749. * src parameter of an <img> to display it
  87750. * @param mimeType The MIME type of the screenshot image (default: image/png).
  87751. * Check your browser for supported MIME types
  87752. * @param samples Texture samples (default: 1)
  87753. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  87754. * @param fileName A name for for the downloaded file.
  87755. */
  87756. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  87757. /**
  87758. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87759. * Be aware Math.random() could cause collisions, but:
  87760. * "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"
  87761. * @returns a pseudo random id
  87762. */
  87763. static RandomId(): string;
  87764. /**
  87765. * Test if the given uri is a base64 string
  87766. * @param uri The uri to test
  87767. * @return True if the uri is a base64 string or false otherwise
  87768. */
  87769. static IsBase64(uri: string): boolean;
  87770. /**
  87771. * Decode the given base64 uri.
  87772. * @param uri The uri to decode
  87773. * @return The decoded base64 data.
  87774. */
  87775. static DecodeBase64(uri: string): ArrayBuffer;
  87776. /**
  87777. * No log
  87778. */
  87779. static readonly NoneLogLevel: number;
  87780. /**
  87781. * Only message logs
  87782. */
  87783. static readonly MessageLogLevel: number;
  87784. /**
  87785. * Only warning logs
  87786. */
  87787. static readonly WarningLogLevel: number;
  87788. /**
  87789. * Only error logs
  87790. */
  87791. static readonly ErrorLogLevel: number;
  87792. /**
  87793. * All logs
  87794. */
  87795. static readonly AllLogLevel: number;
  87796. /**
  87797. * Gets a value indicating the number of loading errors
  87798. * @ignorenaming
  87799. */
  87800. static readonly errorsCount: number;
  87801. /**
  87802. * Callback called when a new log is added
  87803. */
  87804. static OnNewCacheEntry: (entry: string) => void;
  87805. /**
  87806. * Log a message to the console
  87807. * @param message defines the message to log
  87808. */
  87809. static Log(message: string): void;
  87810. /**
  87811. * Write a warning message to the console
  87812. * @param message defines the message to log
  87813. */
  87814. static Warn(message: string): void;
  87815. /**
  87816. * Write an error message to the console
  87817. * @param message defines the message to log
  87818. */
  87819. static Error(message: string): void;
  87820. /**
  87821. * Gets current log cache (list of logs)
  87822. */
  87823. static readonly LogCache: string;
  87824. /**
  87825. * Clears the log cache
  87826. */
  87827. static ClearLogCache(): void;
  87828. /**
  87829. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  87830. */
  87831. static LogLevels: number;
  87832. /**
  87833. * Checks if the loaded document was accessed via `file:`-Protocol.
  87834. * @returns boolean
  87835. */
  87836. static IsFileURL(): boolean;
  87837. /**
  87838. * Checks if the window object exists
  87839. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  87840. */
  87841. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  87842. /**
  87843. * No performance log
  87844. */
  87845. static readonly PerformanceNoneLogLevel: number;
  87846. /**
  87847. * Use user marks to log performance
  87848. */
  87849. static readonly PerformanceUserMarkLogLevel: number;
  87850. /**
  87851. * Log performance to the console
  87852. */
  87853. static readonly PerformanceConsoleLogLevel: number;
  87854. private static _performance;
  87855. /**
  87856. * Sets the current performance log level
  87857. */
  87858. static PerformanceLogLevel: number;
  87859. private static _StartPerformanceCounterDisabled;
  87860. private static _EndPerformanceCounterDisabled;
  87861. private static _StartUserMark;
  87862. private static _EndUserMark;
  87863. private static _StartPerformanceConsole;
  87864. private static _EndPerformanceConsole;
  87865. /**
  87866. * Injects the @see CustomRequestHeaders into the given request
  87867. * @param request the request that should be used for injection
  87868. */
  87869. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  87870. /**
  87871. * Starts a performance counter
  87872. */
  87873. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  87874. /**
  87875. * Ends a specific performance coutner
  87876. */
  87877. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  87878. /**
  87879. * Gets either window.performance.now() if supported or Date.now() else
  87880. */
  87881. static readonly Now: number;
  87882. /**
  87883. * This method will return the name of the class used to create the instance of the given object.
  87884. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  87885. * @param object the object to get the class name from
  87886. * @param isType defines if the object is actually a type
  87887. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  87888. */
  87889. static GetClassName(object: any, isType?: boolean): string;
  87890. /**
  87891. * Gets the first element of an array satisfying a given predicate
  87892. * @param array defines the array to browse
  87893. * @param predicate defines the predicate to use
  87894. * @returns null if not found or the element
  87895. */
  87896. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  87897. /**
  87898. * This method will return the name of the full name of the class, including its owning module (if any).
  87899. * 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).
  87900. * @param object the object to get the class name from
  87901. * @param isType defines if the object is actually a type
  87902. * @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.
  87903. * @ignorenaming
  87904. */
  87905. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  87906. /**
  87907. * Returns a promise that resolves after the given amount of time.
  87908. * @param delay Number of milliseconds to delay
  87909. * @returns Promise that resolves after the given amount of time
  87910. */
  87911. static DelayAsync(delay: number): Promise<void>;
  87912. /**
  87913. * Gets the current gradient from an array of IValueGradient
  87914. * @param ratio defines the current ratio to get
  87915. * @param gradients defines the array of IValueGradient
  87916. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  87917. */
  87918. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  87919. }
  87920. /**
  87921. * This class is used to track a performance counter which is number based.
  87922. * The user has access to many properties which give statistics of different nature.
  87923. *
  87924. * The implementer can track two kinds of Performance Counter: time and count.
  87925. * 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.
  87926. * 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.
  87927. */
  87928. export class PerfCounter {
  87929. /**
  87930. * Gets or sets a global boolean to turn on and off all the counters
  87931. */
  87932. static Enabled: boolean;
  87933. /**
  87934. * Returns the smallest value ever
  87935. */
  87936. readonly min: number;
  87937. /**
  87938. * Returns the biggest value ever
  87939. */
  87940. readonly max: number;
  87941. /**
  87942. * Returns the average value since the performance counter is running
  87943. */
  87944. readonly average: number;
  87945. /**
  87946. * Returns the average value of the last second the counter was monitored
  87947. */
  87948. readonly lastSecAverage: number;
  87949. /**
  87950. * Returns the current value
  87951. */
  87952. readonly current: number;
  87953. /**
  87954. * Gets the accumulated total
  87955. */
  87956. readonly total: number;
  87957. /**
  87958. * Gets the total value count
  87959. */
  87960. readonly count: number;
  87961. /**
  87962. * Creates a new counter
  87963. */
  87964. constructor();
  87965. /**
  87966. * Call this method to start monitoring a new frame.
  87967. * 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.
  87968. */
  87969. fetchNewFrame(): void;
  87970. /**
  87971. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  87972. * @param newCount the count value to add to the monitored count
  87973. * @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.
  87974. */
  87975. addCount(newCount: number, fetchResult: boolean): void;
  87976. /**
  87977. * Start monitoring this performance counter
  87978. */
  87979. beginMonitoring(): void;
  87980. /**
  87981. * Compute the time lapsed since the previous beginMonitoring() call.
  87982. * @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
  87983. */
  87984. endMonitoring(newFrame?: boolean): void;
  87985. private _fetchResult;
  87986. private _startMonitoringTime;
  87987. private _min;
  87988. private _max;
  87989. private _average;
  87990. private _current;
  87991. private _totalValueCount;
  87992. private _totalAccumulated;
  87993. private _lastSecAverage;
  87994. private _lastSecAccumulated;
  87995. private _lastSecTime;
  87996. private _lastSecValueCount;
  87997. }
  87998. /**
  87999. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  88000. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  88001. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  88002. * @param name The name of the class, case should be preserved
  88003. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  88004. */
  88005. export function className(name: string, module?: string): (target: Object) => void;
  88006. /**
  88007. * An implementation of a loop for asynchronous functions.
  88008. */
  88009. export class AsyncLoop {
  88010. /**
  88011. * Defines the number of iterations for the loop
  88012. */
  88013. iterations: number;
  88014. /**
  88015. * Defines the current index of the loop.
  88016. */
  88017. index: number;
  88018. private _done;
  88019. private _fn;
  88020. private _successCallback;
  88021. /**
  88022. * Constructor.
  88023. * @param iterations the number of iterations.
  88024. * @param func the function to run each iteration
  88025. * @param successCallback the callback that will be called upon succesful execution
  88026. * @param offset starting offset.
  88027. */
  88028. constructor(
  88029. /**
  88030. * Defines the number of iterations for the loop
  88031. */
  88032. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  88033. /**
  88034. * Execute the next iteration. Must be called after the last iteration was finished.
  88035. */
  88036. executeNext(): void;
  88037. /**
  88038. * Break the loop and run the success callback.
  88039. */
  88040. breakLoop(): void;
  88041. /**
  88042. * Create and run an async loop.
  88043. * @param iterations the number of iterations.
  88044. * @param fn the function to run each iteration
  88045. * @param successCallback the callback that will be called upon succesful execution
  88046. * @param offset starting offset.
  88047. * @returns the created async loop object
  88048. */
  88049. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  88050. /**
  88051. * A for-loop that will run a given number of iterations synchronous and the rest async.
  88052. * @param iterations total number of iterations
  88053. * @param syncedIterations number of synchronous iterations in each async iteration.
  88054. * @param fn the function to call each iteration.
  88055. * @param callback a success call back that will be called when iterating stops.
  88056. * @param breakFunction a break condition (optional)
  88057. * @param timeout timeout settings for the setTimeout function. default - 0.
  88058. * @returns the created async loop object
  88059. */
  88060. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  88061. }
  88062. }
  88063. declare module BABYLON {
  88064. /** @hidden */
  88065. export interface ICollisionCoordinator {
  88066. createCollider(): Collider;
  88067. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88068. init(scene: Scene): void;
  88069. }
  88070. /** @hidden */
  88071. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  88072. private _scene;
  88073. private _scaledPosition;
  88074. private _scaledVelocity;
  88075. private _finalPosition;
  88076. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88077. createCollider(): Collider;
  88078. init(scene: Scene): void;
  88079. private _collideWithWorld;
  88080. }
  88081. }
  88082. declare module BABYLON {
  88083. /**
  88084. * This class defines the direct association between an animation and a target
  88085. */
  88086. export class TargetedAnimation {
  88087. /**
  88088. * Animation to perform
  88089. */
  88090. animation: Animation;
  88091. /**
  88092. * Target to animate
  88093. */
  88094. target: any;
  88095. }
  88096. /**
  88097. * Use this class to create coordinated animations on multiple targets
  88098. */
  88099. export class AnimationGroup implements IDisposable {
  88100. /** The name of the animation group */
  88101. name: string;
  88102. private _scene;
  88103. private _targetedAnimations;
  88104. private _animatables;
  88105. private _from;
  88106. private _to;
  88107. private _isStarted;
  88108. private _isPaused;
  88109. private _speedRatio;
  88110. /**
  88111. * Gets or sets the unique id of the node
  88112. */
  88113. uniqueId: number;
  88114. /**
  88115. * This observable will notify when one animation have ended
  88116. */
  88117. onAnimationEndObservable: Observable<TargetedAnimation>;
  88118. /**
  88119. * Observer raised when one animation loops
  88120. */
  88121. onAnimationLoopObservable: Observable<TargetedAnimation>;
  88122. /**
  88123. * This observable will notify when all animations have ended.
  88124. */
  88125. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  88126. /**
  88127. * This observable will notify when all animations have paused.
  88128. */
  88129. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  88130. /**
  88131. * This observable will notify when all animations are playing.
  88132. */
  88133. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  88134. /**
  88135. * Gets the first frame
  88136. */
  88137. readonly from: number;
  88138. /**
  88139. * Gets the last frame
  88140. */
  88141. readonly to: number;
  88142. /**
  88143. * Define if the animations are started
  88144. */
  88145. readonly isStarted: boolean;
  88146. /**
  88147. * Gets a value indicating that the current group is playing
  88148. */
  88149. readonly isPlaying: boolean;
  88150. /**
  88151. * Gets or sets the speed ratio to use for all animations
  88152. */
  88153. /**
  88154. * Gets or sets the speed ratio to use for all animations
  88155. */
  88156. speedRatio: number;
  88157. /**
  88158. * Gets the targeted animations for this animation group
  88159. */
  88160. readonly targetedAnimations: Array<TargetedAnimation>;
  88161. /**
  88162. * returning the list of animatables controlled by this animation group.
  88163. */
  88164. readonly animatables: Array<Animatable>;
  88165. /**
  88166. * Instantiates a new Animation Group.
  88167. * This helps managing several animations at once.
  88168. * @see http://doc.babylonjs.com/how_to/group
  88169. * @param name Defines the name of the group
  88170. * @param scene Defines the scene the group belongs to
  88171. */
  88172. constructor(
  88173. /** The name of the animation group */
  88174. name: string, scene?: Nullable<Scene>);
  88175. /**
  88176. * Add an animation (with its target) in the group
  88177. * @param animation defines the animation we want to add
  88178. * @param target defines the target of the animation
  88179. * @returns the TargetedAnimation object
  88180. */
  88181. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  88182. /**
  88183. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  88184. * It can add constant keys at begin or end
  88185. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  88186. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  88187. * @returns the animation group
  88188. */
  88189. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  88190. /**
  88191. * Start all animations on given targets
  88192. * @param loop defines if animations must loop
  88193. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  88194. * @param from defines the from key (optional)
  88195. * @param to defines the to key (optional)
  88196. * @returns the current animation group
  88197. */
  88198. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  88199. /**
  88200. * Pause all animations
  88201. * @returns the animation group
  88202. */
  88203. pause(): AnimationGroup;
  88204. /**
  88205. * Play all animations to initial state
  88206. * This function will start() the animations if they were not started or will restart() them if they were paused
  88207. * @param loop defines if animations must loop
  88208. * @returns the animation group
  88209. */
  88210. play(loop?: boolean): AnimationGroup;
  88211. /**
  88212. * Reset all animations to initial state
  88213. * @returns the animation group
  88214. */
  88215. reset(): AnimationGroup;
  88216. /**
  88217. * Restart animations from key 0
  88218. * @returns the animation group
  88219. */
  88220. restart(): AnimationGroup;
  88221. /**
  88222. * Stop all animations
  88223. * @returns the animation group
  88224. */
  88225. stop(): AnimationGroup;
  88226. /**
  88227. * Set animation weight for all animatables
  88228. * @param weight defines the weight to use
  88229. * @return the animationGroup
  88230. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88231. */
  88232. setWeightForAllAnimatables(weight: number): AnimationGroup;
  88233. /**
  88234. * Synchronize and normalize all animatables with a source animatable
  88235. * @param root defines the root animatable to synchronize with
  88236. * @return the animationGroup
  88237. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88238. */
  88239. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  88240. /**
  88241. * Goes to a specific frame in this animation group
  88242. * @param frame the frame number to go to
  88243. * @return the animationGroup
  88244. */
  88245. goToFrame(frame: number): AnimationGroup;
  88246. /**
  88247. * Dispose all associated resources
  88248. */
  88249. dispose(): void;
  88250. private _checkAnimationGroupEnded;
  88251. /**
  88252. * Clone the current animation group and returns a copy
  88253. * @param newName defines the name of the new group
  88254. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  88255. * @returns the new aniamtion group
  88256. */
  88257. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  88258. /**
  88259. * Returns a new AnimationGroup object parsed from the source provided.
  88260. * @param parsedAnimationGroup defines the source
  88261. * @param scene defines the scene that will receive the animationGroup
  88262. * @returns a new AnimationGroup
  88263. */
  88264. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  88265. /**
  88266. * Returns the string "AnimationGroup"
  88267. * @returns "AnimationGroup"
  88268. */
  88269. getClassName(): string;
  88270. /**
  88271. * Creates a detailled string about the object
  88272. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  88273. * @returns a string representing the object
  88274. */
  88275. toString(fullDetails?: boolean): string;
  88276. }
  88277. }
  88278. declare module BABYLON {
  88279. /**
  88280. * Define an interface for all classes that will hold resources
  88281. */
  88282. export interface IDisposable {
  88283. /**
  88284. * Releases all held resources
  88285. */
  88286. dispose(): void;
  88287. }
  88288. /** Interface defining initialization parameters for Scene class */
  88289. export interface SceneOptions {
  88290. /**
  88291. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  88292. * It will improve performance when the number of geometries becomes important.
  88293. */
  88294. useGeometryUniqueIdsMap?: boolean;
  88295. /**
  88296. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  88297. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88298. */
  88299. useMaterialMeshMap?: boolean;
  88300. /**
  88301. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  88302. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88303. */
  88304. useClonedMeshhMap?: boolean;
  88305. }
  88306. /**
  88307. * Represents a scene to be rendered by the engine.
  88308. * @see http://doc.babylonjs.com/features/scene
  88309. */
  88310. export class Scene extends AbstractScene implements IAnimatable {
  88311. private static _uniqueIdCounter;
  88312. /** The fog is deactivated */
  88313. static readonly FOGMODE_NONE: number;
  88314. /** The fog density is following an exponential function */
  88315. static readonly FOGMODE_EXP: number;
  88316. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  88317. static readonly FOGMODE_EXP2: number;
  88318. /** The fog density is following a linear function. */
  88319. static readonly FOGMODE_LINEAR: number;
  88320. /**
  88321. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  88322. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88323. */
  88324. static MinDeltaTime: number;
  88325. /**
  88326. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  88327. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88328. */
  88329. static MaxDeltaTime: number;
  88330. /**
  88331. * Factory used to create the default material.
  88332. * @param name The name of the material to create
  88333. * @param scene The scene to create the material for
  88334. * @returns The default material
  88335. */
  88336. static DefaultMaterialFactory(scene: Scene): Material;
  88337. /**
  88338. * Factory used to create the a collision coordinator.
  88339. * @returns The collision coordinator
  88340. */
  88341. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  88342. /** @hidden */
  88343. readonly _isScene: boolean;
  88344. /**
  88345. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  88346. */
  88347. autoClear: boolean;
  88348. /**
  88349. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  88350. */
  88351. autoClearDepthAndStencil: boolean;
  88352. /**
  88353. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  88354. */
  88355. clearColor: Color4;
  88356. /**
  88357. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  88358. */
  88359. ambientColor: Color3;
  88360. /** @hidden */
  88361. _environmentBRDFTexture: BaseTexture;
  88362. /** @hidden */
  88363. protected _environmentTexture: Nullable<BaseTexture>;
  88364. /**
  88365. * Texture used in all pbr material as the reflection texture.
  88366. * As in the majority of the scene they are the same (exception for multi room and so on),
  88367. * this is easier to reference from here than from all the materials.
  88368. */
  88369. /**
  88370. * Texture used in all pbr material as the reflection texture.
  88371. * As in the majority of the scene they are the same (exception for multi room and so on),
  88372. * this is easier to set here than in all the materials.
  88373. */
  88374. environmentTexture: Nullable<BaseTexture>;
  88375. /** @hidden */
  88376. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  88377. /**
  88378. * Default image processing configuration used either in the rendering
  88379. * Forward main pass or through the imageProcessingPostProcess if present.
  88380. * As in the majority of the scene they are the same (exception for multi camera),
  88381. * this is easier to reference from here than from all the materials and post process.
  88382. *
  88383. * No setter as we it is a shared configuration, you can set the values instead.
  88384. */
  88385. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  88386. private _forceWireframe;
  88387. /**
  88388. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  88389. */
  88390. forceWireframe: boolean;
  88391. private _forcePointsCloud;
  88392. /**
  88393. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  88394. */
  88395. forcePointsCloud: boolean;
  88396. /**
  88397. * Gets or sets the active clipplane 1
  88398. */
  88399. clipPlane: Nullable<Plane>;
  88400. /**
  88401. * Gets or sets the active clipplane 2
  88402. */
  88403. clipPlane2: Nullable<Plane>;
  88404. /**
  88405. * Gets or sets the active clipplane 3
  88406. */
  88407. clipPlane3: Nullable<Plane>;
  88408. /**
  88409. * Gets or sets the active clipplane 4
  88410. */
  88411. clipPlane4: Nullable<Plane>;
  88412. /**
  88413. * Gets or sets a boolean indicating if animations are enabled
  88414. */
  88415. animationsEnabled: boolean;
  88416. private _animationPropertiesOverride;
  88417. /**
  88418. * Gets or sets the animation properties override
  88419. */
  88420. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88421. /**
  88422. * Gets or sets a boolean indicating if a constant deltatime has to be used
  88423. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  88424. */
  88425. useConstantAnimationDeltaTime: boolean;
  88426. /**
  88427. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  88428. * Please note that it requires to run a ray cast through the scene on every frame
  88429. */
  88430. constantlyUpdateMeshUnderPointer: boolean;
  88431. /**
  88432. * Defines the HTML cursor to use when hovering over interactive elements
  88433. */
  88434. hoverCursor: string;
  88435. /**
  88436. * Defines the HTML default cursor to use (empty by default)
  88437. */
  88438. defaultCursor: string;
  88439. /**
  88440. * This is used to call preventDefault() on pointer down
  88441. * in order to block unwanted artifacts like system double clicks
  88442. */
  88443. preventDefaultOnPointerDown: boolean;
  88444. /**
  88445. * This is used to call preventDefault() on pointer up
  88446. * in order to block unwanted artifacts like system double clicks
  88447. */
  88448. preventDefaultOnPointerUp: boolean;
  88449. /**
  88450. * Gets or sets user defined metadata
  88451. */
  88452. metadata: any;
  88453. /**
  88454. * For internal use only. Please do not use.
  88455. */
  88456. reservedDataStore: any;
  88457. /**
  88458. * Gets the name of the plugin used to load this scene (null by default)
  88459. */
  88460. loadingPluginName: string;
  88461. /**
  88462. * Use this array to add regular expressions used to disable offline support for specific urls
  88463. */
  88464. disableOfflineSupportExceptionRules: RegExp[];
  88465. /**
  88466. * An event triggered when the scene is disposed.
  88467. */
  88468. onDisposeObservable: Observable<Scene>;
  88469. private _onDisposeObserver;
  88470. /** Sets a function to be executed when this scene is disposed. */
  88471. onDispose: () => void;
  88472. /**
  88473. * An event triggered before rendering the scene (right after animations and physics)
  88474. */
  88475. onBeforeRenderObservable: Observable<Scene>;
  88476. private _onBeforeRenderObserver;
  88477. /** Sets a function to be executed before rendering this scene */
  88478. beforeRender: Nullable<() => void>;
  88479. /**
  88480. * An event triggered after rendering the scene
  88481. */
  88482. onAfterRenderObservable: Observable<Scene>;
  88483. private _onAfterRenderObserver;
  88484. /** Sets a function to be executed after rendering this scene */
  88485. afterRender: Nullable<() => void>;
  88486. /**
  88487. * An event triggered before animating the scene
  88488. */
  88489. onBeforeAnimationsObservable: Observable<Scene>;
  88490. /**
  88491. * An event triggered after animations processing
  88492. */
  88493. onAfterAnimationsObservable: Observable<Scene>;
  88494. /**
  88495. * An event triggered before draw calls are ready to be sent
  88496. */
  88497. onBeforeDrawPhaseObservable: Observable<Scene>;
  88498. /**
  88499. * An event triggered after draw calls have been sent
  88500. */
  88501. onAfterDrawPhaseObservable: Observable<Scene>;
  88502. /**
  88503. * An event triggered when the scene is ready
  88504. */
  88505. onReadyObservable: Observable<Scene>;
  88506. /**
  88507. * An event triggered before rendering a camera
  88508. */
  88509. onBeforeCameraRenderObservable: Observable<Camera>;
  88510. private _onBeforeCameraRenderObserver;
  88511. /** Sets a function to be executed before rendering a camera*/
  88512. beforeCameraRender: () => void;
  88513. /**
  88514. * An event triggered after rendering a camera
  88515. */
  88516. onAfterCameraRenderObservable: Observable<Camera>;
  88517. private _onAfterCameraRenderObserver;
  88518. /** Sets a function to be executed after rendering a camera*/
  88519. afterCameraRender: () => void;
  88520. /**
  88521. * An event triggered when active meshes evaluation is about to start
  88522. */
  88523. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  88524. /**
  88525. * An event triggered when active meshes evaluation is done
  88526. */
  88527. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  88528. /**
  88529. * An event triggered when particles rendering is about to start
  88530. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88531. */
  88532. onBeforeParticlesRenderingObservable: Observable<Scene>;
  88533. /**
  88534. * An event triggered when particles rendering is done
  88535. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88536. */
  88537. onAfterParticlesRenderingObservable: Observable<Scene>;
  88538. /**
  88539. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  88540. */
  88541. onDataLoadedObservable: Observable<Scene>;
  88542. /**
  88543. * An event triggered when a camera is created
  88544. */
  88545. onNewCameraAddedObservable: Observable<Camera>;
  88546. /**
  88547. * An event triggered when a camera is removed
  88548. */
  88549. onCameraRemovedObservable: Observable<Camera>;
  88550. /**
  88551. * An event triggered when a light is created
  88552. */
  88553. onNewLightAddedObservable: Observable<Light>;
  88554. /**
  88555. * An event triggered when a light is removed
  88556. */
  88557. onLightRemovedObservable: Observable<Light>;
  88558. /**
  88559. * An event triggered when a geometry is created
  88560. */
  88561. onNewGeometryAddedObservable: Observable<Geometry>;
  88562. /**
  88563. * An event triggered when a geometry is removed
  88564. */
  88565. onGeometryRemovedObservable: Observable<Geometry>;
  88566. /**
  88567. * An event triggered when a transform node is created
  88568. */
  88569. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  88570. /**
  88571. * An event triggered when a transform node is removed
  88572. */
  88573. onTransformNodeRemovedObservable: Observable<TransformNode>;
  88574. /**
  88575. * An event triggered when a mesh is created
  88576. */
  88577. onNewMeshAddedObservable: Observable<AbstractMesh>;
  88578. /**
  88579. * An event triggered when a mesh is removed
  88580. */
  88581. onMeshRemovedObservable: Observable<AbstractMesh>;
  88582. /**
  88583. * An event triggered when a material is created
  88584. */
  88585. onNewMaterialAddedObservable: Observable<Material>;
  88586. /**
  88587. * An event triggered when a material is removed
  88588. */
  88589. onMaterialRemovedObservable: Observable<Material>;
  88590. /**
  88591. * An event triggered when a texture is created
  88592. */
  88593. onNewTextureAddedObservable: Observable<BaseTexture>;
  88594. /**
  88595. * An event triggered when a texture is removed
  88596. */
  88597. onTextureRemovedObservable: Observable<BaseTexture>;
  88598. /**
  88599. * An event triggered when render targets are about to be rendered
  88600. * Can happen multiple times per frame.
  88601. */
  88602. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  88603. /**
  88604. * An event triggered when render targets were rendered.
  88605. * Can happen multiple times per frame.
  88606. */
  88607. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  88608. /**
  88609. * An event triggered before calculating deterministic simulation step
  88610. */
  88611. onBeforeStepObservable: Observable<Scene>;
  88612. /**
  88613. * An event triggered after calculating deterministic simulation step
  88614. */
  88615. onAfterStepObservable: Observable<Scene>;
  88616. /**
  88617. * An event triggered when the activeCamera property is updated
  88618. */
  88619. onActiveCameraChanged: Observable<Scene>;
  88620. /**
  88621. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  88622. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88623. * 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)
  88624. */
  88625. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88626. /**
  88627. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  88628. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88629. * 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)
  88630. */
  88631. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88632. /**
  88633. * This Observable will when a mesh has been imported into the scene.
  88634. */
  88635. onMeshImportedObservable: Observable<AbstractMesh>;
  88636. /**
  88637. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  88638. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  88639. */
  88640. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  88641. /** @hidden */
  88642. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  88643. /**
  88644. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  88645. */
  88646. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  88647. /**
  88648. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  88649. */
  88650. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  88651. /**
  88652. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  88653. */
  88654. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  88655. private _onPointerMove;
  88656. private _onPointerDown;
  88657. private _onPointerUp;
  88658. /** Callback called when a pointer move is detected */
  88659. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88660. /** Callback called when a pointer down is detected */
  88661. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88662. /** Callback called when a pointer up is detected */
  88663. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  88664. /** Callback called when a pointer pick is detected */
  88665. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  88666. /**
  88667. * 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).
  88668. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  88669. */
  88670. onPrePointerObservable: Observable<PointerInfoPre>;
  88671. /**
  88672. * Observable event triggered each time an input event is received from the rendering canvas
  88673. */
  88674. onPointerObservable: Observable<PointerInfo>;
  88675. /**
  88676. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  88677. */
  88678. readonly unTranslatedPointer: Vector2;
  88679. /** The distance in pixel that you have to move to prevent some events */
  88680. static DragMovementThreshold: number;
  88681. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  88682. static LongPressDelay: number;
  88683. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  88684. static DoubleClickDelay: number;
  88685. /** If you need to check double click without raising a single click at first click, enable this flag */
  88686. static ExclusiveDoubleClickMode: boolean;
  88687. private _initClickEvent;
  88688. private _initActionManager;
  88689. private _delayedSimpleClick;
  88690. private _delayedSimpleClickTimeout;
  88691. private _previousDelayedSimpleClickTimeout;
  88692. private _meshPickProceed;
  88693. private _previousButtonPressed;
  88694. private _currentPickResult;
  88695. private _previousPickResult;
  88696. private _totalPointersPressed;
  88697. private _doubleClickOccured;
  88698. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  88699. cameraToUseForPointers: Nullable<Camera>;
  88700. private _pointerX;
  88701. private _pointerY;
  88702. private _unTranslatedPointerX;
  88703. private _unTranslatedPointerY;
  88704. private _startingPointerPosition;
  88705. private _previousStartingPointerPosition;
  88706. private _startingPointerTime;
  88707. private _previousStartingPointerTime;
  88708. private _pointerCaptures;
  88709. private _timeAccumulator;
  88710. private _currentStepId;
  88711. private _currentInternalStep;
  88712. /** @hidden */
  88713. _mirroredCameraPosition: Nullable<Vector3>;
  88714. /**
  88715. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  88716. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  88717. */
  88718. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  88719. /**
  88720. * Observable event triggered each time an keyboard event is received from the hosting window
  88721. */
  88722. onKeyboardObservable: Observable<KeyboardInfo>;
  88723. private _onKeyDown;
  88724. private _onKeyUp;
  88725. private _onCanvasFocusObserver;
  88726. private _onCanvasBlurObserver;
  88727. private _useRightHandedSystem;
  88728. /**
  88729. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  88730. */
  88731. useRightHandedSystem: boolean;
  88732. /**
  88733. * Sets the step Id used by deterministic lock step
  88734. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88735. * @param newStepId defines the step Id
  88736. */
  88737. setStepId(newStepId: number): void;
  88738. /**
  88739. * Gets the step Id used by deterministic lock step
  88740. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88741. * @returns the step Id
  88742. */
  88743. getStepId(): number;
  88744. /**
  88745. * Gets the internal step used by deterministic lock step
  88746. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88747. * @returns the internal step
  88748. */
  88749. getInternalStep(): number;
  88750. private _fogEnabled;
  88751. /**
  88752. * Gets or sets a boolean indicating if fog is enabled on this scene
  88753. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88754. * (Default is true)
  88755. */
  88756. fogEnabled: boolean;
  88757. private _fogMode;
  88758. /**
  88759. * Gets or sets the fog mode to use
  88760. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88761. * | mode | value |
  88762. * | --- | --- |
  88763. * | FOGMODE_NONE | 0 |
  88764. * | FOGMODE_EXP | 1 |
  88765. * | FOGMODE_EXP2 | 2 |
  88766. * | FOGMODE_LINEAR | 3 |
  88767. */
  88768. fogMode: number;
  88769. /**
  88770. * Gets or sets the fog color to use
  88771. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88772. * (Default is Color3(0.2, 0.2, 0.3))
  88773. */
  88774. fogColor: Color3;
  88775. /**
  88776. * Gets or sets the fog density to use
  88777. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88778. * (Default is 0.1)
  88779. */
  88780. fogDensity: number;
  88781. /**
  88782. * Gets or sets the fog start distance to use
  88783. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88784. * (Default is 0)
  88785. */
  88786. fogStart: number;
  88787. /**
  88788. * Gets or sets the fog end distance to use
  88789. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88790. * (Default is 1000)
  88791. */
  88792. fogEnd: number;
  88793. private _shadowsEnabled;
  88794. /**
  88795. * Gets or sets a boolean indicating if shadows are enabled on this scene
  88796. */
  88797. shadowsEnabled: boolean;
  88798. private _lightsEnabled;
  88799. /**
  88800. * Gets or sets a boolean indicating if lights are enabled on this scene
  88801. */
  88802. lightsEnabled: boolean;
  88803. /** All of the active cameras added to this scene. */
  88804. activeCameras: Camera[];
  88805. private _activeCamera;
  88806. /** Gets or sets the current active camera */
  88807. activeCamera: Nullable<Camera>;
  88808. private _defaultMaterial;
  88809. /** The default material used on meshes when no material is affected */
  88810. /** The default material used on meshes when no material is affected */
  88811. defaultMaterial: Material;
  88812. private _texturesEnabled;
  88813. /**
  88814. * Gets or sets a boolean indicating if textures are enabled on this scene
  88815. */
  88816. texturesEnabled: boolean;
  88817. /**
  88818. * Gets or sets a boolean indicating if particles are enabled on this scene
  88819. */
  88820. particlesEnabled: boolean;
  88821. /**
  88822. * Gets or sets a boolean indicating if sprites are enabled on this scene
  88823. */
  88824. spritesEnabled: boolean;
  88825. private _skeletonsEnabled;
  88826. /**
  88827. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  88828. */
  88829. skeletonsEnabled: boolean;
  88830. /**
  88831. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  88832. */
  88833. lensFlaresEnabled: boolean;
  88834. /**
  88835. * Gets or sets a boolean indicating if collisions are enabled on this scene
  88836. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88837. */
  88838. collisionsEnabled: boolean;
  88839. private _collisionCoordinator;
  88840. /** @hidden */
  88841. readonly collisionCoordinator: ICollisionCoordinator;
  88842. /**
  88843. * Defines the gravity applied to this scene (used only for collisions)
  88844. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88845. */
  88846. gravity: Vector3;
  88847. /**
  88848. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  88849. */
  88850. postProcessesEnabled: boolean;
  88851. /**
  88852. * The list of postprocesses added to the scene
  88853. */
  88854. postProcesses: PostProcess[];
  88855. /**
  88856. * Gets the current postprocess manager
  88857. */
  88858. postProcessManager: PostProcessManager;
  88859. /**
  88860. * Gets or sets a boolean indicating if render targets are enabled on this scene
  88861. */
  88862. renderTargetsEnabled: boolean;
  88863. /**
  88864. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  88865. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  88866. */
  88867. dumpNextRenderTargets: boolean;
  88868. /**
  88869. * The list of user defined render targets added to the scene
  88870. */
  88871. customRenderTargets: RenderTargetTexture[];
  88872. /**
  88873. * Defines if texture loading must be delayed
  88874. * If true, textures will only be loaded when they need to be rendered
  88875. */
  88876. useDelayedTextureLoading: boolean;
  88877. /**
  88878. * Gets the list of meshes imported to the scene through SceneLoader
  88879. */
  88880. importedMeshesFiles: String[];
  88881. /**
  88882. * Gets or sets a boolean indicating if probes are enabled on this scene
  88883. */
  88884. probesEnabled: boolean;
  88885. /**
  88886. * Gets or sets the current offline provider to use to store scene data
  88887. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  88888. */
  88889. offlineProvider: IOfflineProvider;
  88890. /**
  88891. * Gets or sets the action manager associated with the scene
  88892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  88893. */
  88894. actionManager: AbstractActionManager;
  88895. private _meshesForIntersections;
  88896. /**
  88897. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  88898. */
  88899. proceduralTexturesEnabled: boolean;
  88900. private _engine;
  88901. private _totalVertices;
  88902. /** @hidden */
  88903. _activeIndices: PerfCounter;
  88904. /** @hidden */
  88905. _activeParticles: PerfCounter;
  88906. /** @hidden */
  88907. _activeBones: PerfCounter;
  88908. private _animationRatio;
  88909. /** @hidden */
  88910. _animationTimeLast: number;
  88911. /** @hidden */
  88912. _animationTime: number;
  88913. /**
  88914. * Gets or sets a general scale for animation speed
  88915. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  88916. */
  88917. animationTimeScale: number;
  88918. /** @hidden */
  88919. _cachedMaterial: Nullable<Material>;
  88920. /** @hidden */
  88921. _cachedEffect: Nullable<Effect>;
  88922. /** @hidden */
  88923. _cachedVisibility: Nullable<number>;
  88924. private _renderId;
  88925. private _frameId;
  88926. private _executeWhenReadyTimeoutId;
  88927. private _intermediateRendering;
  88928. private _viewUpdateFlag;
  88929. private _projectionUpdateFlag;
  88930. private _alternateViewUpdateFlag;
  88931. private _alternateProjectionUpdateFlag;
  88932. /** @hidden */
  88933. _toBeDisposed: Nullable<IDisposable>[];
  88934. private _activeRequests;
  88935. /** @hidden */
  88936. _pendingData: any[];
  88937. private _isDisposed;
  88938. /**
  88939. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  88940. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  88941. */
  88942. dispatchAllSubMeshesOfActiveMeshes: boolean;
  88943. private _activeMeshes;
  88944. private _processedMaterials;
  88945. private _renderTargets;
  88946. /** @hidden */
  88947. _activeParticleSystems: SmartArray<IParticleSystem>;
  88948. private _activeSkeletons;
  88949. private _softwareSkinnedMeshes;
  88950. private _renderingManager;
  88951. /** @hidden */
  88952. _activeAnimatables: Animatable[];
  88953. private _transformMatrix;
  88954. private _sceneUbo;
  88955. private _alternateSceneUbo;
  88956. private _viewMatrix;
  88957. private _projectionMatrix;
  88958. private _alternateViewMatrix;
  88959. private _alternateProjectionMatrix;
  88960. private _alternateTransformMatrix;
  88961. private _useAlternateCameraConfiguration;
  88962. private _alternateRendering;
  88963. private _wheelEventName;
  88964. /** @hidden */
  88965. _forcedViewPosition: Nullable<Vector3>;
  88966. /** @hidden */
  88967. readonly _isAlternateRenderingEnabled: boolean;
  88968. private _frustumPlanes;
  88969. /**
  88970. * Gets the list of frustum planes (built from the active camera)
  88971. */
  88972. readonly frustumPlanes: Plane[];
  88973. /**
  88974. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  88975. * This is useful if there are more lights that the maximum simulteanous authorized
  88976. */
  88977. requireLightSorting: boolean;
  88978. /** @hidden */
  88979. readonly useMaterialMeshMap: boolean;
  88980. /** @hidden */
  88981. readonly useClonedMeshhMap: boolean;
  88982. private _pointerOverMesh;
  88983. private _pickedDownMesh;
  88984. private _pickedUpMesh;
  88985. private _externalData;
  88986. private _uid;
  88987. /**
  88988. * @hidden
  88989. * Backing store of defined scene components.
  88990. */
  88991. _components: ISceneComponent[];
  88992. /**
  88993. * @hidden
  88994. * Backing store of defined scene components.
  88995. */
  88996. _serializableComponents: ISceneSerializableComponent[];
  88997. /**
  88998. * List of components to register on the next registration step.
  88999. */
  89000. private _transientComponents;
  89001. /**
  89002. * Registers the transient components if needed.
  89003. */
  89004. private _registerTransientComponents;
  89005. /**
  89006. * @hidden
  89007. * Add a component to the scene.
  89008. * Note that the ccomponent could be registered on th next frame if this is called after
  89009. * the register component stage.
  89010. * @param component Defines the component to add to the scene
  89011. */
  89012. _addComponent(component: ISceneComponent): void;
  89013. /**
  89014. * @hidden
  89015. * Gets a component from the scene.
  89016. * @param name defines the name of the component to retrieve
  89017. * @returns the component or null if not present
  89018. */
  89019. _getComponent(name: string): Nullable<ISceneComponent>;
  89020. /**
  89021. * @hidden
  89022. * Defines the actions happening before camera updates.
  89023. */
  89024. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  89025. /**
  89026. * @hidden
  89027. * Defines the actions happening before clear the canvas.
  89028. */
  89029. _beforeClearStage: Stage<SimpleStageAction>;
  89030. /**
  89031. * @hidden
  89032. * Defines the actions when collecting render targets for the frame.
  89033. */
  89034. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89035. /**
  89036. * @hidden
  89037. * Defines the actions happening for one camera in the frame.
  89038. */
  89039. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89040. /**
  89041. * @hidden
  89042. * Defines the actions happening during the per mesh ready checks.
  89043. */
  89044. _isReadyForMeshStage: Stage<MeshStageAction>;
  89045. /**
  89046. * @hidden
  89047. * Defines the actions happening before evaluate active mesh checks.
  89048. */
  89049. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  89050. /**
  89051. * @hidden
  89052. * Defines the actions happening during the evaluate sub mesh checks.
  89053. */
  89054. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  89055. /**
  89056. * @hidden
  89057. * Defines the actions happening during the active mesh stage.
  89058. */
  89059. _activeMeshStage: Stage<ActiveMeshStageAction>;
  89060. /**
  89061. * @hidden
  89062. * Defines the actions happening during the per camera render target step.
  89063. */
  89064. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  89065. /**
  89066. * @hidden
  89067. * Defines the actions happening just before the active camera is drawing.
  89068. */
  89069. _beforeCameraDrawStage: Stage<CameraStageAction>;
  89070. /**
  89071. * @hidden
  89072. * Defines the actions happening just before a render target is drawing.
  89073. */
  89074. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89075. /**
  89076. * @hidden
  89077. * Defines the actions happening just before a rendering group is drawing.
  89078. */
  89079. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89080. /**
  89081. * @hidden
  89082. * Defines the actions happening just before a mesh is drawing.
  89083. */
  89084. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89085. /**
  89086. * @hidden
  89087. * Defines the actions happening just after a mesh has been drawn.
  89088. */
  89089. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89090. /**
  89091. * @hidden
  89092. * Defines the actions happening just after a rendering group has been drawn.
  89093. */
  89094. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89095. /**
  89096. * @hidden
  89097. * Defines the actions happening just after the active camera has been drawn.
  89098. */
  89099. _afterCameraDrawStage: Stage<CameraStageAction>;
  89100. /**
  89101. * @hidden
  89102. * Defines the actions happening just after a render target has been drawn.
  89103. */
  89104. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89105. /**
  89106. * @hidden
  89107. * Defines the actions happening just after rendering all cameras and computing intersections.
  89108. */
  89109. _afterRenderStage: Stage<SimpleStageAction>;
  89110. /**
  89111. * @hidden
  89112. * Defines the actions happening when a pointer move event happens.
  89113. */
  89114. _pointerMoveStage: Stage<PointerMoveStageAction>;
  89115. /**
  89116. * @hidden
  89117. * Defines the actions happening when a pointer down event happens.
  89118. */
  89119. _pointerDownStage: Stage<PointerUpDownStageAction>;
  89120. /**
  89121. * @hidden
  89122. * Defines the actions happening when a pointer up event happens.
  89123. */
  89124. _pointerUpStage: Stage<PointerUpDownStageAction>;
  89125. /**
  89126. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  89127. */
  89128. private geometriesByUniqueId;
  89129. /**
  89130. * Creates a new Scene
  89131. * @param engine defines the engine to use to render this scene
  89132. * @param options defines the scene options
  89133. */
  89134. constructor(engine: Engine, options?: SceneOptions);
  89135. private _defaultMeshCandidates;
  89136. /**
  89137. * @hidden
  89138. */
  89139. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  89140. private _defaultSubMeshCandidates;
  89141. /**
  89142. * @hidden
  89143. */
  89144. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  89145. /**
  89146. * Sets the default candidate providers for the scene.
  89147. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  89148. * and getCollidingSubMeshCandidates to their default function
  89149. */
  89150. setDefaultCandidateProviders(): void;
  89151. /**
  89152. * Gets the mesh that is currently under the pointer
  89153. */
  89154. readonly meshUnderPointer: Nullable<AbstractMesh>;
  89155. /**
  89156. * Gets or sets the current on-screen X position of the pointer
  89157. */
  89158. pointerX: number;
  89159. /**
  89160. * Gets or sets the current on-screen Y position of the pointer
  89161. */
  89162. pointerY: number;
  89163. /**
  89164. * Gets the cached material (ie. the latest rendered one)
  89165. * @returns the cached material
  89166. */
  89167. getCachedMaterial(): Nullable<Material>;
  89168. /**
  89169. * Gets the cached effect (ie. the latest rendered one)
  89170. * @returns the cached effect
  89171. */
  89172. getCachedEffect(): Nullable<Effect>;
  89173. /**
  89174. * Gets the cached visibility state (ie. the latest rendered one)
  89175. * @returns the cached visibility state
  89176. */
  89177. getCachedVisibility(): Nullable<number>;
  89178. /**
  89179. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  89180. * @param material defines the current material
  89181. * @param effect defines the current effect
  89182. * @param visibility defines the current visibility state
  89183. * @returns true if one parameter is not cached
  89184. */
  89185. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  89186. /**
  89187. * Gets the engine associated with the scene
  89188. * @returns an Engine
  89189. */
  89190. getEngine(): Engine;
  89191. /**
  89192. * Gets the total number of vertices rendered per frame
  89193. * @returns the total number of vertices rendered per frame
  89194. */
  89195. getTotalVertices(): number;
  89196. /**
  89197. * Gets the performance counter for total vertices
  89198. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89199. */
  89200. readonly totalVerticesPerfCounter: PerfCounter;
  89201. /**
  89202. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  89203. * @returns the total number of active indices rendered per frame
  89204. */
  89205. getActiveIndices(): number;
  89206. /**
  89207. * Gets the performance counter for active indices
  89208. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89209. */
  89210. readonly totalActiveIndicesPerfCounter: PerfCounter;
  89211. /**
  89212. * Gets the total number of active particles rendered per frame
  89213. * @returns the total number of active particles rendered per frame
  89214. */
  89215. getActiveParticles(): number;
  89216. /**
  89217. * Gets the performance counter for active particles
  89218. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89219. */
  89220. readonly activeParticlesPerfCounter: PerfCounter;
  89221. /**
  89222. * Gets the total number of active bones rendered per frame
  89223. * @returns the total number of active bones rendered per frame
  89224. */
  89225. getActiveBones(): number;
  89226. /**
  89227. * Gets the performance counter for active bones
  89228. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89229. */
  89230. readonly activeBonesPerfCounter: PerfCounter;
  89231. /**
  89232. * Gets the array of active meshes
  89233. * @returns an array of AbstractMesh
  89234. */
  89235. getActiveMeshes(): SmartArray<AbstractMesh>;
  89236. /**
  89237. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  89238. * @returns a number
  89239. */
  89240. getAnimationRatio(): number;
  89241. /**
  89242. * Gets an unique Id for the current render phase
  89243. * @returns a number
  89244. */
  89245. getRenderId(): number;
  89246. /**
  89247. * Gets an unique Id for the current frame
  89248. * @returns a number
  89249. */
  89250. getFrameId(): number;
  89251. /** Call this function if you want to manually increment the render Id*/
  89252. incrementRenderId(): void;
  89253. private _updatePointerPosition;
  89254. private _createUbo;
  89255. private _createAlternateUbo;
  89256. private _setRayOnPointerInfo;
  89257. /**
  89258. * Use this method to simulate a pointer move on a mesh
  89259. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89260. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89261. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89262. * @returns the current scene
  89263. */
  89264. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89265. private _processPointerMove;
  89266. private _checkPrePointerObservable;
  89267. /**
  89268. * Use this method to simulate a pointer down on a mesh
  89269. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89270. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89271. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89272. * @returns the current scene
  89273. */
  89274. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89275. private _processPointerDown;
  89276. /**
  89277. * Use this method to simulate a pointer up on a mesh
  89278. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89279. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89280. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89281. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  89282. * @returns the current scene
  89283. */
  89284. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  89285. private _processPointerUp;
  89286. /**
  89287. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  89288. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  89289. * @returns true if the pointer was captured
  89290. */
  89291. isPointerCaptured(pointerId?: number): boolean;
  89292. /** @hidden */
  89293. _isPointerSwiping(): boolean;
  89294. /**
  89295. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  89296. * @param attachUp defines if you want to attach events to pointerup
  89297. * @param attachDown defines if you want to attach events to pointerdown
  89298. * @param attachMove defines if you want to attach events to pointermove
  89299. */
  89300. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  89301. /** Detaches all event handlers*/
  89302. detachControl(): void;
  89303. /**
  89304. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  89305. * Delay loaded resources are not taking in account
  89306. * @return true if all required resources are ready
  89307. */
  89308. isReady(): boolean;
  89309. /** Resets all cached information relative to material (including effect and visibility) */
  89310. resetCachedMaterial(): void;
  89311. /**
  89312. * Registers a function to be called before every frame render
  89313. * @param func defines the function to register
  89314. */
  89315. registerBeforeRender(func: () => void): void;
  89316. /**
  89317. * Unregisters a function called before every frame render
  89318. * @param func defines the function to unregister
  89319. */
  89320. unregisterBeforeRender(func: () => void): void;
  89321. /**
  89322. * Registers a function to be called after every frame render
  89323. * @param func defines the function to register
  89324. */
  89325. registerAfterRender(func: () => void): void;
  89326. /**
  89327. * Unregisters a function called after every frame render
  89328. * @param func defines the function to unregister
  89329. */
  89330. unregisterAfterRender(func: () => void): void;
  89331. private _executeOnceBeforeRender;
  89332. /**
  89333. * The provided function will run before render once and will be disposed afterwards.
  89334. * A timeout delay can be provided so that the function will be executed in N ms.
  89335. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  89336. * @param func The function to be executed.
  89337. * @param timeout optional delay in ms
  89338. */
  89339. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  89340. /** @hidden */
  89341. _addPendingData(data: any): void;
  89342. /** @hidden */
  89343. _removePendingData(data: any): void;
  89344. /**
  89345. * Returns the number of items waiting to be loaded
  89346. * @returns the number of items waiting to be loaded
  89347. */
  89348. getWaitingItemsCount(): number;
  89349. /**
  89350. * Returns a boolean indicating if the scene is still loading data
  89351. */
  89352. readonly isLoading: boolean;
  89353. /**
  89354. * Registers a function to be executed when the scene is ready
  89355. * @param {Function} func - the function to be executed
  89356. */
  89357. executeWhenReady(func: () => void): void;
  89358. /**
  89359. * Returns a promise that resolves when the scene is ready
  89360. * @returns A promise that resolves when the scene is ready
  89361. */
  89362. whenReadyAsync(): Promise<void>;
  89363. /** @hidden */
  89364. _checkIsReady(): void;
  89365. /**
  89366. * Gets all animatable attached to the scene
  89367. */
  89368. readonly animatables: Animatable[];
  89369. /**
  89370. * Resets the last animation time frame.
  89371. * Useful to override when animations start running when loading a scene for the first time.
  89372. */
  89373. resetLastAnimationTimeFrame(): void;
  89374. /** @hidden */
  89375. _switchToAlternateCameraConfiguration(active: boolean): void;
  89376. /**
  89377. * Gets the current view matrix
  89378. * @returns a Matrix
  89379. */
  89380. getViewMatrix(): Matrix;
  89381. /**
  89382. * Gets the current projection matrix
  89383. * @returns a Matrix
  89384. */
  89385. getProjectionMatrix(): Matrix;
  89386. /**
  89387. * Gets the current transform matrix
  89388. * @returns a Matrix made of View * Projection
  89389. */
  89390. getTransformMatrix(): Matrix;
  89391. /**
  89392. * Sets the current transform matrix
  89393. * @param view defines the View matrix to use
  89394. * @param projection defines the Projection matrix to use
  89395. */
  89396. setTransformMatrix(view: Matrix, projection: Matrix): void;
  89397. /** @hidden */
  89398. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  89399. /**
  89400. * Gets the uniform buffer used to store scene data
  89401. * @returns a UniformBuffer
  89402. */
  89403. getSceneUniformBuffer(): UniformBuffer;
  89404. /**
  89405. * Gets an unique (relatively to the current scene) Id
  89406. * @returns an unique number for the scene
  89407. */
  89408. getUniqueId(): number;
  89409. /**
  89410. * Add a mesh to the list of scene's meshes
  89411. * @param newMesh defines the mesh to add
  89412. * @param recursive if all child meshes should also be added to the scene
  89413. */
  89414. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  89415. /**
  89416. * Remove a mesh for the list of scene's meshes
  89417. * @param toRemove defines the mesh to remove
  89418. * @param recursive if all child meshes should also be removed from the scene
  89419. * @returns the index where the mesh was in the mesh list
  89420. */
  89421. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  89422. /**
  89423. * Add a transform node to the list of scene's transform nodes
  89424. * @param newTransformNode defines the transform node to add
  89425. */
  89426. addTransformNode(newTransformNode: TransformNode): void;
  89427. /**
  89428. * Remove a transform node for the list of scene's transform nodes
  89429. * @param toRemove defines the transform node to remove
  89430. * @returns the index where the transform node was in the transform node list
  89431. */
  89432. removeTransformNode(toRemove: TransformNode): number;
  89433. /**
  89434. * Remove a skeleton for the list of scene's skeletons
  89435. * @param toRemove defines the skeleton to remove
  89436. * @returns the index where the skeleton was in the skeleton list
  89437. */
  89438. removeSkeleton(toRemove: Skeleton): number;
  89439. /**
  89440. * Remove a morph target for the list of scene's morph targets
  89441. * @param toRemove defines the morph target to remove
  89442. * @returns the index where the morph target was in the morph target list
  89443. */
  89444. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  89445. /**
  89446. * Remove a light for the list of scene's lights
  89447. * @param toRemove defines the light to remove
  89448. * @returns the index where the light was in the light list
  89449. */
  89450. removeLight(toRemove: Light): number;
  89451. /**
  89452. * Remove a camera for the list of scene's cameras
  89453. * @param toRemove defines the camera to remove
  89454. * @returns the index where the camera was in the camera list
  89455. */
  89456. removeCamera(toRemove: Camera): number;
  89457. /**
  89458. * Remove a particle system for the list of scene's particle systems
  89459. * @param toRemove defines the particle system to remove
  89460. * @returns the index where the particle system was in the particle system list
  89461. */
  89462. removeParticleSystem(toRemove: IParticleSystem): number;
  89463. /**
  89464. * Remove a animation for the list of scene's animations
  89465. * @param toRemove defines the animation to remove
  89466. * @returns the index where the animation was in the animation list
  89467. */
  89468. removeAnimation(toRemove: Animation): number;
  89469. /**
  89470. * Removes the given animation group from this scene.
  89471. * @param toRemove The animation group to remove
  89472. * @returns The index of the removed animation group
  89473. */
  89474. removeAnimationGroup(toRemove: AnimationGroup): number;
  89475. /**
  89476. * Removes the given multi-material from this scene.
  89477. * @param toRemove The multi-material to remove
  89478. * @returns The index of the removed multi-material
  89479. */
  89480. removeMultiMaterial(toRemove: MultiMaterial): number;
  89481. /**
  89482. * Removes the given material from this scene.
  89483. * @param toRemove The material to remove
  89484. * @returns The index of the removed material
  89485. */
  89486. removeMaterial(toRemove: Material): number;
  89487. /**
  89488. * Removes the given action manager from this scene.
  89489. * @param toRemove The action manager to remove
  89490. * @returns The index of the removed action manager
  89491. */
  89492. removeActionManager(toRemove: AbstractActionManager): number;
  89493. /**
  89494. * Removes the given texture from this scene.
  89495. * @param toRemove The texture to remove
  89496. * @returns The index of the removed texture
  89497. */
  89498. removeTexture(toRemove: BaseTexture): number;
  89499. /**
  89500. * Adds the given light to this scene
  89501. * @param newLight The light to add
  89502. */
  89503. addLight(newLight: Light): void;
  89504. /**
  89505. * Sorts the list list based on light priorities
  89506. */
  89507. sortLightsByPriority(): void;
  89508. /**
  89509. * Adds the given camera to this scene
  89510. * @param newCamera The camera to add
  89511. */
  89512. addCamera(newCamera: Camera): void;
  89513. /**
  89514. * Adds the given skeleton to this scene
  89515. * @param newSkeleton The skeleton to add
  89516. */
  89517. addSkeleton(newSkeleton: Skeleton): void;
  89518. /**
  89519. * Adds the given particle system to this scene
  89520. * @param newParticleSystem The particle system to add
  89521. */
  89522. addParticleSystem(newParticleSystem: IParticleSystem): void;
  89523. /**
  89524. * Adds the given animation to this scene
  89525. * @param newAnimation The animation to add
  89526. */
  89527. addAnimation(newAnimation: Animation): void;
  89528. /**
  89529. * Adds the given animation group to this scene.
  89530. * @param newAnimationGroup The animation group to add
  89531. */
  89532. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  89533. /**
  89534. * Adds the given multi-material to this scene
  89535. * @param newMultiMaterial The multi-material to add
  89536. */
  89537. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  89538. /**
  89539. * Adds the given material to this scene
  89540. * @param newMaterial The material to add
  89541. */
  89542. addMaterial(newMaterial: Material): void;
  89543. /**
  89544. * Adds the given morph target to this scene
  89545. * @param newMorphTargetManager The morph target to add
  89546. */
  89547. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  89548. /**
  89549. * Adds the given geometry to this scene
  89550. * @param newGeometry The geometry to add
  89551. */
  89552. addGeometry(newGeometry: Geometry): void;
  89553. /**
  89554. * Adds the given action manager to this scene
  89555. * @param newActionManager The action manager to add
  89556. */
  89557. addActionManager(newActionManager: AbstractActionManager): void;
  89558. /**
  89559. * Adds the given texture to this scene.
  89560. * @param newTexture The texture to add
  89561. */
  89562. addTexture(newTexture: BaseTexture): void;
  89563. /**
  89564. * Switch active camera
  89565. * @param newCamera defines the new active camera
  89566. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  89567. */
  89568. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  89569. /**
  89570. * sets the active camera of the scene using its ID
  89571. * @param id defines the camera's ID
  89572. * @return the new active camera or null if none found.
  89573. */
  89574. setActiveCameraByID(id: string): Nullable<Camera>;
  89575. /**
  89576. * sets the active camera of the scene using its name
  89577. * @param name defines the camera's name
  89578. * @returns the new active camera or null if none found.
  89579. */
  89580. setActiveCameraByName(name: string): Nullable<Camera>;
  89581. /**
  89582. * get an animation group using its name
  89583. * @param name defines the material's name
  89584. * @return the animation group or null if none found.
  89585. */
  89586. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  89587. /**
  89588. * get a material using its id
  89589. * @param id defines the material's ID
  89590. * @return the material or null if none found.
  89591. */
  89592. getMaterialByID(id: string): Nullable<Material>;
  89593. /**
  89594. * Gets a material using its name
  89595. * @param name defines the material's name
  89596. * @return the material or null if none found.
  89597. */
  89598. getMaterialByName(name: string): Nullable<Material>;
  89599. /**
  89600. * Gets a camera using its id
  89601. * @param id defines the id to look for
  89602. * @returns the camera or null if not found
  89603. */
  89604. getCameraByID(id: string): Nullable<Camera>;
  89605. /**
  89606. * Gets a camera using its unique id
  89607. * @param uniqueId defines the unique id to look for
  89608. * @returns the camera or null if not found
  89609. */
  89610. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  89611. /**
  89612. * Gets a camera using its name
  89613. * @param name defines the camera's name
  89614. * @return the camera or null if none found.
  89615. */
  89616. getCameraByName(name: string): Nullable<Camera>;
  89617. /**
  89618. * Gets a bone using its id
  89619. * @param id defines the bone's id
  89620. * @return the bone or null if not found
  89621. */
  89622. getBoneByID(id: string): Nullable<Bone>;
  89623. /**
  89624. * Gets a bone using its id
  89625. * @param name defines the bone's name
  89626. * @return the bone or null if not found
  89627. */
  89628. getBoneByName(name: string): Nullable<Bone>;
  89629. /**
  89630. * Gets a light node using its name
  89631. * @param name defines the the light's name
  89632. * @return the light or null if none found.
  89633. */
  89634. getLightByName(name: string): Nullable<Light>;
  89635. /**
  89636. * Gets a light node using its id
  89637. * @param id defines the light's id
  89638. * @return the light or null if none found.
  89639. */
  89640. getLightByID(id: string): Nullable<Light>;
  89641. /**
  89642. * Gets a light node using its scene-generated unique ID
  89643. * @param uniqueId defines the light's unique id
  89644. * @return the light or null if none found.
  89645. */
  89646. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  89647. /**
  89648. * Gets a particle system by id
  89649. * @param id defines the particle system id
  89650. * @return the corresponding system or null if none found
  89651. */
  89652. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  89653. /**
  89654. * Gets a geometry using its ID
  89655. * @param id defines the geometry's id
  89656. * @return the geometry or null if none found.
  89657. */
  89658. getGeometryByID(id: string): Nullable<Geometry>;
  89659. private _getGeometryByUniqueID;
  89660. /**
  89661. * Add a new geometry to this scene
  89662. * @param geometry defines the geometry to be added to the scene.
  89663. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  89664. * @return a boolean defining if the geometry was added or not
  89665. */
  89666. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  89667. /**
  89668. * Removes an existing geometry
  89669. * @param geometry defines the geometry to be removed from the scene
  89670. * @return a boolean defining if the geometry was removed or not
  89671. */
  89672. removeGeometry(geometry: Geometry): boolean;
  89673. /**
  89674. * Gets the list of geometries attached to the scene
  89675. * @returns an array of Geometry
  89676. */
  89677. getGeometries(): Geometry[];
  89678. /**
  89679. * Gets the first added mesh found of a given ID
  89680. * @param id defines the id to search for
  89681. * @return the mesh found or null if not found at all
  89682. */
  89683. getMeshByID(id: string): Nullable<AbstractMesh>;
  89684. /**
  89685. * Gets a list of meshes using their id
  89686. * @param id defines the id to search for
  89687. * @returns a list of meshes
  89688. */
  89689. getMeshesByID(id: string): Array<AbstractMesh>;
  89690. /**
  89691. * Gets the first added transform node found of a given ID
  89692. * @param id defines the id to search for
  89693. * @return the found transform node or null if not found at all.
  89694. */
  89695. getTransformNodeByID(id: string): Nullable<TransformNode>;
  89696. /**
  89697. * Gets a list of transform nodes using their id
  89698. * @param id defines the id to search for
  89699. * @returns a list of transform nodes
  89700. */
  89701. getTransformNodesByID(id: string): Array<TransformNode>;
  89702. /**
  89703. * Gets a mesh with its auto-generated unique id
  89704. * @param uniqueId defines the unique id to search for
  89705. * @return the found mesh or null if not found at all.
  89706. */
  89707. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  89708. /**
  89709. * Gets a the last added mesh using a given id
  89710. * @param id defines the id to search for
  89711. * @return the found mesh or null if not found at all.
  89712. */
  89713. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  89714. /**
  89715. * Gets a the last added node (Mesh, Camera, Light) using a given id
  89716. * @param id defines the id to search for
  89717. * @return the found node or null if not found at all
  89718. */
  89719. getLastEntryByID(id: string): Nullable<Node>;
  89720. /**
  89721. * Gets a node (Mesh, Camera, Light) using a given id
  89722. * @param id defines the id to search for
  89723. * @return the found node or null if not found at all
  89724. */
  89725. getNodeByID(id: string): Nullable<Node>;
  89726. /**
  89727. * Gets a node (Mesh, Camera, Light) using a given name
  89728. * @param name defines the name to search for
  89729. * @return the found node or null if not found at all.
  89730. */
  89731. getNodeByName(name: string): Nullable<Node>;
  89732. /**
  89733. * Gets a mesh using a given name
  89734. * @param name defines the name to search for
  89735. * @return the found mesh or null if not found at all.
  89736. */
  89737. getMeshByName(name: string): Nullable<AbstractMesh>;
  89738. /**
  89739. * Gets a transform node using a given name
  89740. * @param name defines the name to search for
  89741. * @return the found transform node or null if not found at all.
  89742. */
  89743. getTransformNodeByName(name: string): Nullable<TransformNode>;
  89744. /**
  89745. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  89746. * @param id defines the id to search for
  89747. * @return the found skeleton or null if not found at all.
  89748. */
  89749. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  89750. /**
  89751. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  89752. * @param id defines the id to search for
  89753. * @return the found skeleton or null if not found at all.
  89754. */
  89755. getSkeletonById(id: string): Nullable<Skeleton>;
  89756. /**
  89757. * Gets a skeleton using a given name
  89758. * @param name defines the name to search for
  89759. * @return the found skeleton or null if not found at all.
  89760. */
  89761. getSkeletonByName(name: string): Nullable<Skeleton>;
  89762. /**
  89763. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  89764. * @param id defines the id to search for
  89765. * @return the found morph target manager or null if not found at all.
  89766. */
  89767. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  89768. /**
  89769. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  89770. * @param id defines the id to search for
  89771. * @return the found morph target or null if not found at all.
  89772. */
  89773. getMorphTargetById(id: string): Nullable<MorphTarget>;
  89774. /**
  89775. * Gets a boolean indicating if the given mesh is active
  89776. * @param mesh defines the mesh to look for
  89777. * @returns true if the mesh is in the active list
  89778. */
  89779. isActiveMesh(mesh: AbstractMesh): boolean;
  89780. /**
  89781. * Return a unique id as a string which can serve as an identifier for the scene
  89782. */
  89783. readonly uid: string;
  89784. /**
  89785. * Add an externaly attached data from its key.
  89786. * This method call will fail and return false, if such key already exists.
  89787. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  89788. * @param key the unique key that identifies the data
  89789. * @param data the data object to associate to the key for this Engine instance
  89790. * @return true if no such key were already present and the data was added successfully, false otherwise
  89791. */
  89792. addExternalData<T>(key: string, data: T): boolean;
  89793. /**
  89794. * Get an externaly attached data from its key
  89795. * @param key the unique key that identifies the data
  89796. * @return the associated data, if present (can be null), or undefined if not present
  89797. */
  89798. getExternalData<T>(key: string): Nullable<T>;
  89799. /**
  89800. * Get an externaly attached data from its key, create it using a factory if it's not already present
  89801. * @param key the unique key that identifies the data
  89802. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  89803. * @return the associated data, can be null if the factory returned null.
  89804. */
  89805. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  89806. /**
  89807. * Remove an externaly attached data from the Engine instance
  89808. * @param key the unique key that identifies the data
  89809. * @return true if the data was successfully removed, false if it doesn't exist
  89810. */
  89811. removeExternalData(key: string): boolean;
  89812. private _evaluateSubMesh;
  89813. /**
  89814. * Clear the processed materials smart array preventing retention point in material dispose.
  89815. */
  89816. freeProcessedMaterials(): void;
  89817. private _preventFreeActiveMeshesAndRenderingGroups;
  89818. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  89819. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  89820. * when disposing several meshes in a row or a hierarchy of meshes.
  89821. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  89822. */
  89823. blockfreeActiveMeshesAndRenderingGroups: boolean;
  89824. /**
  89825. * Clear the active meshes smart array preventing retention point in mesh dispose.
  89826. */
  89827. freeActiveMeshes(): void;
  89828. /**
  89829. * Clear the info related to rendering groups preventing retention points during dispose.
  89830. */
  89831. freeRenderingGroups(): void;
  89832. /** @hidden */
  89833. _isInIntermediateRendering(): boolean;
  89834. /**
  89835. * Lambda returning the list of potentially active meshes.
  89836. */
  89837. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  89838. /**
  89839. * Lambda returning the list of potentially active sub meshes.
  89840. */
  89841. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  89842. /**
  89843. * Lambda returning the list of potentially intersecting sub meshes.
  89844. */
  89845. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  89846. /**
  89847. * Lambda returning the list of potentially colliding sub meshes.
  89848. */
  89849. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  89850. private _activeMeshesFrozen;
  89851. /**
  89852. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  89853. * @returns the current scene
  89854. */
  89855. freezeActiveMeshes(): Scene;
  89856. /**
  89857. * Use this function to restart evaluating active meshes on every frame
  89858. * @returns the current scene
  89859. */
  89860. unfreezeActiveMeshes(): Scene;
  89861. private _evaluateActiveMeshes;
  89862. private _activeMesh;
  89863. /**
  89864. * Update the transform matrix to update from the current active camera
  89865. * @param force defines a boolean used to force the update even if cache is up to date
  89866. */
  89867. updateTransformMatrix(force?: boolean): void;
  89868. /**
  89869. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  89870. * @param alternateCamera defines the camera to use
  89871. */
  89872. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  89873. /** @hidden */
  89874. _allowPostProcessClearColor: boolean;
  89875. private _renderForCamera;
  89876. private _processSubCameras;
  89877. private _checkIntersections;
  89878. /** @hidden */
  89879. _advancePhysicsEngineStep(step: number): void;
  89880. /**
  89881. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  89882. */
  89883. getDeterministicFrameTime: () => number;
  89884. /** @hidden */
  89885. _animate(): void;
  89886. /**
  89887. * Render the scene
  89888. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  89889. */
  89890. render(updateCameras?: boolean): void;
  89891. /**
  89892. * Freeze all materials
  89893. * A frozen material will not be updatable but should be faster to render
  89894. */
  89895. freezeMaterials(): void;
  89896. /**
  89897. * Unfreeze all materials
  89898. * A frozen material will not be updatable but should be faster to render
  89899. */
  89900. unfreezeMaterials(): void;
  89901. /**
  89902. * Releases all held ressources
  89903. */
  89904. dispose(): void;
  89905. /**
  89906. * Gets if the scene is already disposed
  89907. */
  89908. readonly isDisposed: boolean;
  89909. /**
  89910. * Call this function to reduce memory footprint of the scene.
  89911. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  89912. */
  89913. clearCachedVertexData(): void;
  89914. /**
  89915. * This function will remove the local cached buffer data from texture.
  89916. * It will save memory but will prevent the texture from being rebuilt
  89917. */
  89918. cleanCachedTextureBuffer(): void;
  89919. /**
  89920. * Get the world extend vectors with an optional filter
  89921. *
  89922. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  89923. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  89924. */
  89925. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  89926. min: Vector3;
  89927. max: Vector3;
  89928. };
  89929. /**
  89930. * Creates a ray that can be used to pick in the scene
  89931. * @param x defines the x coordinate of the origin (on-screen)
  89932. * @param y defines the y coordinate of the origin (on-screen)
  89933. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  89934. * @param camera defines the camera to use for the picking
  89935. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  89936. * @returns a Ray
  89937. */
  89938. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  89939. /**
  89940. * Creates a ray that can be used to pick in the scene
  89941. * @param x defines the x coordinate of the origin (on-screen)
  89942. * @param y defines the y coordinate of the origin (on-screen)
  89943. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  89944. * @param result defines the ray where to store the picking ray
  89945. * @param camera defines the camera to use for the picking
  89946. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  89947. * @returns the current scene
  89948. */
  89949. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  89950. /**
  89951. * Creates a ray that can be used to pick in the scene
  89952. * @param x defines the x coordinate of the origin (on-screen)
  89953. * @param y defines the y coordinate of the origin (on-screen)
  89954. * @param camera defines the camera to use for the picking
  89955. * @returns a Ray
  89956. */
  89957. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  89958. /**
  89959. * Creates a ray that can be used to pick in the scene
  89960. * @param x defines the x coordinate of the origin (on-screen)
  89961. * @param y defines the y coordinate of the origin (on-screen)
  89962. * @param result defines the ray where to store the picking ray
  89963. * @param camera defines the camera to use for the picking
  89964. * @returns the current scene
  89965. */
  89966. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  89967. /** Launch a ray to try to pick a mesh in the scene
  89968. * @param x position on screen
  89969. * @param y position on screen
  89970. * @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
  89971. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  89972. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89973. * @returns a PickingInfo
  89974. */
  89975. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  89976. /** Use the given ray to pick a mesh in the scene
  89977. * @param ray The ray to use to pick meshes
  89978. * @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
  89979. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  89980. * @returns a PickingInfo
  89981. */
  89982. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89983. /**
  89984. * Launch a ray to try to pick a mesh in the scene
  89985. * @param x X position on screen
  89986. * @param y Y position on screen
  89987. * @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
  89988. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89989. * @returns an array of PickingInfo
  89990. */
  89991. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89992. /**
  89993. * Launch a ray to try to pick a mesh in the scene
  89994. * @param ray Ray to use
  89995. * @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
  89996. * @returns an array of PickingInfo
  89997. */
  89998. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  89999. /**
  90000. * Force the value of meshUnderPointer
  90001. * @param mesh defines the mesh to use
  90002. */
  90003. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  90004. /**
  90005. * Gets the mesh under the pointer
  90006. * @returns a Mesh or null if no mesh is under the pointer
  90007. */
  90008. getPointerOverMesh(): Nullable<AbstractMesh>;
  90009. /** @hidden */
  90010. _rebuildGeometries(): void;
  90011. /** @hidden */
  90012. _rebuildTextures(): void;
  90013. private _getByTags;
  90014. /**
  90015. * Get a list of meshes by tags
  90016. * @param tagsQuery defines the tags query to use
  90017. * @param forEach defines a predicate used to filter results
  90018. * @returns an array of Mesh
  90019. */
  90020. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  90021. /**
  90022. * Get a list of cameras by tags
  90023. * @param tagsQuery defines the tags query to use
  90024. * @param forEach defines a predicate used to filter results
  90025. * @returns an array of Camera
  90026. */
  90027. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  90028. /**
  90029. * Get a list of lights by tags
  90030. * @param tagsQuery defines the tags query to use
  90031. * @param forEach defines a predicate used to filter results
  90032. * @returns an array of Light
  90033. */
  90034. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  90035. /**
  90036. * Get a list of materials by tags
  90037. * @param tagsQuery defines the tags query to use
  90038. * @param forEach defines a predicate used to filter results
  90039. * @returns an array of Material
  90040. */
  90041. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  90042. /**
  90043. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90044. * This allowed control for front to back rendering or reversly depending of the special needs.
  90045. *
  90046. * @param renderingGroupId The rendering group id corresponding to its index
  90047. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90048. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90049. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90050. */
  90051. 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;
  90052. /**
  90053. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90054. *
  90055. * @param renderingGroupId The rendering group id corresponding to its index
  90056. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90057. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90058. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90059. */
  90060. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90061. /**
  90062. * Gets the current auto clear configuration for one rendering group of the rendering
  90063. * manager.
  90064. * @param index the rendering group index to get the information for
  90065. * @returns The auto clear setup for the requested rendering group
  90066. */
  90067. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90068. private _blockMaterialDirtyMechanism;
  90069. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  90070. blockMaterialDirtyMechanism: boolean;
  90071. /**
  90072. * Will flag all materials as dirty to trigger new shader compilation
  90073. * @param flag defines the flag used to specify which material part must be marked as dirty
  90074. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  90075. */
  90076. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90077. /** @hidden */
  90078. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  90079. /** @hidden */
  90080. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  90081. }
  90082. }
  90083. declare module BABYLON {
  90084. /**
  90085. * Set of assets to keep when moving a scene into an asset container.
  90086. */
  90087. export class KeepAssets extends AbstractScene {
  90088. }
  90089. /**
  90090. * Container with a set of assets that can be added or removed from a scene.
  90091. */
  90092. export class AssetContainer extends AbstractScene {
  90093. /**
  90094. * The scene the AssetContainer belongs to.
  90095. */
  90096. scene: Scene;
  90097. /**
  90098. * Instantiates an AssetContainer.
  90099. * @param scene The scene the AssetContainer belongs to.
  90100. */
  90101. constructor(scene: Scene);
  90102. /**
  90103. * Adds all the assets from the container to the scene.
  90104. */
  90105. addAllToScene(): void;
  90106. /**
  90107. * Removes all the assets in the container from the scene
  90108. */
  90109. removeAllFromScene(): void;
  90110. /**
  90111. * Disposes all the assets in the container
  90112. */
  90113. dispose(): void;
  90114. private _moveAssets;
  90115. /**
  90116. * Removes all the assets contained in the scene and adds them to the container.
  90117. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  90118. */
  90119. moveAllFromScene(keepAssets?: KeepAssets): void;
  90120. /**
  90121. * 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.
  90122. * @returns the root mesh
  90123. */
  90124. createRootMesh(): Mesh;
  90125. }
  90126. }
  90127. declare module BABYLON {
  90128. /**
  90129. * Defines how the parser contract is defined.
  90130. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  90131. */
  90132. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  90133. /**
  90134. * Defines how the individual parser contract is defined.
  90135. * These parser can parse an individual asset
  90136. */
  90137. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  90138. /**
  90139. * Base class of the scene acting as a container for the different elements composing a scene.
  90140. * This class is dynamically extended by the different components of the scene increasing
  90141. * flexibility and reducing coupling
  90142. */
  90143. export abstract class AbstractScene {
  90144. /**
  90145. * Stores the list of available parsers in the application.
  90146. */
  90147. private static _BabylonFileParsers;
  90148. /**
  90149. * Stores the list of available individual parsers in the application.
  90150. */
  90151. private static _IndividualBabylonFileParsers;
  90152. /**
  90153. * Adds a parser in the list of available ones
  90154. * @param name Defines the name of the parser
  90155. * @param parser Defines the parser to add
  90156. */
  90157. static AddParser(name: string, parser: BabylonFileParser): void;
  90158. /**
  90159. * Gets a general parser from the list of avaialble ones
  90160. * @param name Defines the name of the parser
  90161. * @returns the requested parser or null
  90162. */
  90163. static GetParser(name: string): Nullable<BabylonFileParser>;
  90164. /**
  90165. * Adds n individual parser in the list of available ones
  90166. * @param name Defines the name of the parser
  90167. * @param parser Defines the parser to add
  90168. */
  90169. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  90170. /**
  90171. * Gets an individual parser from the list of avaialble ones
  90172. * @param name Defines the name of the parser
  90173. * @returns the requested parser or null
  90174. */
  90175. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  90176. /**
  90177. * Parser json data and populate both a scene and its associated container object
  90178. * @param jsonData Defines the data to parse
  90179. * @param scene Defines the scene to parse the data for
  90180. * @param container Defines the container attached to the parsing sequence
  90181. * @param rootUrl Defines the root url of the data
  90182. */
  90183. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  90184. /**
  90185. * Gets the list of root nodes (ie. nodes with no parent)
  90186. */
  90187. rootNodes: Node[];
  90188. /** All of the cameras added to this scene
  90189. * @see http://doc.babylonjs.com/babylon101/cameras
  90190. */
  90191. cameras: Camera[];
  90192. /**
  90193. * All of the lights added to this scene
  90194. * @see http://doc.babylonjs.com/babylon101/lights
  90195. */
  90196. lights: Light[];
  90197. /**
  90198. * All of the (abstract) meshes added to this scene
  90199. */
  90200. meshes: AbstractMesh[];
  90201. /**
  90202. * The list of skeletons added to the scene
  90203. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90204. */
  90205. skeletons: Skeleton[];
  90206. /**
  90207. * All of the particle systems added to this scene
  90208. * @see http://doc.babylonjs.com/babylon101/particles
  90209. */
  90210. particleSystems: IParticleSystem[];
  90211. /**
  90212. * Gets a list of Animations associated with the scene
  90213. */
  90214. animations: Animation[];
  90215. /**
  90216. * All of the animation groups added to this scene
  90217. * @see http://doc.babylonjs.com/how_to/group
  90218. */
  90219. animationGroups: AnimationGroup[];
  90220. /**
  90221. * All of the multi-materials added to this scene
  90222. * @see http://doc.babylonjs.com/how_to/multi_materials
  90223. */
  90224. multiMaterials: MultiMaterial[];
  90225. /**
  90226. * All of the materials added to this scene
  90227. * In the context of a Scene, it is not supposed to be modified manually.
  90228. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  90229. * Note also that the order of the Material wihin the array is not significant and might change.
  90230. * @see http://doc.babylonjs.com/babylon101/materials
  90231. */
  90232. materials: Material[];
  90233. /**
  90234. * The list of morph target managers added to the scene
  90235. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  90236. */
  90237. morphTargetManagers: MorphTargetManager[];
  90238. /**
  90239. * The list of geometries used in the scene.
  90240. */
  90241. geometries: Geometry[];
  90242. /**
  90243. * All of the tranform nodes added to this scene
  90244. * In the context of a Scene, it is not supposed to be modified manually.
  90245. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  90246. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  90247. * @see http://doc.babylonjs.com/how_to/transformnode
  90248. */
  90249. transformNodes: TransformNode[];
  90250. /**
  90251. * ActionManagers available on the scene.
  90252. */
  90253. actionManagers: AbstractActionManager[];
  90254. /**
  90255. * Textures to keep.
  90256. */
  90257. textures: BaseTexture[];
  90258. }
  90259. }
  90260. declare module BABYLON {
  90261. /**
  90262. * Defines a sound that can be played in the application.
  90263. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  90264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90265. */
  90266. export class Sound {
  90267. /**
  90268. * The name of the sound in the scene.
  90269. */
  90270. name: string;
  90271. /**
  90272. * Does the sound autoplay once loaded.
  90273. */
  90274. autoplay: boolean;
  90275. /**
  90276. * Does the sound loop after it finishes playing once.
  90277. */
  90278. loop: boolean;
  90279. /**
  90280. * Does the sound use a custom attenuation curve to simulate the falloff
  90281. * happening when the source gets further away from the camera.
  90282. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90283. */
  90284. useCustomAttenuation: boolean;
  90285. /**
  90286. * The sound track id this sound belongs to.
  90287. */
  90288. soundTrackId: number;
  90289. /**
  90290. * Is this sound currently played.
  90291. */
  90292. isPlaying: boolean;
  90293. /**
  90294. * Is this sound currently paused.
  90295. */
  90296. isPaused: boolean;
  90297. /**
  90298. * Does this sound enables spatial sound.
  90299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90300. */
  90301. spatialSound: boolean;
  90302. /**
  90303. * Define the reference distance the sound should be heard perfectly.
  90304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90305. */
  90306. refDistance: number;
  90307. /**
  90308. * Define the roll off factor of spatial sounds.
  90309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90310. */
  90311. rolloffFactor: number;
  90312. /**
  90313. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  90314. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90315. */
  90316. maxDistance: number;
  90317. /**
  90318. * Define the distance attenuation model the sound will follow.
  90319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90320. */
  90321. distanceModel: string;
  90322. /**
  90323. * @hidden
  90324. * Back Compat
  90325. **/
  90326. onended: () => any;
  90327. /**
  90328. * Observable event when the current playing sound finishes.
  90329. */
  90330. onEndedObservable: Observable<Sound>;
  90331. private _panningModel;
  90332. private _playbackRate;
  90333. private _streaming;
  90334. private _startTime;
  90335. private _startOffset;
  90336. private _position;
  90337. /** @hidden */
  90338. _positionInEmitterSpace: boolean;
  90339. private _localDirection;
  90340. private _volume;
  90341. private _isReadyToPlay;
  90342. private _isDirectional;
  90343. private _readyToPlayCallback;
  90344. private _audioBuffer;
  90345. private _soundSource;
  90346. private _streamingSource;
  90347. private _soundPanner;
  90348. private _soundGain;
  90349. private _inputAudioNode;
  90350. private _outputAudioNode;
  90351. private _coneInnerAngle;
  90352. private _coneOuterAngle;
  90353. private _coneOuterGain;
  90354. private _scene;
  90355. private _connectedTransformNode;
  90356. private _customAttenuationFunction;
  90357. private _registerFunc;
  90358. private _isOutputConnected;
  90359. private _htmlAudioElement;
  90360. private _urlType;
  90361. /** @hidden */
  90362. static _SceneComponentInitialization: (scene: Scene) => void;
  90363. /**
  90364. * Create a sound and attach it to a scene
  90365. * @param name Name of your sound
  90366. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  90367. * @param scene defines the scene the sound belongs to
  90368. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  90369. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  90370. */
  90371. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  90372. /**
  90373. * Release the sound and its associated resources
  90374. */
  90375. dispose(): void;
  90376. /**
  90377. * Gets if the sounds is ready to be played or not.
  90378. * @returns true if ready, otherwise false
  90379. */
  90380. isReady(): boolean;
  90381. private _soundLoaded;
  90382. /**
  90383. * Sets the data of the sound from an audiobuffer
  90384. * @param audioBuffer The audioBuffer containing the data
  90385. */
  90386. setAudioBuffer(audioBuffer: AudioBuffer): void;
  90387. /**
  90388. * Updates the current sounds options such as maxdistance, loop...
  90389. * @param options A JSON object containing values named as the object properties
  90390. */
  90391. updateOptions(options: any): void;
  90392. private _createSpatialParameters;
  90393. private _updateSpatialParameters;
  90394. /**
  90395. * Switch the panning model to HRTF:
  90396. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90397. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90398. */
  90399. switchPanningModelToHRTF(): void;
  90400. /**
  90401. * Switch the panning model to Equal Power:
  90402. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90404. */
  90405. switchPanningModelToEqualPower(): void;
  90406. private _switchPanningModel;
  90407. /**
  90408. * Connect this sound to a sound track audio node like gain...
  90409. * @param soundTrackAudioNode the sound track audio node to connect to
  90410. */
  90411. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  90412. /**
  90413. * Transform this sound into a directional source
  90414. * @param coneInnerAngle Size of the inner cone in degree
  90415. * @param coneOuterAngle Size of the outer cone in degree
  90416. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  90417. */
  90418. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  90419. /**
  90420. * Gets or sets the inner angle for the directional cone.
  90421. */
  90422. /**
  90423. * Gets or sets the inner angle for the directional cone.
  90424. */
  90425. directionalConeInnerAngle: number;
  90426. /**
  90427. * Gets or sets the outer angle for the directional cone.
  90428. */
  90429. /**
  90430. * Gets or sets the outer angle for the directional cone.
  90431. */
  90432. directionalConeOuterAngle: number;
  90433. /**
  90434. * Sets the position of the emitter if spatial sound is enabled
  90435. * @param newPosition Defines the new posisiton
  90436. */
  90437. setPosition(newPosition: Vector3): void;
  90438. /**
  90439. * Sets the local direction of the emitter if spatial sound is enabled
  90440. * @param newLocalDirection Defines the new local direction
  90441. */
  90442. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  90443. private _updateDirection;
  90444. /** @hidden */
  90445. updateDistanceFromListener(): void;
  90446. /**
  90447. * Sets a new custom attenuation function for the sound.
  90448. * @param callback Defines the function used for the attenuation
  90449. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90450. */
  90451. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  90452. /**
  90453. * Play the sound
  90454. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  90455. * @param offset (optional) Start the sound setting it at a specific time
  90456. */
  90457. play(time?: number, offset?: number): void;
  90458. private _onended;
  90459. /**
  90460. * Stop the sound
  90461. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  90462. */
  90463. stop(time?: number): void;
  90464. /**
  90465. * Put the sound in pause
  90466. */
  90467. pause(): void;
  90468. /**
  90469. * Sets a dedicated volume for this sounds
  90470. * @param newVolume Define the new volume of the sound
  90471. * @param time Define in how long the sound should be at this value
  90472. */
  90473. setVolume(newVolume: number, time?: number): void;
  90474. /**
  90475. * Set the sound play back rate
  90476. * @param newPlaybackRate Define the playback rate the sound should be played at
  90477. */
  90478. setPlaybackRate(newPlaybackRate: number): void;
  90479. /**
  90480. * Gets the volume of the sound.
  90481. * @returns the volume of the sound
  90482. */
  90483. getVolume(): number;
  90484. /**
  90485. * Attach the sound to a dedicated mesh
  90486. * @param transformNode The transform node to connect the sound with
  90487. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90488. */
  90489. attachToMesh(transformNode: TransformNode): void;
  90490. /**
  90491. * Detach the sound from the previously attached mesh
  90492. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90493. */
  90494. detachFromMesh(): void;
  90495. private _onRegisterAfterWorldMatrixUpdate;
  90496. /**
  90497. * Clone the current sound in the scene.
  90498. * @returns the new sound clone
  90499. */
  90500. clone(): Nullable<Sound>;
  90501. /**
  90502. * Gets the current underlying audio buffer containing the data
  90503. * @returns the audio buffer
  90504. */
  90505. getAudioBuffer(): Nullable<AudioBuffer>;
  90506. /**
  90507. * Serializes the Sound in a JSON representation
  90508. * @returns the JSON representation of the sound
  90509. */
  90510. serialize(): any;
  90511. /**
  90512. * Parse a JSON representation of a sound to innstantiate in a given scene
  90513. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  90514. * @param scene Define the scene the new parsed sound should be created in
  90515. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  90516. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  90517. * @returns the newly parsed sound
  90518. */
  90519. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  90520. }
  90521. }
  90522. declare module BABYLON {
  90523. /**
  90524. * This defines an action helpful to play a defined sound on a triggered action.
  90525. */
  90526. export class PlaySoundAction extends Action {
  90527. private _sound;
  90528. /**
  90529. * Instantiate the action
  90530. * @param triggerOptions defines the trigger options
  90531. * @param sound defines the sound to play
  90532. * @param condition defines the trigger related conditions
  90533. */
  90534. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90535. /** @hidden */
  90536. _prepare(): void;
  90537. /**
  90538. * Execute the action and play the sound.
  90539. */
  90540. execute(): void;
  90541. /**
  90542. * Serializes the actions and its related information.
  90543. * @param parent defines the object to serialize in
  90544. * @returns the serialized object
  90545. */
  90546. serialize(parent: any): any;
  90547. }
  90548. /**
  90549. * This defines an action helpful to stop a defined sound on a triggered action.
  90550. */
  90551. export class StopSoundAction extends Action {
  90552. private _sound;
  90553. /**
  90554. * Instantiate the action
  90555. * @param triggerOptions defines the trigger options
  90556. * @param sound defines the sound to stop
  90557. * @param condition defines the trigger related conditions
  90558. */
  90559. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90560. /** @hidden */
  90561. _prepare(): void;
  90562. /**
  90563. * Execute the action and stop the sound.
  90564. */
  90565. execute(): void;
  90566. /**
  90567. * Serializes the actions and its related information.
  90568. * @param parent defines the object to serialize in
  90569. * @returns the serialized object
  90570. */
  90571. serialize(parent: any): any;
  90572. }
  90573. }
  90574. declare module BABYLON {
  90575. /**
  90576. * This defines an action responsible to change the value of a property
  90577. * by interpolating between its current value and the newly set one once triggered.
  90578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90579. */
  90580. export class InterpolateValueAction extends Action {
  90581. /**
  90582. * Defines the path of the property where the value should be interpolated
  90583. */
  90584. propertyPath: string;
  90585. /**
  90586. * Defines the target value at the end of the interpolation.
  90587. */
  90588. value: any;
  90589. /**
  90590. * Defines the time it will take for the property to interpolate to the value.
  90591. */
  90592. duration: number;
  90593. /**
  90594. * Defines if the other scene animations should be stopped when the action has been triggered
  90595. */
  90596. stopOtherAnimations?: boolean;
  90597. /**
  90598. * Defines a callback raised once the interpolation animation has been done.
  90599. */
  90600. onInterpolationDone?: () => void;
  90601. /**
  90602. * Observable triggered once the interpolation animation has been done.
  90603. */
  90604. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  90605. private _target;
  90606. private _effectiveTarget;
  90607. private _property;
  90608. /**
  90609. * Instantiate the action
  90610. * @param triggerOptions defines the trigger options
  90611. * @param target defines the object containing the value to interpolate
  90612. * @param propertyPath defines the path to the property in the target object
  90613. * @param value defines the target value at the end of the interpolation
  90614. * @param duration deines the time it will take for the property to interpolate to the value.
  90615. * @param condition defines the trigger related conditions
  90616. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  90617. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  90618. */
  90619. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  90620. /** @hidden */
  90621. _prepare(): void;
  90622. /**
  90623. * Execute the action starts the value interpolation.
  90624. */
  90625. execute(): void;
  90626. /**
  90627. * Serializes the actions and its related information.
  90628. * @param parent defines the object to serialize in
  90629. * @returns the serialized object
  90630. */
  90631. serialize(parent: any): any;
  90632. }
  90633. }
  90634. declare module BABYLON {
  90635. /**
  90636. * Options allowed during the creation of a sound track.
  90637. */
  90638. export interface ISoundTrackOptions {
  90639. /**
  90640. * The volume the sound track should take during creation
  90641. */
  90642. volume?: number;
  90643. /**
  90644. * Define if the sound track is the main sound track of the scene
  90645. */
  90646. mainTrack?: boolean;
  90647. }
  90648. /**
  90649. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  90650. * It will be also used in a future release to apply effects on a specific track.
  90651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90652. */
  90653. export class SoundTrack {
  90654. /**
  90655. * The unique identifier of the sound track in the scene.
  90656. */
  90657. id: number;
  90658. /**
  90659. * The list of sounds included in the sound track.
  90660. */
  90661. soundCollection: Array<Sound>;
  90662. private _outputAudioNode;
  90663. private _scene;
  90664. private _isMainTrack;
  90665. private _connectedAnalyser;
  90666. private _options;
  90667. private _isInitialized;
  90668. /**
  90669. * Creates a new sound track.
  90670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90671. * @param scene Define the scene the sound track belongs to
  90672. * @param options
  90673. */
  90674. constructor(scene: Scene, options?: ISoundTrackOptions);
  90675. private _initializeSoundTrackAudioGraph;
  90676. /**
  90677. * Release the sound track and its associated resources
  90678. */
  90679. dispose(): void;
  90680. /**
  90681. * Adds a sound to this sound track
  90682. * @param sound define the cound to add
  90683. * @ignoreNaming
  90684. */
  90685. AddSound(sound: Sound): void;
  90686. /**
  90687. * Removes a sound to this sound track
  90688. * @param sound define the cound to remove
  90689. * @ignoreNaming
  90690. */
  90691. RemoveSound(sound: Sound): void;
  90692. /**
  90693. * Set a global volume for the full sound track.
  90694. * @param newVolume Define the new volume of the sound track
  90695. */
  90696. setVolume(newVolume: number): void;
  90697. /**
  90698. * Switch the panning model to HRTF:
  90699. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90701. */
  90702. switchPanningModelToHRTF(): void;
  90703. /**
  90704. * Switch the panning model to Equal Power:
  90705. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90707. */
  90708. switchPanningModelToEqualPower(): void;
  90709. /**
  90710. * Connect the sound track to an audio analyser allowing some amazing
  90711. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  90712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  90713. * @param analyser The analyser to connect to the engine
  90714. */
  90715. connectToAnalyser(analyser: Analyser): void;
  90716. }
  90717. }
  90718. declare module BABYLON {
  90719. interface AbstractScene {
  90720. /**
  90721. * The list of sounds used in the scene.
  90722. */
  90723. sounds: Nullable<Array<Sound>>;
  90724. }
  90725. interface Scene {
  90726. /**
  90727. * @hidden
  90728. * Backing field
  90729. */
  90730. _mainSoundTrack: SoundTrack;
  90731. /**
  90732. * The main sound track played by the scene.
  90733. * It cotains your primary collection of sounds.
  90734. */
  90735. mainSoundTrack: SoundTrack;
  90736. /**
  90737. * The list of sound tracks added to the scene
  90738. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90739. */
  90740. soundTracks: Nullable<Array<SoundTrack>>;
  90741. /**
  90742. * Gets a sound using a given name
  90743. * @param name defines the name to search for
  90744. * @return the found sound or null if not found at all.
  90745. */
  90746. getSoundByName(name: string): Nullable<Sound>;
  90747. /**
  90748. * Gets or sets if audio support is enabled
  90749. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90750. */
  90751. audioEnabled: boolean;
  90752. /**
  90753. * Gets or sets if audio will be output to headphones
  90754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90755. */
  90756. headphone: boolean;
  90757. }
  90758. /**
  90759. * Defines the sound scene component responsible to manage any sounds
  90760. * in a given scene.
  90761. */
  90762. export class AudioSceneComponent implements ISceneSerializableComponent {
  90763. /**
  90764. * The component name helpfull to identify the component in the list of scene components.
  90765. */
  90766. readonly name: string;
  90767. /**
  90768. * The scene the component belongs to.
  90769. */
  90770. scene: Scene;
  90771. private _audioEnabled;
  90772. /**
  90773. * Gets whether audio is enabled or not.
  90774. * Please use related enable/disable method to switch state.
  90775. */
  90776. readonly audioEnabled: boolean;
  90777. private _headphone;
  90778. /**
  90779. * Gets whether audio is outputing to headphone or not.
  90780. * Please use the according Switch methods to change output.
  90781. */
  90782. readonly headphone: boolean;
  90783. /**
  90784. * Creates a new instance of the component for the given scene
  90785. * @param scene Defines the scene to register the component in
  90786. */
  90787. constructor(scene: Scene);
  90788. /**
  90789. * Registers the component in a given scene
  90790. */
  90791. register(): void;
  90792. /**
  90793. * Rebuilds the elements related to this component in case of
  90794. * context lost for instance.
  90795. */
  90796. rebuild(): void;
  90797. /**
  90798. * Serializes the component data to the specified json object
  90799. * @param serializationObject The object to serialize to
  90800. */
  90801. serialize(serializationObject: any): void;
  90802. /**
  90803. * Adds all the element from the container to the scene
  90804. * @param container the container holding the elements
  90805. */
  90806. addFromContainer(container: AbstractScene): void;
  90807. /**
  90808. * Removes all the elements in the container from the scene
  90809. * @param container contains the elements to remove
  90810. */
  90811. removeFromContainer(container: AbstractScene): void;
  90812. /**
  90813. * Disposes the component and the associated ressources.
  90814. */
  90815. dispose(): void;
  90816. /**
  90817. * Disables audio in the associated scene.
  90818. */
  90819. disableAudio(): void;
  90820. /**
  90821. * Enables audio in the associated scene.
  90822. */
  90823. enableAudio(): void;
  90824. /**
  90825. * Switch audio to headphone output.
  90826. */
  90827. switchAudioModeForHeadphones(): void;
  90828. /**
  90829. * Switch audio to normal speakers.
  90830. */
  90831. switchAudioModeForNormalSpeakers(): void;
  90832. private _afterRender;
  90833. }
  90834. }
  90835. declare module BABYLON {
  90836. /**
  90837. * Wraps one or more Sound objects and selects one with random weight for playback.
  90838. */
  90839. export class WeightedSound {
  90840. /** When true a Sound will be selected and played when the current playing Sound completes. */
  90841. loop: boolean;
  90842. private _coneInnerAngle;
  90843. private _coneOuterAngle;
  90844. private _volume;
  90845. /** A Sound is currently playing. */
  90846. isPlaying: boolean;
  90847. /** A Sound is currently paused. */
  90848. isPaused: boolean;
  90849. private _sounds;
  90850. private _weights;
  90851. private _currentIndex?;
  90852. /**
  90853. * Creates a new WeightedSound from the list of sounds given.
  90854. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  90855. * @param sounds Array of Sounds that will be selected from.
  90856. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  90857. */
  90858. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  90859. /**
  90860. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  90861. */
  90862. /**
  90863. * The size of cone in degress for a directional sound in which there will be no attenuation.
  90864. */
  90865. directionalConeInnerAngle: number;
  90866. /**
  90867. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  90868. * Listener angles between innerAngle and outerAngle will falloff linearly.
  90869. */
  90870. /**
  90871. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  90872. * Listener angles between innerAngle and outerAngle will falloff linearly.
  90873. */
  90874. directionalConeOuterAngle: number;
  90875. /**
  90876. * Playback volume.
  90877. */
  90878. /**
  90879. * Playback volume.
  90880. */
  90881. volume: number;
  90882. private _onended;
  90883. /**
  90884. * Suspend playback
  90885. */
  90886. pause(): void;
  90887. /**
  90888. * Stop playback
  90889. */
  90890. stop(): void;
  90891. /**
  90892. * Start playback.
  90893. * @param startOffset Position the clip head at a specific time in seconds.
  90894. */
  90895. play(startOffset?: number): void;
  90896. }
  90897. }
  90898. declare module BABYLON {
  90899. /**
  90900. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  90901. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90902. */
  90903. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  90904. /**
  90905. * Gets the name of the behavior.
  90906. */
  90907. readonly name: string;
  90908. /**
  90909. * The easing function used by animations
  90910. */
  90911. static EasingFunction: BackEase;
  90912. /**
  90913. * The easing mode used by animations
  90914. */
  90915. static EasingMode: number;
  90916. /**
  90917. * The duration of the animation, in milliseconds
  90918. */
  90919. transitionDuration: number;
  90920. /**
  90921. * Length of the distance animated by the transition when lower radius is reached
  90922. */
  90923. lowerRadiusTransitionRange: number;
  90924. /**
  90925. * Length of the distance animated by the transition when upper radius is reached
  90926. */
  90927. upperRadiusTransitionRange: number;
  90928. private _autoTransitionRange;
  90929. /**
  90930. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  90931. */
  90932. /**
  90933. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  90934. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  90935. */
  90936. autoTransitionRange: boolean;
  90937. private _attachedCamera;
  90938. private _onAfterCheckInputsObserver;
  90939. private _onMeshTargetChangedObserver;
  90940. /**
  90941. * Initializes the behavior.
  90942. */
  90943. init(): void;
  90944. /**
  90945. * Attaches the behavior to its arc rotate camera.
  90946. * @param camera Defines the camera to attach the behavior to
  90947. */
  90948. attach(camera: ArcRotateCamera): void;
  90949. /**
  90950. * Detaches the behavior from its current arc rotate camera.
  90951. */
  90952. detach(): void;
  90953. private _radiusIsAnimating;
  90954. private _radiusBounceTransition;
  90955. private _animatables;
  90956. private _cachedWheelPrecision;
  90957. /**
  90958. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  90959. * @param radiusLimit The limit to check against.
  90960. * @return Bool to indicate if at limit.
  90961. */
  90962. private _isRadiusAtLimit;
  90963. /**
  90964. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  90965. * @param radiusDelta The delta by which to animate to. Can be negative.
  90966. */
  90967. private _applyBoundRadiusAnimation;
  90968. /**
  90969. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  90970. */
  90971. protected _clearAnimationLocks(): void;
  90972. /**
  90973. * Stops and removes all animations that have been applied to the camera
  90974. */
  90975. stopAllAnimations(): void;
  90976. }
  90977. }
  90978. declare module BABYLON {
  90979. /**
  90980. * 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.
  90981. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90982. */
  90983. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  90984. /**
  90985. * Gets the name of the behavior.
  90986. */
  90987. readonly name: string;
  90988. private _mode;
  90989. private _radiusScale;
  90990. private _positionScale;
  90991. private _defaultElevation;
  90992. private _elevationReturnTime;
  90993. private _elevationReturnWaitTime;
  90994. private _zoomStopsAnimation;
  90995. private _framingTime;
  90996. /**
  90997. * The easing function used by animations
  90998. */
  90999. static EasingFunction: ExponentialEase;
  91000. /**
  91001. * The easing mode used by animations
  91002. */
  91003. static EasingMode: number;
  91004. /**
  91005. * Sets the current mode used by the behavior
  91006. */
  91007. /**
  91008. * Gets current mode used by the behavior.
  91009. */
  91010. mode: number;
  91011. /**
  91012. * Sets the scale applied to the radius (1 by default)
  91013. */
  91014. /**
  91015. * Gets the scale applied to the radius
  91016. */
  91017. radiusScale: number;
  91018. /**
  91019. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91020. */
  91021. /**
  91022. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91023. */
  91024. positionScale: number;
  91025. /**
  91026. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91027. * behaviour is triggered, in radians.
  91028. */
  91029. /**
  91030. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91031. * behaviour is triggered, in radians.
  91032. */
  91033. defaultElevation: number;
  91034. /**
  91035. * Sets the time (in milliseconds) taken to return to the default beta position.
  91036. * Negative value indicates camera should not return to default.
  91037. */
  91038. /**
  91039. * Gets the time (in milliseconds) taken to return to the default beta position.
  91040. * Negative value indicates camera should not return to default.
  91041. */
  91042. elevationReturnTime: number;
  91043. /**
  91044. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91045. */
  91046. /**
  91047. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91048. */
  91049. elevationReturnWaitTime: number;
  91050. /**
  91051. * Sets the flag that indicates if user zooming should stop animation.
  91052. */
  91053. /**
  91054. * Gets the flag that indicates if user zooming should stop animation.
  91055. */
  91056. zoomStopsAnimation: boolean;
  91057. /**
  91058. * Sets the transition time when framing the mesh, in milliseconds
  91059. */
  91060. /**
  91061. * Gets the transition time when framing the mesh, in milliseconds
  91062. */
  91063. framingTime: number;
  91064. /**
  91065. * Define if the behavior should automatically change the configured
  91066. * camera limits and sensibilities.
  91067. */
  91068. autoCorrectCameraLimitsAndSensibility: boolean;
  91069. private _onPrePointerObservableObserver;
  91070. private _onAfterCheckInputsObserver;
  91071. private _onMeshTargetChangedObserver;
  91072. private _attachedCamera;
  91073. private _isPointerDown;
  91074. private _lastInteractionTime;
  91075. /**
  91076. * Initializes the behavior.
  91077. */
  91078. init(): void;
  91079. /**
  91080. * Attaches the behavior to its arc rotate camera.
  91081. * @param camera Defines the camera to attach the behavior to
  91082. */
  91083. attach(camera: ArcRotateCamera): void;
  91084. /**
  91085. * Detaches the behavior from its current arc rotate camera.
  91086. */
  91087. detach(): void;
  91088. private _animatables;
  91089. private _betaIsAnimating;
  91090. private _betaTransition;
  91091. private _radiusTransition;
  91092. private _vectorTransition;
  91093. /**
  91094. * Targets the given mesh and updates zoom level accordingly.
  91095. * @param mesh The mesh to target.
  91096. * @param radius Optional. If a cached radius position already exists, overrides default.
  91097. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91098. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91099. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91100. */
  91101. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91102. /**
  91103. * Targets the given mesh with its children and updates zoom level accordingly.
  91104. * @param mesh The mesh to target.
  91105. * @param radius Optional. If a cached radius position already exists, overrides default.
  91106. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91107. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91108. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91109. */
  91110. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91111. /**
  91112. * Targets the given meshes with their children and updates zoom level accordingly.
  91113. * @param meshes The mesh to target.
  91114. * @param radius Optional. If a cached radius position already exists, overrides default.
  91115. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91116. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91117. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91118. */
  91119. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91120. /**
  91121. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  91122. * @param minimumWorld Determines the smaller position of the bounding box extend
  91123. * @param maximumWorld Determines the bigger position of the bounding box extend
  91124. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91125. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91126. */
  91127. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91128. /**
  91129. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  91130. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  91131. * frustum width.
  91132. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  91133. * to fully enclose the mesh in the viewing frustum.
  91134. */
  91135. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  91136. /**
  91137. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  91138. * is automatically returned to its default position (expected to be above ground plane).
  91139. */
  91140. private _maintainCameraAboveGround;
  91141. /**
  91142. * Returns the frustum slope based on the canvas ratio and camera FOV
  91143. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  91144. */
  91145. private _getFrustumSlope;
  91146. /**
  91147. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  91148. */
  91149. private _clearAnimationLocks;
  91150. /**
  91151. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91152. */
  91153. private _applyUserInteraction;
  91154. /**
  91155. * Stops and removes all animations that have been applied to the camera
  91156. */
  91157. stopAllAnimations(): void;
  91158. /**
  91159. * Gets a value indicating if the user is moving the camera
  91160. */
  91161. readonly isUserIsMoving: boolean;
  91162. /**
  91163. * The camera can move all the way towards the mesh.
  91164. */
  91165. static IgnoreBoundsSizeMode: number;
  91166. /**
  91167. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  91168. */
  91169. static FitFrustumSidesMode: number;
  91170. }
  91171. }
  91172. declare module BABYLON {
  91173. /**
  91174. * Base class for Camera Pointer Inputs.
  91175. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  91176. * for example usage.
  91177. */
  91178. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  91179. /**
  91180. * Defines the camera the input is attached to.
  91181. */
  91182. abstract camera: Camera;
  91183. /**
  91184. * Whether keyboard modifier keys are pressed at time of last mouse event.
  91185. */
  91186. protected _altKey: boolean;
  91187. protected _ctrlKey: boolean;
  91188. protected _metaKey: boolean;
  91189. protected _shiftKey: boolean;
  91190. /**
  91191. * Which mouse buttons were pressed at time of last mouse event.
  91192. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  91193. */
  91194. protected _buttonsPressed: number;
  91195. /**
  91196. * Defines the buttons associated with the input to handle camera move.
  91197. */
  91198. buttons: number[];
  91199. /**
  91200. * Attach the input controls to a specific dom element to get the input from.
  91201. * @param element Defines the element the controls should be listened from
  91202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91203. */
  91204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91205. /**
  91206. * Detach the current controls from the specified dom element.
  91207. * @param element Defines the element to stop listening the inputs from
  91208. */
  91209. detachControl(element: Nullable<HTMLElement>): void;
  91210. /**
  91211. * Gets the class name of the current input.
  91212. * @returns the class name
  91213. */
  91214. getClassName(): string;
  91215. /**
  91216. * Get the friendly name associated with the input class.
  91217. * @returns the input friendly name
  91218. */
  91219. getSimpleName(): string;
  91220. /**
  91221. * Called on pointer POINTERDOUBLETAP event.
  91222. * Override this method to provide functionality on POINTERDOUBLETAP event.
  91223. */
  91224. protected onDoubleTap(type: string): void;
  91225. /**
  91226. * Called on pointer POINTERMOVE event if only a single touch is active.
  91227. * Override this method to provide functionality.
  91228. */
  91229. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91230. /**
  91231. * Called on pointer POINTERMOVE event if multiple touches are active.
  91232. * Override this method to provide functionality.
  91233. */
  91234. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91235. /**
  91236. * Called on JS contextmenu event.
  91237. * Override this method to provide functionality.
  91238. */
  91239. protected onContextMenu(evt: PointerEvent): void;
  91240. /**
  91241. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91242. * press.
  91243. * Override this method to provide functionality.
  91244. */
  91245. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91246. /**
  91247. * Called each time a new POINTERUP event occurs. Ie, for each button
  91248. * release.
  91249. * Override this method to provide functionality.
  91250. */
  91251. protected onButtonUp(evt: PointerEvent): void;
  91252. /**
  91253. * Called when window becomes inactive.
  91254. * Override this method to provide functionality.
  91255. */
  91256. protected onLostFocus(): void;
  91257. private _pointerInput;
  91258. private _observer;
  91259. private _onLostFocus;
  91260. }
  91261. }
  91262. declare module BABYLON {
  91263. /**
  91264. * Manage the pointers inputs to control an arc rotate camera.
  91265. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91266. */
  91267. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  91268. /**
  91269. * Defines the camera the input is attached to.
  91270. */
  91271. camera: ArcRotateCamera;
  91272. /**
  91273. * Gets the class name of the current input.
  91274. * @returns the class name
  91275. */
  91276. getClassName(): string;
  91277. /**
  91278. * Defines the buttons associated with the input to handle camera move.
  91279. */
  91280. buttons: number[];
  91281. /**
  91282. * Defines the pointer angular sensibility along the X axis or how fast is
  91283. * the camera rotating.
  91284. */
  91285. angularSensibilityX: number;
  91286. /**
  91287. * Defines the pointer angular sensibility along the Y axis or how fast is
  91288. * the camera rotating.
  91289. */
  91290. angularSensibilityY: number;
  91291. /**
  91292. * Defines the pointer pinch precision or how fast is the camera zooming.
  91293. */
  91294. pinchPrecision: number;
  91295. /**
  91296. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  91297. * from 0.
  91298. * It defines the percentage of current camera.radius to use as delta when
  91299. * pinch zoom is used.
  91300. */
  91301. pinchDeltaPercentage: number;
  91302. /**
  91303. * Defines the pointer panning sensibility or how fast is the camera moving.
  91304. */
  91305. panningSensibility: number;
  91306. /**
  91307. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  91308. */
  91309. multiTouchPanning: boolean;
  91310. /**
  91311. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  91312. * zoom (pinch) through multitouch.
  91313. */
  91314. multiTouchPanAndZoom: boolean;
  91315. /**
  91316. * Revers pinch action direction.
  91317. */
  91318. pinchInwards: boolean;
  91319. private _isPanClick;
  91320. private _twoFingerActivityCount;
  91321. private _isPinching;
  91322. /**
  91323. * Called on pointer POINTERMOVE event if only a single touch is active.
  91324. */
  91325. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91326. /**
  91327. * Called on pointer POINTERDOUBLETAP event.
  91328. */
  91329. protected onDoubleTap(type: string): void;
  91330. /**
  91331. * Called on pointer POINTERMOVE event if multiple touches are active.
  91332. */
  91333. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91334. /**
  91335. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91336. * press.
  91337. */
  91338. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91339. /**
  91340. * Called each time a new POINTERUP event occurs. Ie, for each button
  91341. * release.
  91342. */
  91343. protected onButtonUp(evt: PointerEvent): void;
  91344. /**
  91345. * Called when window becomes inactive.
  91346. */
  91347. protected onLostFocus(): void;
  91348. }
  91349. }
  91350. declare module BABYLON {
  91351. /**
  91352. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  91353. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91354. */
  91355. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  91356. /**
  91357. * Defines the camera the input is attached to.
  91358. */
  91359. camera: ArcRotateCamera;
  91360. /**
  91361. * Defines the list of key codes associated with the up action (increase alpha)
  91362. */
  91363. keysUp: number[];
  91364. /**
  91365. * Defines the list of key codes associated with the down action (decrease alpha)
  91366. */
  91367. keysDown: number[];
  91368. /**
  91369. * Defines the list of key codes associated with the left action (increase beta)
  91370. */
  91371. keysLeft: number[];
  91372. /**
  91373. * Defines the list of key codes associated with the right action (decrease beta)
  91374. */
  91375. keysRight: number[];
  91376. /**
  91377. * Defines the list of key codes associated with the reset action.
  91378. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  91379. */
  91380. keysReset: number[];
  91381. /**
  91382. * Defines the panning sensibility of the inputs.
  91383. * (How fast is the camera paning)
  91384. */
  91385. panningSensibility: number;
  91386. /**
  91387. * Defines the zooming sensibility of the inputs.
  91388. * (How fast is the camera zooming)
  91389. */
  91390. zoomingSensibility: number;
  91391. /**
  91392. * Defines wether maintaining the alt key down switch the movement mode from
  91393. * orientation to zoom.
  91394. */
  91395. useAltToZoom: boolean;
  91396. /**
  91397. * Rotation speed of the camera
  91398. */
  91399. angularSpeed: number;
  91400. private _keys;
  91401. private _ctrlPressed;
  91402. private _altPressed;
  91403. private _onCanvasBlurObserver;
  91404. private _onKeyboardObserver;
  91405. private _engine;
  91406. private _scene;
  91407. /**
  91408. * Attach the input controls to a specific dom element to get the input from.
  91409. * @param element Defines the element the controls should be listened from
  91410. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91411. */
  91412. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91413. /**
  91414. * Detach the current controls from the specified dom element.
  91415. * @param element Defines the element to stop listening the inputs from
  91416. */
  91417. detachControl(element: Nullable<HTMLElement>): void;
  91418. /**
  91419. * Update the current camera state depending on the inputs that have been used this frame.
  91420. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91421. */
  91422. checkInputs(): void;
  91423. /**
  91424. * Gets the class name of the current intput.
  91425. * @returns the class name
  91426. */
  91427. getClassName(): string;
  91428. /**
  91429. * Get the friendly name associated with the input class.
  91430. * @returns the input friendly name
  91431. */
  91432. getSimpleName(): string;
  91433. }
  91434. }
  91435. declare module BABYLON {
  91436. /**
  91437. * Manage the mouse wheel inputs to control an arc rotate camera.
  91438. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91439. */
  91440. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  91441. /**
  91442. * Defines the camera the input is attached to.
  91443. */
  91444. camera: ArcRotateCamera;
  91445. /**
  91446. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91447. */
  91448. wheelPrecision: number;
  91449. /**
  91450. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  91451. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  91452. */
  91453. wheelDeltaPercentage: number;
  91454. private _wheel;
  91455. private _observer;
  91456. /**
  91457. * Attach the input controls to a specific dom element to get the input from.
  91458. * @param element Defines the element the controls should be listened from
  91459. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91460. */
  91461. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91462. /**
  91463. * Detach the current controls from the specified dom element.
  91464. * @param element Defines the element to stop listening the inputs from
  91465. */
  91466. detachControl(element: Nullable<HTMLElement>): void;
  91467. /**
  91468. * Gets the class name of the current intput.
  91469. * @returns the class name
  91470. */
  91471. getClassName(): string;
  91472. /**
  91473. * Get the friendly name associated with the input class.
  91474. * @returns the input friendly name
  91475. */
  91476. getSimpleName(): string;
  91477. }
  91478. }
  91479. declare module BABYLON {
  91480. /**
  91481. * Default Inputs manager for the ArcRotateCamera.
  91482. * It groups all the default supported inputs for ease of use.
  91483. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91484. */
  91485. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  91486. /**
  91487. * Instantiates a new ArcRotateCameraInputsManager.
  91488. * @param camera Defines the camera the inputs belong to
  91489. */
  91490. constructor(camera: ArcRotateCamera);
  91491. /**
  91492. * Add mouse wheel input support to the input manager.
  91493. * @returns the current input manager
  91494. */
  91495. addMouseWheel(): ArcRotateCameraInputsManager;
  91496. /**
  91497. * Add pointers input support to the input manager.
  91498. * @returns the current input manager
  91499. */
  91500. addPointers(): ArcRotateCameraInputsManager;
  91501. /**
  91502. * Add keyboard input support to the input manager.
  91503. * @returns the current input manager
  91504. */
  91505. addKeyboard(): ArcRotateCameraInputsManager;
  91506. }
  91507. }
  91508. declare module BABYLON {
  91509. /**
  91510. * This represents an orbital type of camera.
  91511. *
  91512. * 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.
  91513. * 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.
  91514. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  91515. */
  91516. export class ArcRotateCamera extends TargetCamera {
  91517. /**
  91518. * Defines the rotation angle of the camera along the longitudinal axis.
  91519. */
  91520. alpha: number;
  91521. /**
  91522. * Defines the rotation angle of the camera along the latitudinal axis.
  91523. */
  91524. beta: number;
  91525. /**
  91526. * Defines the radius of the camera from it s target point.
  91527. */
  91528. radius: number;
  91529. protected _target: Vector3;
  91530. protected _targetHost: Nullable<AbstractMesh>;
  91531. /**
  91532. * Defines the target point of the camera.
  91533. * The camera looks towards it form the radius distance.
  91534. */
  91535. target: Vector3;
  91536. /**
  91537. * Define the current local position of the camera in the scene
  91538. */
  91539. position: Vector3;
  91540. /**
  91541. * Current inertia value on the longitudinal axis.
  91542. * The bigger this number the longer it will take for the camera to stop.
  91543. */
  91544. inertialAlphaOffset: number;
  91545. /**
  91546. * Current inertia value on the latitudinal axis.
  91547. * The bigger this number the longer it will take for the camera to stop.
  91548. */
  91549. inertialBetaOffset: number;
  91550. /**
  91551. * Current inertia value on the radius axis.
  91552. * The bigger this number the longer it will take for the camera to stop.
  91553. */
  91554. inertialRadiusOffset: number;
  91555. /**
  91556. * Minimum allowed angle on the longitudinal axis.
  91557. * This can help limiting how the Camera is able to move in the scene.
  91558. */
  91559. lowerAlphaLimit: Nullable<number>;
  91560. /**
  91561. * Maximum allowed angle on the longitudinal axis.
  91562. * This can help limiting how the Camera is able to move in the scene.
  91563. */
  91564. upperAlphaLimit: Nullable<number>;
  91565. /**
  91566. * Minimum allowed angle on the latitudinal axis.
  91567. * This can help limiting how the Camera is able to move in the scene.
  91568. */
  91569. lowerBetaLimit: number;
  91570. /**
  91571. * Maximum allowed angle on the latitudinal axis.
  91572. * This can help limiting how the Camera is able to move in the scene.
  91573. */
  91574. upperBetaLimit: number;
  91575. /**
  91576. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  91577. * This can help limiting how the Camera is able to move in the scene.
  91578. */
  91579. lowerRadiusLimit: Nullable<number>;
  91580. /**
  91581. * Maximum allowed distance of the camera to the target (The camera can not get further).
  91582. * This can help limiting how the Camera is able to move in the scene.
  91583. */
  91584. upperRadiusLimit: Nullable<number>;
  91585. /**
  91586. * Defines the current inertia value used during panning of the camera along the X axis.
  91587. */
  91588. inertialPanningX: number;
  91589. /**
  91590. * Defines the current inertia value used during panning of the camera along the Y axis.
  91591. */
  91592. inertialPanningY: number;
  91593. /**
  91594. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  91595. * Basically if your fingers moves away from more than this distance you will be considered
  91596. * in pinch mode.
  91597. */
  91598. pinchToPanMaxDistance: number;
  91599. /**
  91600. * Defines the maximum distance the camera can pan.
  91601. * This could help keeping the cammera always in your scene.
  91602. */
  91603. panningDistanceLimit: Nullable<number>;
  91604. /**
  91605. * Defines the target of the camera before paning.
  91606. */
  91607. panningOriginTarget: Vector3;
  91608. /**
  91609. * Defines the value of the inertia used during panning.
  91610. * 0 would mean stop inertia and one would mean no decelleration at all.
  91611. */
  91612. panningInertia: number;
  91613. /**
  91614. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  91615. */
  91616. angularSensibilityX: number;
  91617. /**
  91618. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  91619. */
  91620. angularSensibilityY: number;
  91621. /**
  91622. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  91623. */
  91624. pinchPrecision: number;
  91625. /**
  91626. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  91627. * It will be used instead of pinchDeltaPrecision if different from 0.
  91628. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91629. */
  91630. pinchDeltaPercentage: number;
  91631. /**
  91632. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  91633. */
  91634. panningSensibility: number;
  91635. /**
  91636. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  91637. */
  91638. keysUp: number[];
  91639. /**
  91640. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  91641. */
  91642. keysDown: number[];
  91643. /**
  91644. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  91645. */
  91646. keysLeft: number[];
  91647. /**
  91648. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  91649. */
  91650. keysRight: number[];
  91651. /**
  91652. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91653. */
  91654. wheelPrecision: number;
  91655. /**
  91656. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  91657. * It will be used instead of pinchDeltaPrecision if different from 0.
  91658. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91659. */
  91660. wheelDeltaPercentage: number;
  91661. /**
  91662. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  91663. */
  91664. zoomOnFactor: number;
  91665. /**
  91666. * Defines a screen offset for the camera position.
  91667. */
  91668. targetScreenOffset: Vector2;
  91669. /**
  91670. * Allows the camera to be completely reversed.
  91671. * If false the camera can not arrive upside down.
  91672. */
  91673. allowUpsideDown: boolean;
  91674. /**
  91675. * Define if double tap/click is used to restore the previously saved state of the camera.
  91676. */
  91677. useInputToRestoreState: boolean;
  91678. /** @hidden */
  91679. _viewMatrix: Matrix;
  91680. /** @hidden */
  91681. _useCtrlForPanning: boolean;
  91682. /** @hidden */
  91683. _panningMouseButton: number;
  91684. /**
  91685. * Defines the input associated to the camera.
  91686. */
  91687. inputs: ArcRotateCameraInputsManager;
  91688. /** @hidden */
  91689. _reset: () => void;
  91690. /**
  91691. * Defines the allowed panning axis.
  91692. */
  91693. panningAxis: Vector3;
  91694. protected _localDirection: Vector3;
  91695. protected _transformedDirection: Vector3;
  91696. private _bouncingBehavior;
  91697. /**
  91698. * Gets the bouncing behavior of the camera if it has been enabled.
  91699. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91700. */
  91701. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  91702. /**
  91703. * Defines if the bouncing behavior of the camera is enabled on the camera.
  91704. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91705. */
  91706. useBouncingBehavior: boolean;
  91707. private _framingBehavior;
  91708. /**
  91709. * Gets the framing behavior of the camera if it has been enabled.
  91710. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91711. */
  91712. readonly framingBehavior: Nullable<FramingBehavior>;
  91713. /**
  91714. * Defines if the framing behavior of the camera is enabled on the camera.
  91715. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91716. */
  91717. useFramingBehavior: boolean;
  91718. private _autoRotationBehavior;
  91719. /**
  91720. * Gets the auto rotation behavior of the camera if it has been enabled.
  91721. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91722. */
  91723. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  91724. /**
  91725. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  91726. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91727. */
  91728. useAutoRotationBehavior: boolean;
  91729. /**
  91730. * Observable triggered when the mesh target has been changed on the camera.
  91731. */
  91732. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  91733. /**
  91734. * Event raised when the camera is colliding with a mesh.
  91735. */
  91736. onCollide: (collidedMesh: AbstractMesh) => void;
  91737. /**
  91738. * Defines whether the camera should check collision with the objects oh the scene.
  91739. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  91740. */
  91741. checkCollisions: boolean;
  91742. /**
  91743. * Defines the collision radius of the camera.
  91744. * This simulates a sphere around the camera.
  91745. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91746. */
  91747. collisionRadius: Vector3;
  91748. protected _collider: Collider;
  91749. protected _previousPosition: Vector3;
  91750. protected _collisionVelocity: Vector3;
  91751. protected _newPosition: Vector3;
  91752. protected _previousAlpha: number;
  91753. protected _previousBeta: number;
  91754. protected _previousRadius: number;
  91755. protected _collisionTriggered: boolean;
  91756. protected _targetBoundingCenter: Nullable<Vector3>;
  91757. private _computationVector;
  91758. private _tempAxisVector;
  91759. private _tempAxisRotationMatrix;
  91760. /**
  91761. * Instantiates a new ArcRotateCamera in a given scene
  91762. * @param name Defines the name of the camera
  91763. * @param alpha Defines the camera rotation along the logitudinal axis
  91764. * @param beta Defines the camera rotation along the latitudinal axis
  91765. * @param radius Defines the camera distance from its target
  91766. * @param target Defines the camera target
  91767. * @param scene Defines the scene the camera belongs to
  91768. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91769. */
  91770. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91771. /** @hidden */
  91772. _initCache(): void;
  91773. /** @hidden */
  91774. _updateCache(ignoreParentClass?: boolean): void;
  91775. protected _getTargetPosition(): Vector3;
  91776. private _storedAlpha;
  91777. private _storedBeta;
  91778. private _storedRadius;
  91779. private _storedTarget;
  91780. /**
  91781. * Stores the current state of the camera (alpha, beta, radius and target)
  91782. * @returns the camera itself
  91783. */
  91784. storeState(): Camera;
  91785. /**
  91786. * @hidden
  91787. * Restored camera state. You must call storeState() first
  91788. */
  91789. _restoreStateValues(): boolean;
  91790. /** @hidden */
  91791. _isSynchronizedViewMatrix(): boolean;
  91792. /**
  91793. * Attached controls to the current camera.
  91794. * @param element Defines the element the controls should be listened from
  91795. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91796. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  91797. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  91798. */
  91799. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  91800. /**
  91801. * Detach the current controls from the camera.
  91802. * The camera will stop reacting to inputs.
  91803. * @param element Defines the element to stop listening the inputs from
  91804. */
  91805. detachControl(element: HTMLElement): void;
  91806. /** @hidden */
  91807. _checkInputs(): void;
  91808. protected _checkLimits(): void;
  91809. /**
  91810. * Rebuilds angles (alpha, beta) and radius from the give position and target
  91811. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  91812. */
  91813. rebuildAnglesAndRadius(updateView?: boolean): void;
  91814. /**
  91815. * Use a position to define the current camera related information like aplha, beta and radius
  91816. * @param position Defines the position to set the camera at
  91817. */
  91818. setPosition(position: Vector3): void;
  91819. /**
  91820. * Defines the target the camera should look at.
  91821. * This will automatically adapt alpha beta and radius to fit within the new target.
  91822. * @param target Defines the new target as a Vector or a mesh
  91823. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  91824. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  91825. */
  91826. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  91827. /** @hidden */
  91828. _getViewMatrix(): Matrix;
  91829. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  91830. /**
  91831. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  91832. * @param meshes Defines the mesh to zoom on
  91833. * @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)
  91834. */
  91835. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  91836. /**
  91837. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  91838. * The target will be changed but the radius
  91839. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  91840. * @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)
  91841. */
  91842. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  91843. min: Vector3;
  91844. max: Vector3;
  91845. distance: number;
  91846. }, doNotUpdateMaxZ?: boolean): void;
  91847. /**
  91848. * @override
  91849. * Override Camera.createRigCamera
  91850. */
  91851. createRigCamera(name: string, cameraIndex: number): Camera;
  91852. /**
  91853. * @hidden
  91854. * @override
  91855. * Override Camera._updateRigCameras
  91856. */
  91857. _updateRigCameras(): void;
  91858. /**
  91859. * Destroy the camera and release the current resources hold by it.
  91860. */
  91861. dispose(): void;
  91862. /**
  91863. * Gets the current object class name.
  91864. * @return the class name
  91865. */
  91866. getClassName(): string;
  91867. }
  91868. }
  91869. declare module BABYLON {
  91870. /**
  91871. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  91872. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91873. */
  91874. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  91875. /**
  91876. * Gets the name of the behavior.
  91877. */
  91878. readonly name: string;
  91879. private _zoomStopsAnimation;
  91880. private _idleRotationSpeed;
  91881. private _idleRotationWaitTime;
  91882. private _idleRotationSpinupTime;
  91883. /**
  91884. * Sets the flag that indicates if user zooming should stop animation.
  91885. */
  91886. /**
  91887. * Gets the flag that indicates if user zooming should stop animation.
  91888. */
  91889. zoomStopsAnimation: boolean;
  91890. /**
  91891. * Sets the default speed at which the camera rotates around the model.
  91892. */
  91893. /**
  91894. * Gets the default speed at which the camera rotates around the model.
  91895. */
  91896. idleRotationSpeed: number;
  91897. /**
  91898. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  91899. */
  91900. /**
  91901. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  91902. */
  91903. idleRotationWaitTime: number;
  91904. /**
  91905. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  91906. */
  91907. /**
  91908. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  91909. */
  91910. idleRotationSpinupTime: number;
  91911. /**
  91912. * Gets a value indicating if the camera is currently rotating because of this behavior
  91913. */
  91914. readonly rotationInProgress: boolean;
  91915. private _onPrePointerObservableObserver;
  91916. private _onAfterCheckInputsObserver;
  91917. private _attachedCamera;
  91918. private _isPointerDown;
  91919. private _lastFrameTime;
  91920. private _lastInteractionTime;
  91921. private _cameraRotationSpeed;
  91922. /**
  91923. * Initializes the behavior.
  91924. */
  91925. init(): void;
  91926. /**
  91927. * Attaches the behavior to its arc rotate camera.
  91928. * @param camera Defines the camera to attach the behavior to
  91929. */
  91930. attach(camera: ArcRotateCamera): void;
  91931. /**
  91932. * Detaches the behavior from its current arc rotate camera.
  91933. */
  91934. detach(): void;
  91935. /**
  91936. * Returns true if user is scrolling.
  91937. * @return true if user is scrolling.
  91938. */
  91939. private _userIsZooming;
  91940. private _lastFrameRadius;
  91941. private _shouldAnimationStopForInteraction;
  91942. /**
  91943. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91944. */
  91945. private _applyUserInteraction;
  91946. private _userIsMoving;
  91947. }
  91948. }
  91949. declare module BABYLON {
  91950. /**
  91951. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  91952. */
  91953. export class AttachToBoxBehavior implements Behavior<Mesh> {
  91954. private ui;
  91955. /**
  91956. * The name of the behavior
  91957. */
  91958. name: string;
  91959. /**
  91960. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  91961. */
  91962. distanceAwayFromFace: number;
  91963. /**
  91964. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  91965. */
  91966. distanceAwayFromBottomOfFace: number;
  91967. private _faceVectors;
  91968. private _target;
  91969. private _scene;
  91970. private _onRenderObserver;
  91971. private _tmpMatrix;
  91972. private _tmpVector;
  91973. /**
  91974. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  91975. * @param ui The transform node that should be attched to the mesh
  91976. */
  91977. constructor(ui: TransformNode);
  91978. /**
  91979. * Initializes the behavior
  91980. */
  91981. init(): void;
  91982. private _closestFace;
  91983. private _zeroVector;
  91984. private _lookAtTmpMatrix;
  91985. private _lookAtToRef;
  91986. /**
  91987. * Attaches the AttachToBoxBehavior to the passed in mesh
  91988. * @param target The mesh that the specified node will be attached to
  91989. */
  91990. attach(target: Mesh): void;
  91991. /**
  91992. * Detaches the behavior from the mesh
  91993. */
  91994. detach(): void;
  91995. }
  91996. }
  91997. declare module BABYLON {
  91998. /**
  91999. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  92000. */
  92001. export class FadeInOutBehavior implements Behavior<Mesh> {
  92002. /**
  92003. * Time in milliseconds to delay before fading in (Default: 0)
  92004. */
  92005. delay: number;
  92006. /**
  92007. * Time in milliseconds for the mesh to fade in (Default: 300)
  92008. */
  92009. fadeInTime: number;
  92010. private _millisecondsPerFrame;
  92011. private _hovered;
  92012. private _hoverValue;
  92013. private _ownerNode;
  92014. /**
  92015. * Instatiates the FadeInOutBehavior
  92016. */
  92017. constructor();
  92018. /**
  92019. * The name of the behavior
  92020. */
  92021. readonly name: string;
  92022. /**
  92023. * Initializes the behavior
  92024. */
  92025. init(): void;
  92026. /**
  92027. * Attaches the fade behavior on the passed in mesh
  92028. * @param ownerNode The mesh that will be faded in/out once attached
  92029. */
  92030. attach(ownerNode: Mesh): void;
  92031. /**
  92032. * Detaches the behavior from the mesh
  92033. */
  92034. detach(): void;
  92035. /**
  92036. * Triggers the mesh to begin fading in or out
  92037. * @param value if the object should fade in or out (true to fade in)
  92038. */
  92039. fadeIn(value: boolean): void;
  92040. private _update;
  92041. private _setAllVisibility;
  92042. }
  92043. }
  92044. declare module BABYLON {
  92045. /**
  92046. * Class containing a set of static utilities functions for managing Pivots
  92047. * @hidden
  92048. */
  92049. export class PivotTools {
  92050. private static _PivotCached;
  92051. private static _OldPivotPoint;
  92052. private static _PivotTranslation;
  92053. private static _PivotTmpVector;
  92054. /** @hidden */
  92055. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  92056. /** @hidden */
  92057. static _RestorePivotPoint(mesh: AbstractMesh): void;
  92058. }
  92059. }
  92060. declare module BABYLON {
  92061. /**
  92062. * Class containing static functions to help procedurally build meshes
  92063. */
  92064. export class PlaneBuilder {
  92065. /**
  92066. * Creates a plane mesh
  92067. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  92068. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  92069. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  92070. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92071. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92073. * @param name defines the name of the mesh
  92074. * @param options defines the options used to create the mesh
  92075. * @param scene defines the hosting scene
  92076. * @returns the plane mesh
  92077. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  92078. */
  92079. static CreatePlane(name: string, options: {
  92080. size?: number;
  92081. width?: number;
  92082. height?: number;
  92083. sideOrientation?: number;
  92084. frontUVs?: Vector4;
  92085. backUVs?: Vector4;
  92086. updatable?: boolean;
  92087. sourcePlane?: Plane;
  92088. }, scene: Scene): Mesh;
  92089. }
  92090. }
  92091. declare module BABYLON {
  92092. /**
  92093. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  92094. */
  92095. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  92096. private static _AnyMouseID;
  92097. private _attachedNode;
  92098. private _dragPlane;
  92099. private _scene;
  92100. private _pointerObserver;
  92101. private _beforeRenderObserver;
  92102. private static _planeScene;
  92103. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  92104. /**
  92105. * 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)
  92106. */
  92107. maxDragAngle: number;
  92108. /**
  92109. * @hidden
  92110. */
  92111. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  92112. /**
  92113. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92114. */
  92115. currentDraggingPointerID: number;
  92116. /**
  92117. * The last position where the pointer hit the drag plane in world space
  92118. */
  92119. lastDragPosition: Vector3;
  92120. /**
  92121. * If the behavior is currently in a dragging state
  92122. */
  92123. dragging: boolean;
  92124. /**
  92125. * 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)
  92126. */
  92127. dragDeltaRatio: number;
  92128. /**
  92129. * If the drag plane orientation should be updated during the dragging (Default: true)
  92130. */
  92131. updateDragPlane: boolean;
  92132. private _debugMode;
  92133. private _moving;
  92134. /**
  92135. * Fires each time the attached mesh is dragged with the pointer
  92136. * * delta between last drag position and current drag position in world space
  92137. * * dragDistance along the drag axis
  92138. * * dragPlaneNormal normal of the current drag plane used during the drag
  92139. * * dragPlanePoint in world space where the drag intersects the drag plane
  92140. */
  92141. onDragObservable: Observable<{
  92142. delta: Vector3;
  92143. dragPlanePoint: Vector3;
  92144. dragPlaneNormal: Vector3;
  92145. dragDistance: number;
  92146. pointerId: number;
  92147. }>;
  92148. /**
  92149. * Fires each time a drag begins (eg. mouse down on mesh)
  92150. */
  92151. onDragStartObservable: Observable<{
  92152. dragPlanePoint: Vector3;
  92153. pointerId: number;
  92154. }>;
  92155. /**
  92156. * Fires each time a drag ends (eg. mouse release after drag)
  92157. */
  92158. onDragEndObservable: Observable<{
  92159. dragPlanePoint: Vector3;
  92160. pointerId: number;
  92161. }>;
  92162. /**
  92163. * If the attached mesh should be moved when dragged
  92164. */
  92165. moveAttached: boolean;
  92166. /**
  92167. * If the drag behavior will react to drag events (Default: true)
  92168. */
  92169. enabled: boolean;
  92170. /**
  92171. * If camera controls should be detached during the drag
  92172. */
  92173. detachCameraControls: boolean;
  92174. /**
  92175. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  92176. */
  92177. useObjectOrienationForDragging: boolean;
  92178. private _options;
  92179. /**
  92180. * Creates a pointer drag behavior that can be attached to a mesh
  92181. * @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)
  92182. */
  92183. constructor(options?: {
  92184. dragAxis?: Vector3;
  92185. dragPlaneNormal?: Vector3;
  92186. });
  92187. /**
  92188. * Predicate to determine if it is valid to move the object to a new position when it is moved
  92189. */
  92190. validateDrag: (targetPosition: Vector3) => boolean;
  92191. /**
  92192. * The name of the behavior
  92193. */
  92194. readonly name: string;
  92195. /**
  92196. * Initializes the behavior
  92197. */
  92198. init(): void;
  92199. private _tmpVector;
  92200. private _alternatePickedPoint;
  92201. private _worldDragAxis;
  92202. private _targetPosition;
  92203. private _attachedElement;
  92204. /**
  92205. * Attaches the drag behavior the passed in mesh
  92206. * @param ownerNode The mesh that will be dragged around once attached
  92207. */
  92208. attach(ownerNode: AbstractMesh): void;
  92209. /**
  92210. * Force relase the drag action by code.
  92211. */
  92212. releaseDrag(): void;
  92213. private _startDragRay;
  92214. private _lastPointerRay;
  92215. /**
  92216. * Simulates the start of a pointer drag event on the behavior
  92217. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  92218. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  92219. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  92220. */
  92221. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  92222. private _startDrag;
  92223. private _dragDelta;
  92224. private _moveDrag;
  92225. private _pickWithRayOnDragPlane;
  92226. private _pointA;
  92227. private _pointB;
  92228. private _pointC;
  92229. private _lineA;
  92230. private _lineB;
  92231. private _localAxis;
  92232. private _lookAt;
  92233. private _updateDragPlanePosition;
  92234. /**
  92235. * Detaches the behavior from the mesh
  92236. */
  92237. detach(): void;
  92238. }
  92239. }
  92240. declare module BABYLON {
  92241. /**
  92242. * A behavior that when attached to a mesh will allow the mesh to be scaled
  92243. */
  92244. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  92245. private _dragBehaviorA;
  92246. private _dragBehaviorB;
  92247. private _startDistance;
  92248. private _initialScale;
  92249. private _targetScale;
  92250. private _ownerNode;
  92251. private _sceneRenderObserver;
  92252. /**
  92253. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  92254. */
  92255. constructor();
  92256. /**
  92257. * The name of the behavior
  92258. */
  92259. readonly name: string;
  92260. /**
  92261. * Initializes the behavior
  92262. */
  92263. init(): void;
  92264. private _getCurrentDistance;
  92265. /**
  92266. * Attaches the scale behavior the passed in mesh
  92267. * @param ownerNode The mesh that will be scaled around once attached
  92268. */
  92269. attach(ownerNode: Mesh): void;
  92270. /**
  92271. * Detaches the behavior from the mesh
  92272. */
  92273. detach(): void;
  92274. }
  92275. }
  92276. declare module BABYLON {
  92277. /**
  92278. * 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
  92279. */
  92280. export class SixDofDragBehavior implements Behavior<Mesh> {
  92281. private static _virtualScene;
  92282. private _ownerNode;
  92283. private _sceneRenderObserver;
  92284. private _scene;
  92285. private _targetPosition;
  92286. private _virtualOriginMesh;
  92287. private _virtualDragMesh;
  92288. private _pointerObserver;
  92289. private _moving;
  92290. private _startingOrientation;
  92291. /**
  92292. * 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)
  92293. */
  92294. private zDragFactor;
  92295. /**
  92296. * If the object should rotate to face the drag origin
  92297. */
  92298. rotateDraggedObject: boolean;
  92299. /**
  92300. * If the behavior is currently in a dragging state
  92301. */
  92302. dragging: boolean;
  92303. /**
  92304. * 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)
  92305. */
  92306. dragDeltaRatio: number;
  92307. /**
  92308. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92309. */
  92310. currentDraggingPointerID: number;
  92311. /**
  92312. * If camera controls should be detached during the drag
  92313. */
  92314. detachCameraControls: boolean;
  92315. /**
  92316. * Fires each time a drag starts
  92317. */
  92318. onDragStartObservable: Observable<{}>;
  92319. /**
  92320. * Fires each time a drag ends (eg. mouse release after drag)
  92321. */
  92322. onDragEndObservable: Observable<{}>;
  92323. /**
  92324. * 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
  92325. */
  92326. constructor();
  92327. /**
  92328. * The name of the behavior
  92329. */
  92330. readonly name: string;
  92331. /**
  92332. * Initializes the behavior
  92333. */
  92334. init(): void;
  92335. /**
  92336. * Attaches the scale behavior the passed in mesh
  92337. * @param ownerNode The mesh that will be scaled around once attached
  92338. */
  92339. attach(ownerNode: Mesh): void;
  92340. /**
  92341. * Detaches the behavior from the mesh
  92342. */
  92343. detach(): void;
  92344. }
  92345. }
  92346. declare module BABYLON {
  92347. /**
  92348. * Class used to apply inverse kinematics to bones
  92349. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  92350. */
  92351. export class BoneIKController {
  92352. private static _tmpVecs;
  92353. private static _tmpQuat;
  92354. private static _tmpMats;
  92355. /**
  92356. * Gets or sets the target mesh
  92357. */
  92358. targetMesh: AbstractMesh;
  92359. /** Gets or sets the mesh used as pole */
  92360. poleTargetMesh: AbstractMesh;
  92361. /**
  92362. * Gets or sets the bone used as pole
  92363. */
  92364. poleTargetBone: Nullable<Bone>;
  92365. /**
  92366. * Gets or sets the target position
  92367. */
  92368. targetPosition: Vector3;
  92369. /**
  92370. * Gets or sets the pole target position
  92371. */
  92372. poleTargetPosition: Vector3;
  92373. /**
  92374. * Gets or sets the pole target local offset
  92375. */
  92376. poleTargetLocalOffset: Vector3;
  92377. /**
  92378. * Gets or sets the pole angle
  92379. */
  92380. poleAngle: number;
  92381. /**
  92382. * Gets or sets the mesh associated with the controller
  92383. */
  92384. mesh: AbstractMesh;
  92385. /**
  92386. * 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)
  92387. */
  92388. slerpAmount: number;
  92389. private _bone1Quat;
  92390. private _bone1Mat;
  92391. private _bone2Ang;
  92392. private _bone1;
  92393. private _bone2;
  92394. private _bone1Length;
  92395. private _bone2Length;
  92396. private _maxAngle;
  92397. private _maxReach;
  92398. private _rightHandedSystem;
  92399. private _bendAxis;
  92400. private _slerping;
  92401. private _adjustRoll;
  92402. /**
  92403. * Gets or sets maximum allowed angle
  92404. */
  92405. maxAngle: number;
  92406. /**
  92407. * Creates a new BoneIKController
  92408. * @param mesh defines the mesh to control
  92409. * @param bone defines the bone to control
  92410. * @param options defines options to set up the controller
  92411. */
  92412. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  92413. targetMesh?: AbstractMesh;
  92414. poleTargetMesh?: AbstractMesh;
  92415. poleTargetBone?: Bone;
  92416. poleTargetLocalOffset?: Vector3;
  92417. poleAngle?: number;
  92418. bendAxis?: Vector3;
  92419. maxAngle?: number;
  92420. slerpAmount?: number;
  92421. });
  92422. private _setMaxAngle;
  92423. /**
  92424. * Force the controller to update the bones
  92425. */
  92426. update(): void;
  92427. }
  92428. }
  92429. declare module BABYLON {
  92430. /**
  92431. * Class used to make a bone look toward a point in space
  92432. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  92433. */
  92434. export class BoneLookController {
  92435. private static _tmpVecs;
  92436. private static _tmpQuat;
  92437. private static _tmpMats;
  92438. /**
  92439. * The target Vector3 that the bone will look at
  92440. */
  92441. target: Vector3;
  92442. /**
  92443. * The mesh that the bone is attached to
  92444. */
  92445. mesh: AbstractMesh;
  92446. /**
  92447. * The bone that will be looking to the target
  92448. */
  92449. bone: Bone;
  92450. /**
  92451. * The up axis of the coordinate system that is used when the bone is rotated
  92452. */
  92453. upAxis: Vector3;
  92454. /**
  92455. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  92456. */
  92457. upAxisSpace: Space;
  92458. /**
  92459. * Used to make an adjustment to the yaw of the bone
  92460. */
  92461. adjustYaw: number;
  92462. /**
  92463. * Used to make an adjustment to the pitch of the bone
  92464. */
  92465. adjustPitch: number;
  92466. /**
  92467. * Used to make an adjustment to the roll of the bone
  92468. */
  92469. adjustRoll: number;
  92470. /**
  92471. * 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)
  92472. */
  92473. slerpAmount: number;
  92474. private _minYaw;
  92475. private _maxYaw;
  92476. private _minPitch;
  92477. private _maxPitch;
  92478. private _minYawSin;
  92479. private _minYawCos;
  92480. private _maxYawSin;
  92481. private _maxYawCos;
  92482. private _midYawConstraint;
  92483. private _minPitchTan;
  92484. private _maxPitchTan;
  92485. private _boneQuat;
  92486. private _slerping;
  92487. private _transformYawPitch;
  92488. private _transformYawPitchInv;
  92489. private _firstFrameSkipped;
  92490. private _yawRange;
  92491. private _fowardAxis;
  92492. /**
  92493. * Gets or sets the minimum yaw angle that the bone can look to
  92494. */
  92495. minYaw: number;
  92496. /**
  92497. * Gets or sets the maximum yaw angle that the bone can look to
  92498. */
  92499. maxYaw: number;
  92500. /**
  92501. * Gets or sets the minimum pitch angle that the bone can look to
  92502. */
  92503. minPitch: number;
  92504. /**
  92505. * Gets or sets the maximum pitch angle that the bone can look to
  92506. */
  92507. maxPitch: number;
  92508. /**
  92509. * Create a BoneLookController
  92510. * @param mesh the mesh that the bone belongs to
  92511. * @param bone the bone that will be looking to the target
  92512. * @param target the target Vector3 to look at
  92513. * @param options optional settings:
  92514. * * maxYaw: the maximum angle the bone will yaw to
  92515. * * minYaw: the minimum angle the bone will yaw to
  92516. * * maxPitch: the maximum angle the bone will pitch to
  92517. * * minPitch: the minimum angle the bone will yaw to
  92518. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  92519. * * upAxis: the up axis of the coordinate system
  92520. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  92521. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  92522. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  92523. * * adjustYaw: used to make an adjustment to the yaw of the bone
  92524. * * adjustPitch: used to make an adjustment to the pitch of the bone
  92525. * * adjustRoll: used to make an adjustment to the roll of the bone
  92526. **/
  92527. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  92528. maxYaw?: number;
  92529. minYaw?: number;
  92530. maxPitch?: number;
  92531. minPitch?: number;
  92532. slerpAmount?: number;
  92533. upAxis?: Vector3;
  92534. upAxisSpace?: Space;
  92535. yawAxis?: Vector3;
  92536. pitchAxis?: Vector3;
  92537. adjustYaw?: number;
  92538. adjustPitch?: number;
  92539. adjustRoll?: number;
  92540. });
  92541. /**
  92542. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  92543. */
  92544. update(): void;
  92545. private _getAngleDiff;
  92546. private _getAngleBetween;
  92547. private _isAngleBetween;
  92548. }
  92549. }
  92550. declare module BABYLON {
  92551. /**
  92552. * Manage the gamepad inputs to control an arc rotate camera.
  92553. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92554. */
  92555. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  92556. /**
  92557. * Defines the camera the input is attached to.
  92558. */
  92559. camera: ArcRotateCamera;
  92560. /**
  92561. * Defines the gamepad the input is gathering event from.
  92562. */
  92563. gamepad: Nullable<Gamepad>;
  92564. /**
  92565. * Defines the gamepad rotation sensiblity.
  92566. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92567. */
  92568. gamepadRotationSensibility: number;
  92569. /**
  92570. * Defines the gamepad move sensiblity.
  92571. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92572. */
  92573. gamepadMoveSensibility: number;
  92574. private _onGamepadConnectedObserver;
  92575. private _onGamepadDisconnectedObserver;
  92576. /**
  92577. * Attach the input controls to a specific dom element to get the input from.
  92578. * @param element Defines the element the controls should be listened from
  92579. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92580. */
  92581. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92582. /**
  92583. * Detach the current controls from the specified dom element.
  92584. * @param element Defines the element to stop listening the inputs from
  92585. */
  92586. detachControl(element: Nullable<HTMLElement>): void;
  92587. /**
  92588. * Update the current camera state depending on the inputs that have been used this frame.
  92589. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92590. */
  92591. checkInputs(): void;
  92592. /**
  92593. * Gets the class name of the current intput.
  92594. * @returns the class name
  92595. */
  92596. getClassName(): string;
  92597. /**
  92598. * Get the friendly name associated with the input class.
  92599. * @returns the input friendly name
  92600. */
  92601. getSimpleName(): string;
  92602. }
  92603. }
  92604. declare module BABYLON {
  92605. interface ArcRotateCameraInputsManager {
  92606. /**
  92607. * Add orientation input support to the input manager.
  92608. * @returns the current input manager
  92609. */
  92610. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  92611. }
  92612. /**
  92613. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  92614. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92615. */
  92616. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  92617. /**
  92618. * Defines the camera the input is attached to.
  92619. */
  92620. camera: ArcRotateCamera;
  92621. /**
  92622. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  92623. */
  92624. alphaCorrection: number;
  92625. /**
  92626. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  92627. */
  92628. gammaCorrection: number;
  92629. private _alpha;
  92630. private _gamma;
  92631. private _dirty;
  92632. private _deviceOrientationHandler;
  92633. /**
  92634. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  92635. */
  92636. constructor();
  92637. /**
  92638. * Attach the input controls to a specific dom element to get the input from.
  92639. * @param element Defines the element the controls should be listened from
  92640. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92641. */
  92642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92643. /** @hidden */
  92644. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  92645. /**
  92646. * Update the current camera state depending on the inputs that have been used this frame.
  92647. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92648. */
  92649. checkInputs(): void;
  92650. /**
  92651. * Detach the current controls from the specified dom element.
  92652. * @param element Defines the element to stop listening the inputs from
  92653. */
  92654. detachControl(element: Nullable<HTMLElement>): void;
  92655. /**
  92656. * Gets the class name of the current intput.
  92657. * @returns the class name
  92658. */
  92659. getClassName(): string;
  92660. /**
  92661. * Get the friendly name associated with the input class.
  92662. * @returns the input friendly name
  92663. */
  92664. getSimpleName(): string;
  92665. }
  92666. }
  92667. declare module BABYLON {
  92668. /**
  92669. * Listen to mouse events to control the camera.
  92670. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92671. */
  92672. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  92673. /**
  92674. * Defines the camera the input is attached to.
  92675. */
  92676. camera: FlyCamera;
  92677. /**
  92678. * Defines if touch is enabled. (Default is true.)
  92679. */
  92680. touchEnabled: boolean;
  92681. /**
  92682. * Defines the buttons associated with the input to handle camera rotation.
  92683. */
  92684. buttons: number[];
  92685. /**
  92686. * Assign buttons for Yaw control.
  92687. */
  92688. buttonsYaw: number[];
  92689. /**
  92690. * Assign buttons for Pitch control.
  92691. */
  92692. buttonsPitch: number[];
  92693. /**
  92694. * Assign buttons for Roll control.
  92695. */
  92696. buttonsRoll: number[];
  92697. /**
  92698. * Detect if any button is being pressed while mouse is moved.
  92699. * -1 = Mouse locked.
  92700. * 0 = Left button.
  92701. * 1 = Middle Button.
  92702. * 2 = Right Button.
  92703. */
  92704. activeButton: number;
  92705. /**
  92706. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  92707. * Higher values reduce its sensitivity.
  92708. */
  92709. angularSensibility: number;
  92710. private _mousemoveCallback;
  92711. private _observer;
  92712. private _rollObserver;
  92713. private previousPosition;
  92714. private noPreventDefault;
  92715. private element;
  92716. /**
  92717. * Listen to mouse events to control the camera.
  92718. * @param touchEnabled Define if touch is enabled. (Default is true.)
  92719. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92720. */
  92721. constructor(touchEnabled?: boolean);
  92722. /**
  92723. * Attach the mouse control to the HTML DOM element.
  92724. * @param element Defines the element that listens to the input events.
  92725. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  92726. */
  92727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92728. /**
  92729. * Detach the current controls from the specified dom element.
  92730. * @param element Defines the element to stop listening the inputs from
  92731. */
  92732. detachControl(element: Nullable<HTMLElement>): void;
  92733. /**
  92734. * Gets the class name of the current input.
  92735. * @returns the class name.
  92736. */
  92737. getClassName(): string;
  92738. /**
  92739. * Get the friendly name associated with the input class.
  92740. * @returns the input's friendly name.
  92741. */
  92742. getSimpleName(): string;
  92743. private _pointerInput;
  92744. private _onMouseMove;
  92745. /**
  92746. * Rotate camera by mouse offset.
  92747. */
  92748. private rotateCamera;
  92749. }
  92750. }
  92751. declare module BABYLON {
  92752. /**
  92753. * Default Inputs manager for the FlyCamera.
  92754. * It groups all the default supported inputs for ease of use.
  92755. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92756. */
  92757. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  92758. /**
  92759. * Instantiates a new FlyCameraInputsManager.
  92760. * @param camera Defines the camera the inputs belong to.
  92761. */
  92762. constructor(camera: FlyCamera);
  92763. /**
  92764. * Add keyboard input support to the input manager.
  92765. * @returns the new FlyCameraKeyboardMoveInput().
  92766. */
  92767. addKeyboard(): FlyCameraInputsManager;
  92768. /**
  92769. * Add mouse input support to the input manager.
  92770. * @param touchEnabled Enable touch screen support.
  92771. * @returns the new FlyCameraMouseInput().
  92772. */
  92773. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  92774. }
  92775. }
  92776. declare module BABYLON {
  92777. /**
  92778. * This is a flying camera, designed for 3D movement and rotation in all directions,
  92779. * such as in a 3D Space Shooter or a Flight Simulator.
  92780. */
  92781. export class FlyCamera extends TargetCamera {
  92782. /**
  92783. * Define the collision ellipsoid of the camera.
  92784. * This is helpful for simulating a camera body, like a player's body.
  92785. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92786. */
  92787. ellipsoid: Vector3;
  92788. /**
  92789. * Define an offset for the position of the ellipsoid around the camera.
  92790. * This can be helpful if the camera is attached away from the player's body center,
  92791. * such as at its head.
  92792. */
  92793. ellipsoidOffset: Vector3;
  92794. /**
  92795. * Enable or disable collisions of the camera with the rest of the scene objects.
  92796. */
  92797. checkCollisions: boolean;
  92798. /**
  92799. * Enable or disable gravity on the camera.
  92800. */
  92801. applyGravity: boolean;
  92802. /**
  92803. * Define the current direction the camera is moving to.
  92804. */
  92805. cameraDirection: Vector3;
  92806. /**
  92807. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  92808. * This overrides and empties cameraRotation.
  92809. */
  92810. rotationQuaternion: Quaternion;
  92811. /**
  92812. * Track Roll to maintain the wanted Rolling when looking around.
  92813. */
  92814. _trackRoll: number;
  92815. /**
  92816. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  92817. */
  92818. rollCorrect: number;
  92819. /**
  92820. * Mimic a banked turn, Rolling the camera when Yawing.
  92821. * It's recommended to use rollCorrect = 10 for faster banking correction.
  92822. */
  92823. bankedTurn: boolean;
  92824. /**
  92825. * Limit in radians for how much Roll banking will add. (Default: 90°)
  92826. */
  92827. bankedTurnLimit: number;
  92828. /**
  92829. * Value of 0 disables the banked Roll.
  92830. * Value of 1 is equal to the Yaw angle in radians.
  92831. */
  92832. bankedTurnMultiplier: number;
  92833. /**
  92834. * The inputs manager loads all the input sources, such as keyboard and mouse.
  92835. */
  92836. inputs: FlyCameraInputsManager;
  92837. /**
  92838. * Gets the input sensibility for mouse input.
  92839. * Higher values reduce sensitivity.
  92840. */
  92841. /**
  92842. * Sets the input sensibility for a mouse input.
  92843. * Higher values reduce sensitivity.
  92844. */
  92845. angularSensibility: number;
  92846. /**
  92847. * Get the keys for camera movement forward.
  92848. */
  92849. /**
  92850. * Set the keys for camera movement forward.
  92851. */
  92852. keysForward: number[];
  92853. /**
  92854. * Get the keys for camera movement backward.
  92855. */
  92856. keysBackward: number[];
  92857. /**
  92858. * Get the keys for camera movement up.
  92859. */
  92860. /**
  92861. * Set the keys for camera movement up.
  92862. */
  92863. keysUp: number[];
  92864. /**
  92865. * Get the keys for camera movement down.
  92866. */
  92867. /**
  92868. * Set the keys for camera movement down.
  92869. */
  92870. keysDown: number[];
  92871. /**
  92872. * Get the keys for camera movement left.
  92873. */
  92874. /**
  92875. * Set the keys for camera movement left.
  92876. */
  92877. keysLeft: number[];
  92878. /**
  92879. * Set the keys for camera movement right.
  92880. */
  92881. /**
  92882. * Set the keys for camera movement right.
  92883. */
  92884. keysRight: number[];
  92885. /**
  92886. * Event raised when the camera collides with a mesh in the scene.
  92887. */
  92888. onCollide: (collidedMesh: AbstractMesh) => void;
  92889. private _collider;
  92890. private _needMoveForGravity;
  92891. private _oldPosition;
  92892. private _diffPosition;
  92893. private _newPosition;
  92894. /** @hidden */
  92895. _localDirection: Vector3;
  92896. /** @hidden */
  92897. _transformedDirection: Vector3;
  92898. /**
  92899. * Instantiates a FlyCamera.
  92900. * This is a flying camera, designed for 3D movement and rotation in all directions,
  92901. * such as in a 3D Space Shooter or a Flight Simulator.
  92902. * @param name Define the name of the camera in the scene.
  92903. * @param position Define the starting position of the camera in the scene.
  92904. * @param scene Define the scene the camera belongs to.
  92905. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  92906. */
  92907. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92908. /**
  92909. * Attach a control to the HTML DOM element.
  92910. * @param element Defines the element that listens to the input events.
  92911. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  92912. */
  92913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92914. /**
  92915. * Detach a control from the HTML DOM element.
  92916. * The camera will stop reacting to that input.
  92917. * @param element Defines the element that listens to the input events.
  92918. */
  92919. detachControl(element: HTMLElement): void;
  92920. private _collisionMask;
  92921. /**
  92922. * Get the mask that the camera ignores in collision events.
  92923. */
  92924. /**
  92925. * Set the mask that the camera ignores in collision events.
  92926. */
  92927. collisionMask: number;
  92928. /** @hidden */
  92929. _collideWithWorld(displacement: Vector3): void;
  92930. /** @hidden */
  92931. private _onCollisionPositionChange;
  92932. /** @hidden */
  92933. _checkInputs(): void;
  92934. /** @hidden */
  92935. _decideIfNeedsToMove(): boolean;
  92936. /** @hidden */
  92937. _updatePosition(): void;
  92938. /**
  92939. * Restore the Roll to its target value at the rate specified.
  92940. * @param rate - Higher means slower restoring.
  92941. * @hidden
  92942. */
  92943. restoreRoll(rate: number): void;
  92944. /**
  92945. * Destroy the camera and release the current resources held by it.
  92946. */
  92947. dispose(): void;
  92948. /**
  92949. * Get the current object class name.
  92950. * @returns the class name.
  92951. */
  92952. getClassName(): string;
  92953. }
  92954. }
  92955. declare module BABYLON {
  92956. /**
  92957. * Listen to keyboard events to control the camera.
  92958. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92959. */
  92960. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  92961. /**
  92962. * Defines the camera the input is attached to.
  92963. */
  92964. camera: FlyCamera;
  92965. /**
  92966. * The list of keyboard keys used to control the forward move of the camera.
  92967. */
  92968. keysForward: number[];
  92969. /**
  92970. * The list of keyboard keys used to control the backward move of the camera.
  92971. */
  92972. keysBackward: number[];
  92973. /**
  92974. * The list of keyboard keys used to control the forward move of the camera.
  92975. */
  92976. keysUp: number[];
  92977. /**
  92978. * The list of keyboard keys used to control the backward move of the camera.
  92979. */
  92980. keysDown: number[];
  92981. /**
  92982. * The list of keyboard keys used to control the right strafe move of the camera.
  92983. */
  92984. keysRight: number[];
  92985. /**
  92986. * The list of keyboard keys used to control the left strafe move of the camera.
  92987. */
  92988. keysLeft: number[];
  92989. private _keys;
  92990. private _onCanvasBlurObserver;
  92991. private _onKeyboardObserver;
  92992. private _engine;
  92993. private _scene;
  92994. /**
  92995. * Attach the input controls to a specific dom element to get the input from.
  92996. * @param element Defines the element the controls should be listened from
  92997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92998. */
  92999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93000. /**
  93001. * Detach the current controls from the specified dom element.
  93002. * @param element Defines the element to stop listening the inputs from
  93003. */
  93004. detachControl(element: Nullable<HTMLElement>): void;
  93005. /**
  93006. * Gets the class name of the current intput.
  93007. * @returns the class name
  93008. */
  93009. getClassName(): string;
  93010. /** @hidden */
  93011. _onLostFocus(e: FocusEvent): void;
  93012. /**
  93013. * Get the friendly name associated with the input class.
  93014. * @returns the input friendly name
  93015. */
  93016. getSimpleName(): string;
  93017. /**
  93018. * Update the current camera state depending on the inputs that have been used this frame.
  93019. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93020. */
  93021. checkInputs(): void;
  93022. }
  93023. }
  93024. declare module BABYLON {
  93025. /**
  93026. * Manage the mouse wheel inputs to control a follow camera.
  93027. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93028. */
  93029. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  93030. /**
  93031. * Defines the camera the input is attached to.
  93032. */
  93033. camera: FollowCamera;
  93034. /**
  93035. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  93036. */
  93037. axisControlRadius: boolean;
  93038. /**
  93039. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  93040. */
  93041. axisControlHeight: boolean;
  93042. /**
  93043. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  93044. */
  93045. axisControlRotation: boolean;
  93046. /**
  93047. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  93048. * relation to mouseWheel events.
  93049. */
  93050. wheelPrecision: number;
  93051. /**
  93052. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93053. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93054. */
  93055. wheelDeltaPercentage: number;
  93056. private _wheel;
  93057. private _observer;
  93058. /**
  93059. * Attach the input controls to a specific dom element to get the input from.
  93060. * @param element Defines the element the controls should be listened from
  93061. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93062. */
  93063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93064. /**
  93065. * Detach the current controls from the specified dom element.
  93066. * @param element Defines the element to stop listening the inputs from
  93067. */
  93068. detachControl(element: Nullable<HTMLElement>): void;
  93069. /**
  93070. * Gets the class name of the current intput.
  93071. * @returns the class name
  93072. */
  93073. getClassName(): string;
  93074. /**
  93075. * Get the friendly name associated with the input class.
  93076. * @returns the input friendly name
  93077. */
  93078. getSimpleName(): string;
  93079. }
  93080. }
  93081. declare module BABYLON {
  93082. /**
  93083. * Manage the pointers inputs to control an follow camera.
  93084. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93085. */
  93086. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  93087. /**
  93088. * Defines the camera the input is attached to.
  93089. */
  93090. camera: FollowCamera;
  93091. /**
  93092. * Gets the class name of the current input.
  93093. * @returns the class name
  93094. */
  93095. getClassName(): string;
  93096. /**
  93097. * Defines the pointer angular sensibility along the X axis or how fast is
  93098. * the camera rotating.
  93099. * A negative number will reverse the axis direction.
  93100. */
  93101. angularSensibilityX: number;
  93102. /**
  93103. * Defines the pointer angular sensibility along the Y axis or how fast is
  93104. * the camera rotating.
  93105. * A negative number will reverse the axis direction.
  93106. */
  93107. angularSensibilityY: number;
  93108. /**
  93109. * Defines the pointer pinch precision or how fast is the camera zooming.
  93110. * A negative number will reverse the axis direction.
  93111. */
  93112. pinchPrecision: number;
  93113. /**
  93114. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93115. * from 0.
  93116. * It defines the percentage of current camera.radius to use as delta when
  93117. * pinch zoom is used.
  93118. */
  93119. pinchDeltaPercentage: number;
  93120. /**
  93121. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  93122. */
  93123. axisXControlRadius: boolean;
  93124. /**
  93125. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  93126. */
  93127. axisXControlHeight: boolean;
  93128. /**
  93129. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  93130. */
  93131. axisXControlRotation: boolean;
  93132. /**
  93133. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  93134. */
  93135. axisYControlRadius: boolean;
  93136. /**
  93137. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  93138. */
  93139. axisYControlHeight: boolean;
  93140. /**
  93141. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  93142. */
  93143. axisYControlRotation: boolean;
  93144. /**
  93145. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  93146. */
  93147. axisPinchControlRadius: boolean;
  93148. /**
  93149. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  93150. */
  93151. axisPinchControlHeight: boolean;
  93152. /**
  93153. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  93154. */
  93155. axisPinchControlRotation: boolean;
  93156. /**
  93157. * Log error messages if basic misconfiguration has occurred.
  93158. */
  93159. warningEnable: boolean;
  93160. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93161. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93162. private _warningCounter;
  93163. private _warning;
  93164. }
  93165. }
  93166. declare module BABYLON {
  93167. /**
  93168. * Default Inputs manager for the FollowCamera.
  93169. * It groups all the default supported inputs for ease of use.
  93170. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93171. */
  93172. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  93173. /**
  93174. * Instantiates a new FollowCameraInputsManager.
  93175. * @param camera Defines the camera the inputs belong to
  93176. */
  93177. constructor(camera: FollowCamera);
  93178. /**
  93179. * Add keyboard input support to the input manager.
  93180. * @returns the current input manager
  93181. */
  93182. addKeyboard(): FollowCameraInputsManager;
  93183. /**
  93184. * Add mouse wheel input support to the input manager.
  93185. * @returns the current input manager
  93186. */
  93187. addMouseWheel(): FollowCameraInputsManager;
  93188. /**
  93189. * Add pointers input support to the input manager.
  93190. * @returns the current input manager
  93191. */
  93192. addPointers(): FollowCameraInputsManager;
  93193. /**
  93194. * Add orientation input support to the input manager.
  93195. * @returns the current input manager
  93196. */
  93197. addVRDeviceOrientation(): FollowCameraInputsManager;
  93198. }
  93199. }
  93200. declare module BABYLON {
  93201. /**
  93202. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  93203. * an arc rotate version arcFollowCamera are available.
  93204. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93205. */
  93206. export class FollowCamera extends TargetCamera {
  93207. /**
  93208. * Distance the follow camera should follow an object at
  93209. */
  93210. radius: number;
  93211. /**
  93212. * Minimum allowed distance of the camera to the axis of rotation
  93213. * (The camera can not get closer).
  93214. * This can help limiting how the Camera is able to move in the scene.
  93215. */
  93216. lowerRadiusLimit: Nullable<number>;
  93217. /**
  93218. * Maximum allowed distance of the camera to the axis of rotation
  93219. * (The camera can not get further).
  93220. * This can help limiting how the Camera is able to move in the scene.
  93221. */
  93222. upperRadiusLimit: Nullable<number>;
  93223. /**
  93224. * Define a rotation offset between the camera and the object it follows
  93225. */
  93226. rotationOffset: number;
  93227. /**
  93228. * Minimum allowed angle to camera position relative to target object.
  93229. * This can help limiting how the Camera is able to move in the scene.
  93230. */
  93231. lowerRotationOffsetLimit: Nullable<number>;
  93232. /**
  93233. * Maximum allowed angle to camera position relative to target object.
  93234. * This can help limiting how the Camera is able to move in the scene.
  93235. */
  93236. upperRotationOffsetLimit: Nullable<number>;
  93237. /**
  93238. * Define a height offset between the camera and the object it follows.
  93239. * It can help following an object from the top (like a car chaing a plane)
  93240. */
  93241. heightOffset: number;
  93242. /**
  93243. * Minimum allowed height of camera position relative to target object.
  93244. * This can help limiting how the Camera is able to move in the scene.
  93245. */
  93246. lowerHeightOffsetLimit: Nullable<number>;
  93247. /**
  93248. * Maximum allowed height of camera position relative to target object.
  93249. * This can help limiting how the Camera is able to move in the scene.
  93250. */
  93251. upperHeightOffsetLimit: Nullable<number>;
  93252. /**
  93253. * Define how fast the camera can accelerate to follow it s target.
  93254. */
  93255. cameraAcceleration: number;
  93256. /**
  93257. * Define the speed limit of the camera following an object.
  93258. */
  93259. maxCameraSpeed: number;
  93260. /**
  93261. * Define the target of the camera.
  93262. */
  93263. lockedTarget: Nullable<AbstractMesh>;
  93264. /**
  93265. * Defines the input associated with the camera.
  93266. */
  93267. inputs: FollowCameraInputsManager;
  93268. /**
  93269. * Instantiates the follow camera.
  93270. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93271. * @param name Define the name of the camera in the scene
  93272. * @param position Define the position of the camera
  93273. * @param scene Define the scene the camera belong to
  93274. * @param lockedTarget Define the target of the camera
  93275. */
  93276. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  93277. private _follow;
  93278. /**
  93279. * Attached controls to the current camera.
  93280. * @param element Defines the element the controls should be listened from
  93281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93282. */
  93283. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93284. /**
  93285. * Detach the current controls from the camera.
  93286. * The camera will stop reacting to inputs.
  93287. * @param element Defines the element to stop listening the inputs from
  93288. */
  93289. detachControl(element: HTMLElement): void;
  93290. /** @hidden */
  93291. _checkInputs(): void;
  93292. private _checkLimits;
  93293. /**
  93294. * Gets the camera class name.
  93295. * @returns the class name
  93296. */
  93297. getClassName(): string;
  93298. }
  93299. /**
  93300. * Arc Rotate version of the follow camera.
  93301. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  93302. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93303. */
  93304. export class ArcFollowCamera extends TargetCamera {
  93305. /** The longitudinal angle of the camera */
  93306. alpha: number;
  93307. /** The latitudinal angle of the camera */
  93308. beta: number;
  93309. /** The radius of the camera from its target */
  93310. radius: number;
  93311. /** Define the camera target (the messh it should follow) */
  93312. target: Nullable<AbstractMesh>;
  93313. private _cartesianCoordinates;
  93314. /**
  93315. * Instantiates a new ArcFollowCamera
  93316. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93317. * @param name Define the name of the camera
  93318. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  93319. * @param beta Define the rotation angle of the camera around the elevation axis
  93320. * @param radius Define the radius of the camera from its target point
  93321. * @param target Define the target of the camera
  93322. * @param scene Define the scene the camera belongs to
  93323. */
  93324. constructor(name: string,
  93325. /** The longitudinal angle of the camera */
  93326. alpha: number,
  93327. /** The latitudinal angle of the camera */
  93328. beta: number,
  93329. /** The radius of the camera from its target */
  93330. radius: number,
  93331. /** Define the camera target (the messh it should follow) */
  93332. target: Nullable<AbstractMesh>, scene: Scene);
  93333. private _follow;
  93334. /** @hidden */
  93335. _checkInputs(): void;
  93336. /**
  93337. * Returns the class name of the object.
  93338. * It is mostly used internally for serialization purposes.
  93339. */
  93340. getClassName(): string;
  93341. }
  93342. }
  93343. declare module BABYLON {
  93344. /**
  93345. * Manage the keyboard inputs to control the movement of a follow camera.
  93346. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93347. */
  93348. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  93349. /**
  93350. * Defines the camera the input is attached to.
  93351. */
  93352. camera: FollowCamera;
  93353. /**
  93354. * Defines the list of key codes associated with the up action (increase heightOffset)
  93355. */
  93356. keysHeightOffsetIncr: number[];
  93357. /**
  93358. * Defines the list of key codes associated with the down action (decrease heightOffset)
  93359. */
  93360. keysHeightOffsetDecr: number[];
  93361. /**
  93362. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  93363. */
  93364. keysHeightOffsetModifierAlt: boolean;
  93365. /**
  93366. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  93367. */
  93368. keysHeightOffsetModifierCtrl: boolean;
  93369. /**
  93370. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  93371. */
  93372. keysHeightOffsetModifierShift: boolean;
  93373. /**
  93374. * Defines the list of key codes associated with the left action (increase rotationOffset)
  93375. */
  93376. keysRotationOffsetIncr: number[];
  93377. /**
  93378. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  93379. */
  93380. keysRotationOffsetDecr: number[];
  93381. /**
  93382. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  93383. */
  93384. keysRotationOffsetModifierAlt: boolean;
  93385. /**
  93386. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  93387. */
  93388. keysRotationOffsetModifierCtrl: boolean;
  93389. /**
  93390. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  93391. */
  93392. keysRotationOffsetModifierShift: boolean;
  93393. /**
  93394. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  93395. */
  93396. keysRadiusIncr: number[];
  93397. /**
  93398. * Defines the list of key codes associated with the zoom-out action (increase radius)
  93399. */
  93400. keysRadiusDecr: number[];
  93401. /**
  93402. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  93403. */
  93404. keysRadiusModifierAlt: boolean;
  93405. /**
  93406. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  93407. */
  93408. keysRadiusModifierCtrl: boolean;
  93409. /**
  93410. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  93411. */
  93412. keysRadiusModifierShift: boolean;
  93413. /**
  93414. * Defines the rate of change of heightOffset.
  93415. */
  93416. heightSensibility: number;
  93417. /**
  93418. * Defines the rate of change of rotationOffset.
  93419. */
  93420. rotationSensibility: number;
  93421. /**
  93422. * Defines the rate of change of radius.
  93423. */
  93424. radiusSensibility: number;
  93425. private _keys;
  93426. private _ctrlPressed;
  93427. private _altPressed;
  93428. private _shiftPressed;
  93429. private _onCanvasBlurObserver;
  93430. private _onKeyboardObserver;
  93431. private _engine;
  93432. private _scene;
  93433. /**
  93434. * Attach the input controls to a specific dom element to get the input from.
  93435. * @param element Defines the element the controls should be listened from
  93436. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93437. */
  93438. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93439. /**
  93440. * Detach the current controls from the specified dom element.
  93441. * @param element Defines the element to stop listening the inputs from
  93442. */
  93443. detachControl(element: Nullable<HTMLElement>): void;
  93444. /**
  93445. * Update the current camera state depending on the inputs that have been used this frame.
  93446. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93447. */
  93448. checkInputs(): void;
  93449. /**
  93450. * Gets the class name of the current input.
  93451. * @returns the class name
  93452. */
  93453. getClassName(): string;
  93454. /**
  93455. * Get the friendly name associated with the input class.
  93456. * @returns the input friendly name
  93457. */
  93458. getSimpleName(): string;
  93459. /**
  93460. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93461. * allow modification of the heightOffset value.
  93462. */
  93463. private _modifierHeightOffset;
  93464. /**
  93465. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93466. * allow modification of the rotationOffset value.
  93467. */
  93468. private _modifierRotationOffset;
  93469. /**
  93470. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93471. * allow modification of the radius value.
  93472. */
  93473. private _modifierRadius;
  93474. }
  93475. }
  93476. declare module BABYLON {
  93477. interface FreeCameraInputsManager {
  93478. /**
  93479. * Add orientation input support to the input manager.
  93480. * @returns the current input manager
  93481. */
  93482. addDeviceOrientation(): FreeCameraInputsManager;
  93483. }
  93484. /**
  93485. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  93486. * Screen rotation is taken into account.
  93487. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93488. */
  93489. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  93490. private _camera;
  93491. private _screenOrientationAngle;
  93492. private _constantTranform;
  93493. private _screenQuaternion;
  93494. private _alpha;
  93495. private _beta;
  93496. private _gamma;
  93497. /**
  93498. * Instantiates a new input
  93499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93500. */
  93501. constructor();
  93502. /**
  93503. * Define the camera controlled by the input.
  93504. */
  93505. camera: FreeCamera;
  93506. /**
  93507. * Attach the input controls to a specific dom element to get the input from.
  93508. * @param element Defines the element the controls should be listened from
  93509. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93510. */
  93511. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93512. private _orientationChanged;
  93513. private _deviceOrientation;
  93514. /**
  93515. * Detach the current controls from the specified dom element.
  93516. * @param element Defines the element to stop listening the inputs from
  93517. */
  93518. detachControl(element: Nullable<HTMLElement>): void;
  93519. /**
  93520. * Update the current camera state depending on the inputs that have been used this frame.
  93521. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93522. */
  93523. checkInputs(): void;
  93524. /**
  93525. * Gets the class name of the current intput.
  93526. * @returns the class name
  93527. */
  93528. getClassName(): string;
  93529. /**
  93530. * Get the friendly name associated with the input class.
  93531. * @returns the input friendly name
  93532. */
  93533. getSimpleName(): string;
  93534. }
  93535. }
  93536. declare module BABYLON {
  93537. /**
  93538. * Manage the gamepad inputs to control a free camera.
  93539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93540. */
  93541. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  93542. /**
  93543. * Define the camera the input is attached to.
  93544. */
  93545. camera: FreeCamera;
  93546. /**
  93547. * Define the Gamepad controlling the input
  93548. */
  93549. gamepad: Nullable<Gamepad>;
  93550. /**
  93551. * Defines the gamepad rotation sensiblity.
  93552. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93553. */
  93554. gamepadAngularSensibility: number;
  93555. /**
  93556. * Defines the gamepad move sensiblity.
  93557. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93558. */
  93559. gamepadMoveSensibility: number;
  93560. private _onGamepadConnectedObserver;
  93561. private _onGamepadDisconnectedObserver;
  93562. private _cameraTransform;
  93563. private _deltaTransform;
  93564. private _vector3;
  93565. private _vector2;
  93566. /**
  93567. * Attach the input controls to a specific dom element to get the input from.
  93568. * @param element Defines the element the controls should be listened from
  93569. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93570. */
  93571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93572. /**
  93573. * Detach the current controls from the specified dom element.
  93574. * @param element Defines the element to stop listening the inputs from
  93575. */
  93576. detachControl(element: Nullable<HTMLElement>): void;
  93577. /**
  93578. * Update the current camera state depending on the inputs that have been used this frame.
  93579. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93580. */
  93581. checkInputs(): void;
  93582. /**
  93583. * Gets the class name of the current intput.
  93584. * @returns the class name
  93585. */
  93586. getClassName(): string;
  93587. /**
  93588. * Get the friendly name associated with the input class.
  93589. * @returns the input friendly name
  93590. */
  93591. getSimpleName(): string;
  93592. }
  93593. }
  93594. declare module BABYLON {
  93595. /**
  93596. * Defines the potential axis of a Joystick
  93597. */
  93598. export enum JoystickAxis {
  93599. /** X axis */
  93600. X = 0,
  93601. /** Y axis */
  93602. Y = 1,
  93603. /** Z axis */
  93604. Z = 2
  93605. }
  93606. /**
  93607. * Class used to define virtual joystick (used in touch mode)
  93608. */
  93609. export class VirtualJoystick {
  93610. /**
  93611. * Gets or sets a boolean indicating that left and right values must be inverted
  93612. */
  93613. reverseLeftRight: boolean;
  93614. /**
  93615. * Gets or sets a boolean indicating that up and down values must be inverted
  93616. */
  93617. reverseUpDown: boolean;
  93618. /**
  93619. * Gets the offset value for the position (ie. the change of the position value)
  93620. */
  93621. deltaPosition: Vector3;
  93622. /**
  93623. * Gets a boolean indicating if the virtual joystick was pressed
  93624. */
  93625. pressed: boolean;
  93626. /**
  93627. * Canvas the virtual joystick will render onto, default z-index of this is 5
  93628. */
  93629. static Canvas: Nullable<HTMLCanvasElement>;
  93630. private static _globalJoystickIndex;
  93631. private static vjCanvasContext;
  93632. private static vjCanvasWidth;
  93633. private static vjCanvasHeight;
  93634. private static halfWidth;
  93635. private _action;
  93636. private _axisTargetedByLeftAndRight;
  93637. private _axisTargetedByUpAndDown;
  93638. private _joystickSensibility;
  93639. private _inversedSensibility;
  93640. private _joystickPointerID;
  93641. private _joystickColor;
  93642. private _joystickPointerPos;
  93643. private _joystickPreviousPointerPos;
  93644. private _joystickPointerStartPos;
  93645. private _deltaJoystickVector;
  93646. private _leftJoystick;
  93647. private _touches;
  93648. private _onPointerDownHandlerRef;
  93649. private _onPointerMoveHandlerRef;
  93650. private _onPointerUpHandlerRef;
  93651. private _onResize;
  93652. /**
  93653. * Creates a new virtual joystick
  93654. * @param leftJoystick defines that the joystick is for left hand (false by default)
  93655. */
  93656. constructor(leftJoystick?: boolean);
  93657. /**
  93658. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  93659. * @param newJoystickSensibility defines the new sensibility
  93660. */
  93661. setJoystickSensibility(newJoystickSensibility: number): void;
  93662. private _onPointerDown;
  93663. private _onPointerMove;
  93664. private _onPointerUp;
  93665. /**
  93666. * Change the color of the virtual joystick
  93667. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  93668. */
  93669. setJoystickColor(newColor: string): void;
  93670. /**
  93671. * Defines a callback to call when the joystick is touched
  93672. * @param action defines the callback
  93673. */
  93674. setActionOnTouch(action: () => any): void;
  93675. /**
  93676. * Defines which axis you'd like to control for left & right
  93677. * @param axis defines the axis to use
  93678. */
  93679. setAxisForLeftRight(axis: JoystickAxis): void;
  93680. /**
  93681. * Defines which axis you'd like to control for up & down
  93682. * @param axis defines the axis to use
  93683. */
  93684. setAxisForUpDown(axis: JoystickAxis): void;
  93685. private _drawVirtualJoystick;
  93686. /**
  93687. * Release internal HTML canvas
  93688. */
  93689. releaseCanvas(): void;
  93690. }
  93691. }
  93692. declare module BABYLON {
  93693. interface FreeCameraInputsManager {
  93694. /**
  93695. * Add virtual joystick input support to the input manager.
  93696. * @returns the current input manager
  93697. */
  93698. addVirtualJoystick(): FreeCameraInputsManager;
  93699. }
  93700. /**
  93701. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  93702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93703. */
  93704. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  93705. /**
  93706. * Defines the camera the input is attached to.
  93707. */
  93708. camera: FreeCamera;
  93709. private _leftjoystick;
  93710. private _rightjoystick;
  93711. /**
  93712. * Gets the left stick of the virtual joystick.
  93713. * @returns The virtual Joystick
  93714. */
  93715. getLeftJoystick(): VirtualJoystick;
  93716. /**
  93717. * Gets the right stick of the virtual joystick.
  93718. * @returns The virtual Joystick
  93719. */
  93720. getRightJoystick(): VirtualJoystick;
  93721. /**
  93722. * Update the current camera state depending on the inputs that have been used this frame.
  93723. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93724. */
  93725. checkInputs(): void;
  93726. /**
  93727. * Attach the input controls to a specific dom element to get the input from.
  93728. * @param element Defines the element the controls should be listened from
  93729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93730. */
  93731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93732. /**
  93733. * Detach the current controls from the specified dom element.
  93734. * @param element Defines the element to stop listening the inputs from
  93735. */
  93736. detachControl(element: Nullable<HTMLElement>): void;
  93737. /**
  93738. * Gets the class name of the current intput.
  93739. * @returns the class name
  93740. */
  93741. getClassName(): string;
  93742. /**
  93743. * Get the friendly name associated with the input class.
  93744. * @returns the input friendly name
  93745. */
  93746. getSimpleName(): string;
  93747. }
  93748. }
  93749. declare module BABYLON {
  93750. /**
  93751. * This represents a FPS type of camera controlled by touch.
  93752. * This is like a universal camera minus the Gamepad controls.
  93753. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93754. */
  93755. export class TouchCamera extends FreeCamera {
  93756. /**
  93757. * Defines the touch sensibility for rotation.
  93758. * The higher the faster.
  93759. */
  93760. touchAngularSensibility: number;
  93761. /**
  93762. * Defines the touch sensibility for move.
  93763. * The higher the faster.
  93764. */
  93765. touchMoveSensibility: number;
  93766. /**
  93767. * Instantiates a new touch camera.
  93768. * This represents a FPS type of camera controlled by touch.
  93769. * This is like a universal camera minus the Gamepad controls.
  93770. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93771. * @param name Define the name of the camera in the scene
  93772. * @param position Define the start position of the camera in the scene
  93773. * @param scene Define the scene the camera belongs to
  93774. */
  93775. constructor(name: string, position: Vector3, scene: Scene);
  93776. /**
  93777. * Gets the current object class name.
  93778. * @return the class name
  93779. */
  93780. getClassName(): string;
  93781. /** @hidden */
  93782. _setupInputs(): void;
  93783. }
  93784. }
  93785. declare module BABYLON {
  93786. /**
  93787. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  93788. * being tilted forward or back and left or right.
  93789. */
  93790. export class DeviceOrientationCamera extends FreeCamera {
  93791. private _initialQuaternion;
  93792. private _quaternionCache;
  93793. /**
  93794. * Creates a new device orientation camera
  93795. * @param name The name of the camera
  93796. * @param position The start position camera
  93797. * @param scene The scene the camera belongs to
  93798. */
  93799. constructor(name: string, position: Vector3, scene: Scene);
  93800. /**
  93801. * Gets the current instance class name ("DeviceOrientationCamera").
  93802. * This helps avoiding instanceof at run time.
  93803. * @returns the class name
  93804. */
  93805. getClassName(): string;
  93806. /**
  93807. * @hidden
  93808. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  93809. */
  93810. _checkInputs(): void;
  93811. /**
  93812. * Reset the camera to its default orientation on the specified axis only.
  93813. * @param axis The axis to reset
  93814. */
  93815. resetToCurrentRotation(axis?: Axis): void;
  93816. }
  93817. }
  93818. declare module BABYLON {
  93819. /**
  93820. * 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,
  93821. * which still works and will still be found in many Playgrounds.
  93822. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93823. */
  93824. export class UniversalCamera extends TouchCamera {
  93825. /**
  93826. * Defines the gamepad rotation sensiblity.
  93827. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93828. */
  93829. gamepadAngularSensibility: number;
  93830. /**
  93831. * Defines the gamepad move sensiblity.
  93832. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93833. */
  93834. gamepadMoveSensibility: number;
  93835. /**
  93836. * 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,
  93837. * which still works and will still be found in many Playgrounds.
  93838. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93839. * @param name Define the name of the camera in the scene
  93840. * @param position Define the start position of the camera in the scene
  93841. * @param scene Define the scene the camera belongs to
  93842. */
  93843. constructor(name: string, position: Vector3, scene: Scene);
  93844. /**
  93845. * Gets the current object class name.
  93846. * @return the class name
  93847. */
  93848. getClassName(): string;
  93849. }
  93850. }
  93851. declare module BABYLON {
  93852. /**
  93853. * This represents a FPS type of camera. This is only here for back compat purpose.
  93854. * Please use the UniversalCamera instead as both are identical.
  93855. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93856. */
  93857. export class GamepadCamera extends UniversalCamera {
  93858. /**
  93859. * Instantiates a new Gamepad Camera
  93860. * This represents a FPS type of camera. This is only here for back compat purpose.
  93861. * Please use the UniversalCamera instead as both are identical.
  93862. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93863. * @param name Define the name of the camera in the scene
  93864. * @param position Define the start position of the camera in the scene
  93865. * @param scene Define the scene the camera belongs to
  93866. */
  93867. constructor(name: string, position: Vector3, scene: Scene);
  93868. /**
  93869. * Gets the current object class name.
  93870. * @return the class name
  93871. */
  93872. getClassName(): string;
  93873. }
  93874. }
  93875. declare module BABYLON {
  93876. /** @hidden */
  93877. export var passPixelShader: {
  93878. name: string;
  93879. shader: string;
  93880. };
  93881. }
  93882. declare module BABYLON {
  93883. /** @hidden */
  93884. export var passCubePixelShader: {
  93885. name: string;
  93886. shader: string;
  93887. };
  93888. }
  93889. declare module BABYLON {
  93890. /**
  93891. * PassPostProcess which produces an output the same as it's input
  93892. */
  93893. export class PassPostProcess extends PostProcess {
  93894. /**
  93895. * Creates the PassPostProcess
  93896. * @param name The name of the effect.
  93897. * @param options The required width/height ratio to downsize to before computing the render pass.
  93898. * @param camera The camera to apply the render pass to.
  93899. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93900. * @param engine The engine which the post process will be applied. (default: current engine)
  93901. * @param reusable If the post process can be reused on the same frame. (default: false)
  93902. * @param textureType The type of texture to be used when performing the post processing.
  93903. * @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)
  93904. */
  93905. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  93906. }
  93907. /**
  93908. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  93909. */
  93910. export class PassCubePostProcess extends PostProcess {
  93911. private _face;
  93912. /**
  93913. * Gets or sets the cube face to display.
  93914. * * 0 is +X
  93915. * * 1 is -X
  93916. * * 2 is +Y
  93917. * * 3 is -Y
  93918. * * 4 is +Z
  93919. * * 5 is -Z
  93920. */
  93921. face: number;
  93922. /**
  93923. * Creates the PassCubePostProcess
  93924. * @param name The name of the effect.
  93925. * @param options The required width/height ratio to downsize to before computing the render pass.
  93926. * @param camera The camera to apply the render pass to.
  93927. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93928. * @param engine The engine which the post process will be applied. (default: current engine)
  93929. * @param reusable If the post process can be reused on the same frame. (default: false)
  93930. * @param textureType The type of texture to be used when performing the post processing.
  93931. * @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)
  93932. */
  93933. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  93934. }
  93935. }
  93936. declare module BABYLON {
  93937. /** @hidden */
  93938. export var anaglyphPixelShader: {
  93939. name: string;
  93940. shader: string;
  93941. };
  93942. }
  93943. declare module BABYLON {
  93944. /**
  93945. * Postprocess used to generate anaglyphic rendering
  93946. */
  93947. export class AnaglyphPostProcess extends PostProcess {
  93948. private _passedProcess;
  93949. /**
  93950. * Creates a new AnaglyphPostProcess
  93951. * @param name defines postprocess name
  93952. * @param options defines creation options or target ratio scale
  93953. * @param rigCameras defines cameras using this postprocess
  93954. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  93955. * @param engine defines hosting engine
  93956. * @param reusable defines if the postprocess will be reused multiple times per frame
  93957. */
  93958. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  93959. }
  93960. }
  93961. declare module BABYLON {
  93962. /**
  93963. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  93964. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  93965. */
  93966. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  93967. /**
  93968. * Creates a new AnaglyphArcRotateCamera
  93969. * @param name defines camera name
  93970. * @param alpha defines alpha angle (in radians)
  93971. * @param beta defines beta angle (in radians)
  93972. * @param radius defines radius
  93973. * @param target defines camera target
  93974. * @param interaxialDistance defines distance between each color axis
  93975. * @param scene defines the hosting scene
  93976. */
  93977. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  93978. /**
  93979. * Gets camera class name
  93980. * @returns AnaglyphArcRotateCamera
  93981. */
  93982. getClassName(): string;
  93983. }
  93984. }
  93985. declare module BABYLON {
  93986. /**
  93987. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  93988. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  93989. */
  93990. export class AnaglyphFreeCamera extends FreeCamera {
  93991. /**
  93992. * Creates a new AnaglyphFreeCamera
  93993. * @param name defines camera name
  93994. * @param position defines initial position
  93995. * @param interaxialDistance defines distance between each color axis
  93996. * @param scene defines the hosting scene
  93997. */
  93998. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  93999. /**
  94000. * Gets camera class name
  94001. * @returns AnaglyphFreeCamera
  94002. */
  94003. getClassName(): string;
  94004. }
  94005. }
  94006. declare module BABYLON {
  94007. /**
  94008. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  94009. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94010. */
  94011. export class AnaglyphGamepadCamera extends GamepadCamera {
  94012. /**
  94013. * Creates a new AnaglyphGamepadCamera
  94014. * @param name defines camera name
  94015. * @param position defines initial position
  94016. * @param interaxialDistance defines distance between each color axis
  94017. * @param scene defines the hosting scene
  94018. */
  94019. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94020. /**
  94021. * Gets camera class name
  94022. * @returns AnaglyphGamepadCamera
  94023. */
  94024. getClassName(): string;
  94025. }
  94026. }
  94027. declare module BABYLON {
  94028. /**
  94029. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  94030. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94031. */
  94032. export class AnaglyphUniversalCamera extends UniversalCamera {
  94033. /**
  94034. * Creates a new AnaglyphUniversalCamera
  94035. * @param name defines camera name
  94036. * @param position defines initial position
  94037. * @param interaxialDistance defines distance between each color axis
  94038. * @param scene defines the hosting scene
  94039. */
  94040. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94041. /**
  94042. * Gets camera class name
  94043. * @returns AnaglyphUniversalCamera
  94044. */
  94045. getClassName(): string;
  94046. }
  94047. }
  94048. declare module BABYLON {
  94049. /** @hidden */
  94050. export var stereoscopicInterlacePixelShader: {
  94051. name: string;
  94052. shader: string;
  94053. };
  94054. }
  94055. declare module BABYLON {
  94056. /**
  94057. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  94058. */
  94059. export class StereoscopicInterlacePostProcess extends PostProcess {
  94060. private _stepSize;
  94061. private _passedProcess;
  94062. /**
  94063. * Initializes a StereoscopicInterlacePostProcess
  94064. * @param name The name of the effect.
  94065. * @param rigCameras The rig cameras to be appled to the post process
  94066. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  94067. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94068. * @param engine The engine which the post process will be applied. (default: current engine)
  94069. * @param reusable If the post process can be reused on the same frame. (default: false)
  94070. */
  94071. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  94072. }
  94073. }
  94074. declare module BABYLON {
  94075. /**
  94076. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  94077. * @see http://doc.babylonjs.com/features/cameras
  94078. */
  94079. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  94080. /**
  94081. * Creates a new StereoscopicArcRotateCamera
  94082. * @param name defines camera name
  94083. * @param alpha defines alpha angle (in radians)
  94084. * @param beta defines beta angle (in radians)
  94085. * @param radius defines radius
  94086. * @param target defines camera target
  94087. * @param interaxialDistance defines distance between each color axis
  94088. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94089. * @param scene defines the hosting scene
  94090. */
  94091. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94092. /**
  94093. * Gets camera class name
  94094. * @returns StereoscopicArcRotateCamera
  94095. */
  94096. getClassName(): string;
  94097. }
  94098. }
  94099. declare module BABYLON {
  94100. /**
  94101. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  94102. * @see http://doc.babylonjs.com/features/cameras
  94103. */
  94104. export class StereoscopicFreeCamera extends FreeCamera {
  94105. /**
  94106. * Creates a new StereoscopicFreeCamera
  94107. * @param name defines camera name
  94108. * @param position defines initial position
  94109. * @param interaxialDistance defines distance between each color axis
  94110. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94111. * @param scene defines the hosting scene
  94112. */
  94113. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94114. /**
  94115. * Gets camera class name
  94116. * @returns StereoscopicFreeCamera
  94117. */
  94118. getClassName(): string;
  94119. }
  94120. }
  94121. declare module BABYLON {
  94122. /**
  94123. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  94124. * @see http://doc.babylonjs.com/features/cameras
  94125. */
  94126. export class StereoscopicGamepadCamera extends GamepadCamera {
  94127. /**
  94128. * Creates a new StereoscopicGamepadCamera
  94129. * @param name defines camera name
  94130. * @param position defines initial position
  94131. * @param interaxialDistance defines distance between each color axis
  94132. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94133. * @param scene defines the hosting scene
  94134. */
  94135. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94136. /**
  94137. * Gets camera class name
  94138. * @returns StereoscopicGamepadCamera
  94139. */
  94140. getClassName(): string;
  94141. }
  94142. }
  94143. declare module BABYLON {
  94144. /**
  94145. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  94146. * @see http://doc.babylonjs.com/features/cameras
  94147. */
  94148. export class StereoscopicUniversalCamera extends UniversalCamera {
  94149. /**
  94150. * Creates a new StereoscopicUniversalCamera
  94151. * @param name defines camera name
  94152. * @param position defines initial position
  94153. * @param interaxialDistance defines distance between each color axis
  94154. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94155. * @param scene defines the hosting scene
  94156. */
  94157. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94158. /**
  94159. * Gets camera class name
  94160. * @returns StereoscopicUniversalCamera
  94161. */
  94162. getClassName(): string;
  94163. }
  94164. }
  94165. declare module BABYLON {
  94166. /**
  94167. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94168. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94169. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94170. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94171. */
  94172. export class VirtualJoysticksCamera extends FreeCamera {
  94173. /**
  94174. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  94175. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94176. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94177. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94178. * @param name Define the name of the camera in the scene
  94179. * @param position Define the start position of the camera in the scene
  94180. * @param scene Define the scene the camera belongs to
  94181. */
  94182. constructor(name: string, position: Vector3, scene: Scene);
  94183. /**
  94184. * Gets the current object class name.
  94185. * @return the class name
  94186. */
  94187. getClassName(): string;
  94188. }
  94189. }
  94190. declare module BABYLON {
  94191. /**
  94192. * This represents all the required metrics to create a VR camera.
  94193. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  94194. */
  94195. export class VRCameraMetrics {
  94196. /**
  94197. * Define the horizontal resolution off the screen.
  94198. */
  94199. hResolution: number;
  94200. /**
  94201. * Define the vertical resolution off the screen.
  94202. */
  94203. vResolution: number;
  94204. /**
  94205. * Define the horizontal screen size.
  94206. */
  94207. hScreenSize: number;
  94208. /**
  94209. * Define the vertical screen size.
  94210. */
  94211. vScreenSize: number;
  94212. /**
  94213. * Define the vertical screen center position.
  94214. */
  94215. vScreenCenter: number;
  94216. /**
  94217. * Define the distance of the eyes to the screen.
  94218. */
  94219. eyeToScreenDistance: number;
  94220. /**
  94221. * Define the distance between both lenses
  94222. */
  94223. lensSeparationDistance: number;
  94224. /**
  94225. * Define the distance between both viewer's eyes.
  94226. */
  94227. interpupillaryDistance: number;
  94228. /**
  94229. * Define the distortion factor of the VR postprocess.
  94230. * Please, touch with care.
  94231. */
  94232. distortionK: number[];
  94233. /**
  94234. * Define the chromatic aberration correction factors for the VR post process.
  94235. */
  94236. chromaAbCorrection: number[];
  94237. /**
  94238. * Define the scale factor of the post process.
  94239. * The smaller the better but the slower.
  94240. */
  94241. postProcessScaleFactor: number;
  94242. /**
  94243. * Define an offset for the lens center.
  94244. */
  94245. lensCenterOffset: number;
  94246. /**
  94247. * Define if the current vr camera should compensate the distortion of the lense or not.
  94248. */
  94249. compensateDistortion: boolean;
  94250. /**
  94251. * Gets the rendering aspect ratio based on the provided resolutions.
  94252. */
  94253. readonly aspectRatio: number;
  94254. /**
  94255. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  94256. */
  94257. readonly aspectRatioFov: number;
  94258. /**
  94259. * @hidden
  94260. */
  94261. readonly leftHMatrix: Matrix;
  94262. /**
  94263. * @hidden
  94264. */
  94265. readonly rightHMatrix: Matrix;
  94266. /**
  94267. * @hidden
  94268. */
  94269. readonly leftPreViewMatrix: Matrix;
  94270. /**
  94271. * @hidden
  94272. */
  94273. readonly rightPreViewMatrix: Matrix;
  94274. /**
  94275. * Get the default VRMetrics based on the most generic setup.
  94276. * @returns the default vr metrics
  94277. */
  94278. static GetDefault(): VRCameraMetrics;
  94279. }
  94280. }
  94281. declare module BABYLON {
  94282. /** @hidden */
  94283. export var vrDistortionCorrectionPixelShader: {
  94284. name: string;
  94285. shader: string;
  94286. };
  94287. }
  94288. declare module BABYLON {
  94289. /**
  94290. * VRDistortionCorrectionPostProcess used for mobile VR
  94291. */
  94292. export class VRDistortionCorrectionPostProcess extends PostProcess {
  94293. private _isRightEye;
  94294. private _distortionFactors;
  94295. private _postProcessScaleFactor;
  94296. private _lensCenterOffset;
  94297. private _scaleIn;
  94298. private _scaleFactor;
  94299. private _lensCenter;
  94300. /**
  94301. * Initializes the VRDistortionCorrectionPostProcess
  94302. * @param name The name of the effect.
  94303. * @param camera The camera to apply the render pass to.
  94304. * @param isRightEye If this is for the right eye distortion
  94305. * @param vrMetrics All the required metrics for the VR camera
  94306. */
  94307. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  94308. }
  94309. }
  94310. declare module BABYLON {
  94311. /**
  94312. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  94313. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94314. */
  94315. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  94316. /**
  94317. * Creates a new VRDeviceOrientationArcRotateCamera
  94318. * @param name defines camera name
  94319. * @param alpha defines the camera rotation along the logitudinal axis
  94320. * @param beta defines the camera rotation along the latitudinal axis
  94321. * @param radius defines the camera distance from its target
  94322. * @param target defines the camera target
  94323. * @param scene defines the scene the camera belongs to
  94324. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94325. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94326. */
  94327. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94328. /**
  94329. * Gets camera class name
  94330. * @returns VRDeviceOrientationArcRotateCamera
  94331. */
  94332. getClassName(): string;
  94333. }
  94334. }
  94335. declare module BABYLON {
  94336. /**
  94337. * Camera used to simulate VR rendering (based on FreeCamera)
  94338. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94339. */
  94340. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  94341. /**
  94342. * Creates a new VRDeviceOrientationFreeCamera
  94343. * @param name defines camera name
  94344. * @param position defines the start position of the camera
  94345. * @param scene defines the scene the camera belongs to
  94346. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94347. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94348. */
  94349. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94350. /**
  94351. * Gets camera class name
  94352. * @returns VRDeviceOrientationFreeCamera
  94353. */
  94354. getClassName(): string;
  94355. }
  94356. }
  94357. declare module BABYLON {
  94358. /**
  94359. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  94360. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94361. */
  94362. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  94363. /**
  94364. * Creates a new VRDeviceOrientationGamepadCamera
  94365. * @param name defines camera name
  94366. * @param position defines the start position of the camera
  94367. * @param scene defines the scene the camera belongs to
  94368. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94369. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94370. */
  94371. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94372. /**
  94373. * Gets camera class name
  94374. * @returns VRDeviceOrientationGamepadCamera
  94375. */
  94376. getClassName(): string;
  94377. }
  94378. }
  94379. declare module BABYLON {
  94380. /**
  94381. * Defines supported buttons for XBox360 compatible gamepads
  94382. */
  94383. export enum Xbox360Button {
  94384. /** A */
  94385. A = 0,
  94386. /** B */
  94387. B = 1,
  94388. /** X */
  94389. X = 2,
  94390. /** Y */
  94391. Y = 3,
  94392. /** Start */
  94393. Start = 4,
  94394. /** Back */
  94395. Back = 5,
  94396. /** Left button */
  94397. LB = 6,
  94398. /** Right button */
  94399. RB = 7,
  94400. /** Left stick */
  94401. LeftStick = 8,
  94402. /** Right stick */
  94403. RightStick = 9
  94404. }
  94405. /** Defines values for XBox360 DPad */
  94406. export enum Xbox360Dpad {
  94407. /** Up */
  94408. Up = 0,
  94409. /** Down */
  94410. Down = 1,
  94411. /** Left */
  94412. Left = 2,
  94413. /** Right */
  94414. Right = 3
  94415. }
  94416. /**
  94417. * Defines a XBox360 gamepad
  94418. */
  94419. export class Xbox360Pad extends Gamepad {
  94420. private _leftTrigger;
  94421. private _rightTrigger;
  94422. private _onlefttriggerchanged;
  94423. private _onrighttriggerchanged;
  94424. private _onbuttondown;
  94425. private _onbuttonup;
  94426. private _ondpaddown;
  94427. private _ondpadup;
  94428. /** Observable raised when a button is pressed */
  94429. onButtonDownObservable: Observable<Xbox360Button>;
  94430. /** Observable raised when a button is released */
  94431. onButtonUpObservable: Observable<Xbox360Button>;
  94432. /** Observable raised when a pad is pressed */
  94433. onPadDownObservable: Observable<Xbox360Dpad>;
  94434. /** Observable raised when a pad is released */
  94435. onPadUpObservable: Observable<Xbox360Dpad>;
  94436. private _buttonA;
  94437. private _buttonB;
  94438. private _buttonX;
  94439. private _buttonY;
  94440. private _buttonBack;
  94441. private _buttonStart;
  94442. private _buttonLB;
  94443. private _buttonRB;
  94444. private _buttonLeftStick;
  94445. private _buttonRightStick;
  94446. private _dPadUp;
  94447. private _dPadDown;
  94448. private _dPadLeft;
  94449. private _dPadRight;
  94450. private _isXboxOnePad;
  94451. /**
  94452. * Creates a new XBox360 gamepad object
  94453. * @param id defines the id of this gamepad
  94454. * @param index defines its index
  94455. * @param gamepad defines the internal HTML gamepad object
  94456. * @param xboxOne defines if it is a XBox One gamepad
  94457. */
  94458. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  94459. /**
  94460. * Defines the callback to call when left trigger is pressed
  94461. * @param callback defines the callback to use
  94462. */
  94463. onlefttriggerchanged(callback: (value: number) => void): void;
  94464. /**
  94465. * Defines the callback to call when right trigger is pressed
  94466. * @param callback defines the callback to use
  94467. */
  94468. onrighttriggerchanged(callback: (value: number) => void): void;
  94469. /**
  94470. * Gets the left trigger value
  94471. */
  94472. /**
  94473. * Sets the left trigger value
  94474. */
  94475. leftTrigger: number;
  94476. /**
  94477. * Gets the right trigger value
  94478. */
  94479. /**
  94480. * Sets the right trigger value
  94481. */
  94482. rightTrigger: number;
  94483. /**
  94484. * Defines the callback to call when a button is pressed
  94485. * @param callback defines the callback to use
  94486. */
  94487. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  94488. /**
  94489. * Defines the callback to call when a button is released
  94490. * @param callback defines the callback to use
  94491. */
  94492. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  94493. /**
  94494. * Defines the callback to call when a pad is pressed
  94495. * @param callback defines the callback to use
  94496. */
  94497. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  94498. /**
  94499. * Defines the callback to call when a pad is released
  94500. * @param callback defines the callback to use
  94501. */
  94502. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  94503. private _setButtonValue;
  94504. private _setDPadValue;
  94505. /**
  94506. * Gets the value of the `A` button
  94507. */
  94508. /**
  94509. * Sets the value of the `A` button
  94510. */
  94511. buttonA: number;
  94512. /**
  94513. * Gets the value of the `B` button
  94514. */
  94515. /**
  94516. * Sets the value of the `B` button
  94517. */
  94518. buttonB: number;
  94519. /**
  94520. * Gets the value of the `X` button
  94521. */
  94522. /**
  94523. * Sets the value of the `X` button
  94524. */
  94525. buttonX: number;
  94526. /**
  94527. * Gets the value of the `Y` button
  94528. */
  94529. /**
  94530. * Sets the value of the `Y` button
  94531. */
  94532. buttonY: number;
  94533. /**
  94534. * Gets the value of the `Start` button
  94535. */
  94536. /**
  94537. * Sets the value of the `Start` button
  94538. */
  94539. buttonStart: number;
  94540. /**
  94541. * Gets the value of the `Back` button
  94542. */
  94543. /**
  94544. * Sets the value of the `Back` button
  94545. */
  94546. buttonBack: number;
  94547. /**
  94548. * Gets the value of the `Left` button
  94549. */
  94550. /**
  94551. * Sets the value of the `Left` button
  94552. */
  94553. buttonLB: number;
  94554. /**
  94555. * Gets the value of the `Right` button
  94556. */
  94557. /**
  94558. * Sets the value of the `Right` button
  94559. */
  94560. buttonRB: number;
  94561. /**
  94562. * Gets the value of the Left joystick
  94563. */
  94564. /**
  94565. * Sets the value of the Left joystick
  94566. */
  94567. buttonLeftStick: number;
  94568. /**
  94569. * Gets the value of the Right joystick
  94570. */
  94571. /**
  94572. * Sets the value of the Right joystick
  94573. */
  94574. buttonRightStick: number;
  94575. /**
  94576. * Gets the value of D-pad up
  94577. */
  94578. /**
  94579. * Sets the value of D-pad up
  94580. */
  94581. dPadUp: number;
  94582. /**
  94583. * Gets the value of D-pad down
  94584. */
  94585. /**
  94586. * Sets the value of D-pad down
  94587. */
  94588. dPadDown: number;
  94589. /**
  94590. * Gets the value of D-pad left
  94591. */
  94592. /**
  94593. * Sets the value of D-pad left
  94594. */
  94595. dPadLeft: number;
  94596. /**
  94597. * Gets the value of D-pad right
  94598. */
  94599. /**
  94600. * Sets the value of D-pad right
  94601. */
  94602. dPadRight: number;
  94603. /**
  94604. * Force the gamepad to synchronize with device values
  94605. */
  94606. update(): void;
  94607. /**
  94608. * Disposes the gamepad
  94609. */
  94610. dispose(): void;
  94611. }
  94612. }
  94613. declare module BABYLON {
  94614. /**
  94615. * Base class of materials working in push mode in babylon JS
  94616. * @hidden
  94617. */
  94618. export class PushMaterial extends Material {
  94619. protected _activeEffect: Effect;
  94620. protected _normalMatrix: Matrix;
  94621. /**
  94622. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  94623. * This means that the material can keep using a previous shader while a new one is being compiled.
  94624. * This is mostly used when shader parallel compilation is supported (true by default)
  94625. */
  94626. allowShaderHotSwapping: boolean;
  94627. constructor(name: string, scene: Scene);
  94628. getEffect(): Effect;
  94629. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94630. /**
  94631. * Binds the given world matrix to the active effect
  94632. *
  94633. * @param world the matrix to bind
  94634. */
  94635. bindOnlyWorldMatrix(world: Matrix): void;
  94636. /**
  94637. * Binds the given normal matrix to the active effect
  94638. *
  94639. * @param normalMatrix the matrix to bind
  94640. */
  94641. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94642. bind(world: Matrix, mesh?: Mesh): void;
  94643. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94644. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94645. }
  94646. }
  94647. declare module BABYLON {
  94648. /**
  94649. * This groups all the flags used to control the materials channel.
  94650. */
  94651. export class MaterialFlags {
  94652. private static _DiffuseTextureEnabled;
  94653. /**
  94654. * Are diffuse textures enabled in the application.
  94655. */
  94656. static DiffuseTextureEnabled: boolean;
  94657. private static _AmbientTextureEnabled;
  94658. /**
  94659. * Are ambient textures enabled in the application.
  94660. */
  94661. static AmbientTextureEnabled: boolean;
  94662. private static _OpacityTextureEnabled;
  94663. /**
  94664. * Are opacity textures enabled in the application.
  94665. */
  94666. static OpacityTextureEnabled: boolean;
  94667. private static _ReflectionTextureEnabled;
  94668. /**
  94669. * Are reflection textures enabled in the application.
  94670. */
  94671. static ReflectionTextureEnabled: boolean;
  94672. private static _EmissiveTextureEnabled;
  94673. /**
  94674. * Are emissive textures enabled in the application.
  94675. */
  94676. static EmissiveTextureEnabled: boolean;
  94677. private static _SpecularTextureEnabled;
  94678. /**
  94679. * Are specular textures enabled in the application.
  94680. */
  94681. static SpecularTextureEnabled: boolean;
  94682. private static _BumpTextureEnabled;
  94683. /**
  94684. * Are bump textures enabled in the application.
  94685. */
  94686. static BumpTextureEnabled: boolean;
  94687. private static _LightmapTextureEnabled;
  94688. /**
  94689. * Are lightmap textures enabled in the application.
  94690. */
  94691. static LightmapTextureEnabled: boolean;
  94692. private static _RefractionTextureEnabled;
  94693. /**
  94694. * Are refraction textures enabled in the application.
  94695. */
  94696. static RefractionTextureEnabled: boolean;
  94697. private static _ColorGradingTextureEnabled;
  94698. /**
  94699. * Are color grading textures enabled in the application.
  94700. */
  94701. static ColorGradingTextureEnabled: boolean;
  94702. private static _FresnelEnabled;
  94703. /**
  94704. * Are fresnels enabled in the application.
  94705. */
  94706. static FresnelEnabled: boolean;
  94707. private static _ClearCoatTextureEnabled;
  94708. /**
  94709. * Are clear coat textures enabled in the application.
  94710. */
  94711. static ClearCoatTextureEnabled: boolean;
  94712. private static _ClearCoatBumpTextureEnabled;
  94713. /**
  94714. * Are clear coat bump textures enabled in the application.
  94715. */
  94716. static ClearCoatBumpTextureEnabled: boolean;
  94717. private static _ClearCoatTintTextureEnabled;
  94718. /**
  94719. * Are clear coat tint textures enabled in the application.
  94720. */
  94721. static ClearCoatTintTextureEnabled: boolean;
  94722. }
  94723. }
  94724. declare module BABYLON {
  94725. /** @hidden */
  94726. export var defaultFragmentDeclaration: {
  94727. name: string;
  94728. shader: string;
  94729. };
  94730. }
  94731. declare module BABYLON {
  94732. /** @hidden */
  94733. export var defaultUboDeclaration: {
  94734. name: string;
  94735. shader: string;
  94736. };
  94737. }
  94738. declare module BABYLON {
  94739. /** @hidden */
  94740. export var lightFragmentDeclaration: {
  94741. name: string;
  94742. shader: string;
  94743. };
  94744. }
  94745. declare module BABYLON {
  94746. /** @hidden */
  94747. export var lightUboDeclaration: {
  94748. name: string;
  94749. shader: string;
  94750. };
  94751. }
  94752. declare module BABYLON {
  94753. /** @hidden */
  94754. export var lightsFragmentFunctions: {
  94755. name: string;
  94756. shader: string;
  94757. };
  94758. }
  94759. declare module BABYLON {
  94760. /** @hidden */
  94761. export var shadowsFragmentFunctions: {
  94762. name: string;
  94763. shader: string;
  94764. };
  94765. }
  94766. declare module BABYLON {
  94767. /** @hidden */
  94768. export var fresnelFunction: {
  94769. name: string;
  94770. shader: string;
  94771. };
  94772. }
  94773. declare module BABYLON {
  94774. /** @hidden */
  94775. export var reflectionFunction: {
  94776. name: string;
  94777. shader: string;
  94778. };
  94779. }
  94780. declare module BABYLON {
  94781. /** @hidden */
  94782. export var bumpFragmentFunctions: {
  94783. name: string;
  94784. shader: string;
  94785. };
  94786. }
  94787. declare module BABYLON {
  94788. /** @hidden */
  94789. export var logDepthDeclaration: {
  94790. name: string;
  94791. shader: string;
  94792. };
  94793. }
  94794. declare module BABYLON {
  94795. /** @hidden */
  94796. export var bumpFragment: {
  94797. name: string;
  94798. shader: string;
  94799. };
  94800. }
  94801. declare module BABYLON {
  94802. /** @hidden */
  94803. export var depthPrePass: {
  94804. name: string;
  94805. shader: string;
  94806. };
  94807. }
  94808. declare module BABYLON {
  94809. /** @hidden */
  94810. export var lightFragment: {
  94811. name: string;
  94812. shader: string;
  94813. };
  94814. }
  94815. declare module BABYLON {
  94816. /** @hidden */
  94817. export var logDepthFragment: {
  94818. name: string;
  94819. shader: string;
  94820. };
  94821. }
  94822. declare module BABYLON {
  94823. /** @hidden */
  94824. export var defaultPixelShader: {
  94825. name: string;
  94826. shader: string;
  94827. };
  94828. }
  94829. declare module BABYLON {
  94830. /** @hidden */
  94831. export var defaultVertexDeclaration: {
  94832. name: string;
  94833. shader: string;
  94834. };
  94835. }
  94836. declare module BABYLON {
  94837. /** @hidden */
  94838. export var bumpVertexDeclaration: {
  94839. name: string;
  94840. shader: string;
  94841. };
  94842. }
  94843. declare module BABYLON {
  94844. /** @hidden */
  94845. export var bumpVertex: {
  94846. name: string;
  94847. shader: string;
  94848. };
  94849. }
  94850. declare module BABYLON {
  94851. /** @hidden */
  94852. export var fogVertex: {
  94853. name: string;
  94854. shader: string;
  94855. };
  94856. }
  94857. declare module BABYLON {
  94858. /** @hidden */
  94859. export var shadowsVertex: {
  94860. name: string;
  94861. shader: string;
  94862. };
  94863. }
  94864. declare module BABYLON {
  94865. /** @hidden */
  94866. export var pointCloudVertex: {
  94867. name: string;
  94868. shader: string;
  94869. };
  94870. }
  94871. declare module BABYLON {
  94872. /** @hidden */
  94873. export var logDepthVertex: {
  94874. name: string;
  94875. shader: string;
  94876. };
  94877. }
  94878. declare module BABYLON {
  94879. /** @hidden */
  94880. export var defaultVertexShader: {
  94881. name: string;
  94882. shader: string;
  94883. };
  94884. }
  94885. declare module BABYLON {
  94886. /** @hidden */
  94887. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  94888. MAINUV1: boolean;
  94889. MAINUV2: boolean;
  94890. DIFFUSE: boolean;
  94891. DIFFUSEDIRECTUV: number;
  94892. AMBIENT: boolean;
  94893. AMBIENTDIRECTUV: number;
  94894. OPACITY: boolean;
  94895. OPACITYDIRECTUV: number;
  94896. OPACITYRGB: boolean;
  94897. REFLECTION: boolean;
  94898. EMISSIVE: boolean;
  94899. EMISSIVEDIRECTUV: number;
  94900. SPECULAR: boolean;
  94901. SPECULARDIRECTUV: number;
  94902. BUMP: boolean;
  94903. BUMPDIRECTUV: number;
  94904. PARALLAX: boolean;
  94905. PARALLAXOCCLUSION: boolean;
  94906. SPECULAROVERALPHA: boolean;
  94907. CLIPPLANE: boolean;
  94908. CLIPPLANE2: boolean;
  94909. CLIPPLANE3: boolean;
  94910. CLIPPLANE4: boolean;
  94911. ALPHATEST: boolean;
  94912. DEPTHPREPASS: boolean;
  94913. ALPHAFROMDIFFUSE: boolean;
  94914. POINTSIZE: boolean;
  94915. FOG: boolean;
  94916. SPECULARTERM: boolean;
  94917. DIFFUSEFRESNEL: boolean;
  94918. OPACITYFRESNEL: boolean;
  94919. REFLECTIONFRESNEL: boolean;
  94920. REFRACTIONFRESNEL: boolean;
  94921. EMISSIVEFRESNEL: boolean;
  94922. FRESNEL: boolean;
  94923. NORMAL: boolean;
  94924. UV1: boolean;
  94925. UV2: boolean;
  94926. VERTEXCOLOR: boolean;
  94927. VERTEXALPHA: boolean;
  94928. NUM_BONE_INFLUENCERS: number;
  94929. BonesPerMesh: number;
  94930. BONETEXTURE: boolean;
  94931. INSTANCES: boolean;
  94932. GLOSSINESS: boolean;
  94933. ROUGHNESS: boolean;
  94934. EMISSIVEASILLUMINATION: boolean;
  94935. LINKEMISSIVEWITHDIFFUSE: boolean;
  94936. REFLECTIONFRESNELFROMSPECULAR: boolean;
  94937. LIGHTMAP: boolean;
  94938. LIGHTMAPDIRECTUV: number;
  94939. OBJECTSPACE_NORMALMAP: boolean;
  94940. USELIGHTMAPASSHADOWMAP: boolean;
  94941. REFLECTIONMAP_3D: boolean;
  94942. REFLECTIONMAP_SPHERICAL: boolean;
  94943. REFLECTIONMAP_PLANAR: boolean;
  94944. REFLECTIONMAP_CUBIC: boolean;
  94945. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  94946. REFLECTIONMAP_PROJECTION: boolean;
  94947. REFLECTIONMAP_SKYBOX: boolean;
  94948. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  94949. REFLECTIONMAP_EXPLICIT: boolean;
  94950. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  94951. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  94952. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  94953. INVERTCUBICMAP: boolean;
  94954. LOGARITHMICDEPTH: boolean;
  94955. REFRACTION: boolean;
  94956. REFRACTIONMAP_3D: boolean;
  94957. REFLECTIONOVERALPHA: boolean;
  94958. TWOSIDEDLIGHTING: boolean;
  94959. SHADOWFLOAT: boolean;
  94960. MORPHTARGETS: boolean;
  94961. MORPHTARGETS_NORMAL: boolean;
  94962. MORPHTARGETS_TANGENT: boolean;
  94963. NUM_MORPH_INFLUENCERS: number;
  94964. NONUNIFORMSCALING: boolean;
  94965. PREMULTIPLYALPHA: boolean;
  94966. IMAGEPROCESSING: boolean;
  94967. VIGNETTE: boolean;
  94968. VIGNETTEBLENDMODEMULTIPLY: boolean;
  94969. VIGNETTEBLENDMODEOPAQUE: boolean;
  94970. TONEMAPPING: boolean;
  94971. TONEMAPPING_ACES: boolean;
  94972. CONTRAST: boolean;
  94973. COLORCURVES: boolean;
  94974. COLORGRADING: boolean;
  94975. COLORGRADING3D: boolean;
  94976. SAMPLER3DGREENDEPTH: boolean;
  94977. SAMPLER3DBGRMAP: boolean;
  94978. IMAGEPROCESSINGPOSTPROCESS: boolean;
  94979. /**
  94980. * If the reflection texture on this material is in linear color space
  94981. * @hidden
  94982. */
  94983. IS_REFLECTION_LINEAR: boolean;
  94984. /**
  94985. * If the refraction texture on this material is in linear color space
  94986. * @hidden
  94987. */
  94988. IS_REFRACTION_LINEAR: boolean;
  94989. EXPOSURE: boolean;
  94990. constructor();
  94991. setReflectionMode(modeToEnable: string): void;
  94992. }
  94993. /**
  94994. * This is the default material used in Babylon. It is the best trade off between quality
  94995. * and performances.
  94996. * @see http://doc.babylonjs.com/babylon101/materials
  94997. */
  94998. export class StandardMaterial extends PushMaterial {
  94999. private _diffuseTexture;
  95000. /**
  95001. * The basic texture of the material as viewed under a light.
  95002. */
  95003. diffuseTexture: Nullable<BaseTexture>;
  95004. private _ambientTexture;
  95005. /**
  95006. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  95007. */
  95008. ambientTexture: Nullable<BaseTexture>;
  95009. private _opacityTexture;
  95010. /**
  95011. * Define the transparency of the material from a texture.
  95012. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  95013. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  95014. */
  95015. opacityTexture: Nullable<BaseTexture>;
  95016. private _reflectionTexture;
  95017. /**
  95018. * Define the texture used to display the reflection.
  95019. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95020. */
  95021. reflectionTexture: Nullable<BaseTexture>;
  95022. private _emissiveTexture;
  95023. /**
  95024. * Define texture of the material as if self lit.
  95025. * This will be mixed in the final result even in the absence of light.
  95026. */
  95027. emissiveTexture: Nullable<BaseTexture>;
  95028. private _specularTexture;
  95029. /**
  95030. * Define how the color and intensity of the highlight given by the light in the material.
  95031. */
  95032. specularTexture: Nullable<BaseTexture>;
  95033. private _bumpTexture;
  95034. /**
  95035. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  95036. * 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.
  95037. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  95038. */
  95039. bumpTexture: Nullable<BaseTexture>;
  95040. private _lightmapTexture;
  95041. /**
  95042. * Complex lighting can be computationally expensive to compute at runtime.
  95043. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  95044. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  95045. */
  95046. lightmapTexture: Nullable<BaseTexture>;
  95047. private _refractionTexture;
  95048. /**
  95049. * Define the texture used to display the refraction.
  95050. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95051. */
  95052. refractionTexture: Nullable<BaseTexture>;
  95053. /**
  95054. * The color of the material lit by the environmental background lighting.
  95055. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  95056. */
  95057. ambientColor: Color3;
  95058. /**
  95059. * The basic color of the material as viewed under a light.
  95060. */
  95061. diffuseColor: Color3;
  95062. /**
  95063. * Define how the color and intensity of the highlight given by the light in the material.
  95064. */
  95065. specularColor: Color3;
  95066. /**
  95067. * Define the color of the material as if self lit.
  95068. * This will be mixed in the final result even in the absence of light.
  95069. */
  95070. emissiveColor: Color3;
  95071. /**
  95072. * Defines how sharp are the highlights in the material.
  95073. * The bigger the value the sharper giving a more glossy feeling to the result.
  95074. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95075. */
  95076. specularPower: number;
  95077. private _useAlphaFromDiffuseTexture;
  95078. /**
  95079. * Does the transparency come from the diffuse texture alpha channel.
  95080. */
  95081. useAlphaFromDiffuseTexture: boolean;
  95082. private _useEmissiveAsIllumination;
  95083. /**
  95084. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95085. */
  95086. useEmissiveAsIllumination: boolean;
  95087. private _linkEmissiveWithDiffuse;
  95088. /**
  95089. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95090. * the emissive level when the final color is close to one.
  95091. */
  95092. linkEmissiveWithDiffuse: boolean;
  95093. private _useSpecularOverAlpha;
  95094. /**
  95095. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95096. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95097. */
  95098. useSpecularOverAlpha: boolean;
  95099. private _useReflectionOverAlpha;
  95100. /**
  95101. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95102. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95103. */
  95104. useReflectionOverAlpha: boolean;
  95105. private _disableLighting;
  95106. /**
  95107. * Does lights from the scene impacts this material.
  95108. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95109. */
  95110. disableLighting: boolean;
  95111. private _useObjectSpaceNormalMap;
  95112. /**
  95113. * Allows using an object space normal map (instead of tangent space).
  95114. */
  95115. useObjectSpaceNormalMap: boolean;
  95116. private _useParallax;
  95117. /**
  95118. * Is parallax enabled or not.
  95119. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95120. */
  95121. useParallax: boolean;
  95122. private _useParallaxOcclusion;
  95123. /**
  95124. * Is parallax occlusion enabled or not.
  95125. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95126. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95127. */
  95128. useParallaxOcclusion: boolean;
  95129. /**
  95130. * 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.
  95131. */
  95132. parallaxScaleBias: number;
  95133. private _roughness;
  95134. /**
  95135. * Helps to define how blurry the reflections should appears in the material.
  95136. */
  95137. roughness: number;
  95138. /**
  95139. * In case of refraction, define the value of the indice of refraction.
  95140. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95141. */
  95142. indexOfRefraction: number;
  95143. /**
  95144. * Invert the refraction texture alongside the y axis.
  95145. * It can be useful with procedural textures or probe for instance.
  95146. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95147. */
  95148. invertRefractionY: boolean;
  95149. /**
  95150. * Defines the alpha limits in alpha test mode.
  95151. */
  95152. alphaCutOff: number;
  95153. private _useLightmapAsShadowmap;
  95154. /**
  95155. * In case of light mapping, define whether the map contains light or shadow informations.
  95156. */
  95157. useLightmapAsShadowmap: boolean;
  95158. private _diffuseFresnelParameters;
  95159. /**
  95160. * Define the diffuse fresnel parameters of the material.
  95161. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95162. */
  95163. diffuseFresnelParameters: FresnelParameters;
  95164. private _opacityFresnelParameters;
  95165. /**
  95166. * Define the opacity fresnel parameters of the material.
  95167. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95168. */
  95169. opacityFresnelParameters: FresnelParameters;
  95170. private _reflectionFresnelParameters;
  95171. /**
  95172. * Define the reflection fresnel parameters of the material.
  95173. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95174. */
  95175. reflectionFresnelParameters: FresnelParameters;
  95176. private _refractionFresnelParameters;
  95177. /**
  95178. * Define the refraction fresnel parameters of the material.
  95179. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95180. */
  95181. refractionFresnelParameters: FresnelParameters;
  95182. private _emissiveFresnelParameters;
  95183. /**
  95184. * Define the emissive fresnel parameters of the material.
  95185. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95186. */
  95187. emissiveFresnelParameters: FresnelParameters;
  95188. private _useReflectionFresnelFromSpecular;
  95189. /**
  95190. * If true automatically deducts the fresnels values from the material specularity.
  95191. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95192. */
  95193. useReflectionFresnelFromSpecular: boolean;
  95194. private _useGlossinessFromSpecularMapAlpha;
  95195. /**
  95196. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95197. */
  95198. useGlossinessFromSpecularMapAlpha: boolean;
  95199. private _maxSimultaneousLights;
  95200. /**
  95201. * Defines the maximum number of lights that can be used in the material
  95202. */
  95203. maxSimultaneousLights: number;
  95204. private _invertNormalMapX;
  95205. /**
  95206. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95207. */
  95208. invertNormalMapX: boolean;
  95209. private _invertNormalMapY;
  95210. /**
  95211. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95212. */
  95213. invertNormalMapY: boolean;
  95214. private _twoSidedLighting;
  95215. /**
  95216. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95217. */
  95218. twoSidedLighting: boolean;
  95219. /**
  95220. * Default configuration related to image processing available in the standard Material.
  95221. */
  95222. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95223. /**
  95224. * Gets the image processing configuration used either in this material.
  95225. */
  95226. /**
  95227. * Sets the Default image processing configuration used either in the this material.
  95228. *
  95229. * If sets to null, the scene one is in use.
  95230. */
  95231. imageProcessingConfiguration: ImageProcessingConfiguration;
  95232. /**
  95233. * Keep track of the image processing observer to allow dispose and replace.
  95234. */
  95235. private _imageProcessingObserver;
  95236. /**
  95237. * Attaches a new image processing configuration to the Standard Material.
  95238. * @param configuration
  95239. */
  95240. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95241. /**
  95242. * Gets wether the color curves effect is enabled.
  95243. */
  95244. /**
  95245. * Sets wether the color curves effect is enabled.
  95246. */
  95247. cameraColorCurvesEnabled: boolean;
  95248. /**
  95249. * Gets wether the color grading effect is enabled.
  95250. */
  95251. /**
  95252. * Gets wether the color grading effect is enabled.
  95253. */
  95254. cameraColorGradingEnabled: boolean;
  95255. /**
  95256. * Gets wether tonemapping is enabled or not.
  95257. */
  95258. /**
  95259. * Sets wether tonemapping is enabled or not
  95260. */
  95261. cameraToneMappingEnabled: boolean;
  95262. /**
  95263. * The camera exposure used on this material.
  95264. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95265. * This corresponds to a photographic exposure.
  95266. */
  95267. /**
  95268. * The camera exposure used on this material.
  95269. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95270. * This corresponds to a photographic exposure.
  95271. */
  95272. cameraExposure: number;
  95273. /**
  95274. * Gets The camera contrast used on this material.
  95275. */
  95276. /**
  95277. * Sets The camera contrast used on this material.
  95278. */
  95279. cameraContrast: number;
  95280. /**
  95281. * Gets the Color Grading 2D Lookup Texture.
  95282. */
  95283. /**
  95284. * Sets the Color Grading 2D Lookup Texture.
  95285. */
  95286. cameraColorGradingTexture: Nullable<BaseTexture>;
  95287. /**
  95288. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95289. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95290. * 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;
  95291. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95292. */
  95293. /**
  95294. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95295. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95296. * 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;
  95297. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95298. */
  95299. cameraColorCurves: Nullable<ColorCurves>;
  95300. /**
  95301. * Custom callback helping to override the default shader used in the material.
  95302. */
  95303. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95304. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95305. protected _worldViewProjectionMatrix: Matrix;
  95306. protected _globalAmbientColor: Color3;
  95307. protected _useLogarithmicDepth: boolean;
  95308. /**
  95309. * Instantiates a new standard material.
  95310. * This is the default material used in Babylon. It is the best trade off between quality
  95311. * and performances.
  95312. * @see http://doc.babylonjs.com/babylon101/materials
  95313. * @param name Define the name of the material in the scene
  95314. * @param scene Define the scene the material belong to
  95315. */
  95316. constructor(name: string, scene: Scene);
  95317. /**
  95318. * Gets a boolean indicating that current material needs to register RTT
  95319. */
  95320. readonly hasRenderTargetTextures: boolean;
  95321. /**
  95322. * Gets the current class name of the material e.g. "StandardMaterial"
  95323. * Mainly use in serialization.
  95324. * @returns the class name
  95325. */
  95326. getClassName(): string;
  95327. /**
  95328. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95329. * You can try switching to logarithmic depth.
  95330. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95331. */
  95332. useLogarithmicDepth: boolean;
  95333. /**
  95334. * Specifies if the material will require alpha blending
  95335. * @returns a boolean specifying if alpha blending is needed
  95336. */
  95337. needAlphaBlending(): boolean;
  95338. /**
  95339. * Specifies if this material should be rendered in alpha test mode
  95340. * @returns a boolean specifying if an alpha test is needed.
  95341. */
  95342. needAlphaTesting(): boolean;
  95343. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95344. /**
  95345. * Get the texture used for alpha test purpose.
  95346. * @returns the diffuse texture in case of the standard material.
  95347. */
  95348. getAlphaTestTexture(): Nullable<BaseTexture>;
  95349. /**
  95350. * Get if the submesh is ready to be used and all its information available.
  95351. * Child classes can use it to update shaders
  95352. * @param mesh defines the mesh to check
  95353. * @param subMesh defines which submesh to check
  95354. * @param useInstances specifies that instances should be used
  95355. * @returns a boolean indicating that the submesh is ready or not
  95356. */
  95357. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95358. /**
  95359. * Builds the material UBO layouts.
  95360. * Used internally during the effect preparation.
  95361. */
  95362. buildUniformLayout(): void;
  95363. /**
  95364. * Unbinds the material from the mesh
  95365. */
  95366. unbind(): void;
  95367. /**
  95368. * Binds the submesh to this material by preparing the effect and shader to draw
  95369. * @param world defines the world transformation matrix
  95370. * @param mesh defines the mesh containing the submesh
  95371. * @param subMesh defines the submesh to bind the material to
  95372. */
  95373. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95374. /**
  95375. * Get the list of animatables in the material.
  95376. * @returns the list of animatables object used in the material
  95377. */
  95378. getAnimatables(): IAnimatable[];
  95379. /**
  95380. * Gets the active textures from the material
  95381. * @returns an array of textures
  95382. */
  95383. getActiveTextures(): BaseTexture[];
  95384. /**
  95385. * Specifies if the material uses a texture
  95386. * @param texture defines the texture to check against the material
  95387. * @returns a boolean specifying if the material uses the texture
  95388. */
  95389. hasTexture(texture: BaseTexture): boolean;
  95390. /**
  95391. * Disposes the material
  95392. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95393. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95394. */
  95395. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95396. /**
  95397. * Makes a duplicate of the material, and gives it a new name
  95398. * @param name defines the new name for the duplicated material
  95399. * @returns the cloned material
  95400. */
  95401. clone(name: string): StandardMaterial;
  95402. /**
  95403. * Serializes this material in a JSON representation
  95404. * @returns the serialized material object
  95405. */
  95406. serialize(): any;
  95407. /**
  95408. * Creates a standard material from parsed material data
  95409. * @param source defines the JSON representation of the material
  95410. * @param scene defines the hosting scene
  95411. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95412. * @returns a new standard material
  95413. */
  95414. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95415. /**
  95416. * Are diffuse textures enabled in the application.
  95417. */
  95418. static DiffuseTextureEnabled: boolean;
  95419. /**
  95420. * Are ambient textures enabled in the application.
  95421. */
  95422. static AmbientTextureEnabled: boolean;
  95423. /**
  95424. * Are opacity textures enabled in the application.
  95425. */
  95426. static OpacityTextureEnabled: boolean;
  95427. /**
  95428. * Are reflection textures enabled in the application.
  95429. */
  95430. static ReflectionTextureEnabled: boolean;
  95431. /**
  95432. * Are emissive textures enabled in the application.
  95433. */
  95434. static EmissiveTextureEnabled: boolean;
  95435. /**
  95436. * Are specular textures enabled in the application.
  95437. */
  95438. static SpecularTextureEnabled: boolean;
  95439. /**
  95440. * Are bump textures enabled in the application.
  95441. */
  95442. static BumpTextureEnabled: boolean;
  95443. /**
  95444. * Are lightmap textures enabled in the application.
  95445. */
  95446. static LightmapTextureEnabled: boolean;
  95447. /**
  95448. * Are refraction textures enabled in the application.
  95449. */
  95450. static RefractionTextureEnabled: boolean;
  95451. /**
  95452. * Are color grading textures enabled in the application.
  95453. */
  95454. static ColorGradingTextureEnabled: boolean;
  95455. /**
  95456. * Are fresnels enabled in the application.
  95457. */
  95458. static FresnelEnabled: boolean;
  95459. }
  95460. }
  95461. declare module BABYLON {
  95462. /**
  95463. * A class extending Texture allowing drawing on a texture
  95464. * @see http://doc.babylonjs.com/how_to/dynamictexture
  95465. */
  95466. export class DynamicTexture extends Texture {
  95467. private _generateMipMaps;
  95468. private _canvas;
  95469. private _context;
  95470. private _engine;
  95471. /**
  95472. * Creates a DynamicTexture
  95473. * @param name defines the name of the texture
  95474. * @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
  95475. * @param scene defines the scene where you want the texture
  95476. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  95477. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  95478. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  95479. */
  95480. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  95481. /**
  95482. * Get the current class name of the texture useful for serialization or dynamic coding.
  95483. * @returns "DynamicTexture"
  95484. */
  95485. getClassName(): string;
  95486. /**
  95487. * Gets the current state of canRescale
  95488. */
  95489. readonly canRescale: boolean;
  95490. private _recreate;
  95491. /**
  95492. * Scales the texture
  95493. * @param ratio the scale factor to apply to both width and height
  95494. */
  95495. scale(ratio: number): void;
  95496. /**
  95497. * Resizes the texture
  95498. * @param width the new width
  95499. * @param height the new height
  95500. */
  95501. scaleTo(width: number, height: number): void;
  95502. /**
  95503. * Gets the context of the canvas used by the texture
  95504. * @returns the canvas context of the dynamic texture
  95505. */
  95506. getContext(): CanvasRenderingContext2D;
  95507. /**
  95508. * Clears the texture
  95509. */
  95510. clear(): void;
  95511. /**
  95512. * Updates the texture
  95513. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95514. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  95515. */
  95516. update(invertY?: boolean, premulAlpha?: boolean): void;
  95517. /**
  95518. * Draws text onto the texture
  95519. * @param text defines the text to be drawn
  95520. * @param x defines the placement of the text from the left
  95521. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  95522. * @param font defines the font to be used with font-style, font-size, font-name
  95523. * @param color defines the color used for the text
  95524. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  95525. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95526. * @param update defines whether texture is immediately update (default is true)
  95527. */
  95528. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  95529. /**
  95530. * Clones the texture
  95531. * @returns the clone of the texture.
  95532. */
  95533. clone(): DynamicTexture;
  95534. /**
  95535. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  95536. * @returns a serialized dynamic texture object
  95537. */
  95538. serialize(): any;
  95539. /** @hidden */
  95540. _rebuild(): void;
  95541. }
  95542. }
  95543. declare module BABYLON {
  95544. /** @hidden */
  95545. export var imageProcessingPixelShader: {
  95546. name: string;
  95547. shader: string;
  95548. };
  95549. }
  95550. declare module BABYLON {
  95551. /**
  95552. * ImageProcessingPostProcess
  95553. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  95554. */
  95555. export class ImageProcessingPostProcess extends PostProcess {
  95556. /**
  95557. * Default configuration related to image processing available in the PBR Material.
  95558. */
  95559. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95560. /**
  95561. * Gets the image processing configuration used either in this material.
  95562. */
  95563. /**
  95564. * Sets the Default image processing configuration used either in the this material.
  95565. *
  95566. * If sets to null, the scene one is in use.
  95567. */
  95568. imageProcessingConfiguration: ImageProcessingConfiguration;
  95569. /**
  95570. * Keep track of the image processing observer to allow dispose and replace.
  95571. */
  95572. private _imageProcessingObserver;
  95573. /**
  95574. * Attaches a new image processing configuration to the PBR Material.
  95575. * @param configuration
  95576. */
  95577. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  95578. /**
  95579. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95580. */
  95581. /**
  95582. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95583. */
  95584. colorCurves: Nullable<ColorCurves>;
  95585. /**
  95586. * Gets wether the color curves effect is enabled.
  95587. */
  95588. /**
  95589. * Sets wether the color curves effect is enabled.
  95590. */
  95591. colorCurvesEnabled: boolean;
  95592. /**
  95593. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95594. */
  95595. /**
  95596. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95597. */
  95598. colorGradingTexture: Nullable<BaseTexture>;
  95599. /**
  95600. * Gets wether the color grading effect is enabled.
  95601. */
  95602. /**
  95603. * Gets wether the color grading effect is enabled.
  95604. */
  95605. colorGradingEnabled: boolean;
  95606. /**
  95607. * Gets exposure used in the effect.
  95608. */
  95609. /**
  95610. * Sets exposure used in the effect.
  95611. */
  95612. exposure: number;
  95613. /**
  95614. * Gets wether tonemapping is enabled or not.
  95615. */
  95616. /**
  95617. * Sets wether tonemapping is enabled or not
  95618. */
  95619. toneMappingEnabled: boolean;
  95620. /**
  95621. * Gets the type of tone mapping effect.
  95622. */
  95623. /**
  95624. * Sets the type of tone mapping effect.
  95625. */
  95626. toneMappingType: number;
  95627. /**
  95628. * Gets contrast used in the effect.
  95629. */
  95630. /**
  95631. * Sets contrast used in the effect.
  95632. */
  95633. contrast: number;
  95634. /**
  95635. * Gets Vignette stretch size.
  95636. */
  95637. /**
  95638. * Sets Vignette stretch size.
  95639. */
  95640. vignetteStretch: number;
  95641. /**
  95642. * Gets Vignette centre X Offset.
  95643. */
  95644. /**
  95645. * Sets Vignette centre X Offset.
  95646. */
  95647. vignetteCentreX: number;
  95648. /**
  95649. * Gets Vignette centre Y Offset.
  95650. */
  95651. /**
  95652. * Sets Vignette centre Y Offset.
  95653. */
  95654. vignetteCentreY: number;
  95655. /**
  95656. * Gets Vignette weight or intensity of the vignette effect.
  95657. */
  95658. /**
  95659. * Sets Vignette weight or intensity of the vignette effect.
  95660. */
  95661. vignetteWeight: number;
  95662. /**
  95663. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  95664. * if vignetteEnabled is set to true.
  95665. */
  95666. /**
  95667. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  95668. * if vignetteEnabled is set to true.
  95669. */
  95670. vignetteColor: Color4;
  95671. /**
  95672. * Gets Camera field of view used by the Vignette effect.
  95673. */
  95674. /**
  95675. * Sets Camera field of view used by the Vignette effect.
  95676. */
  95677. vignetteCameraFov: number;
  95678. /**
  95679. * Gets the vignette blend mode allowing different kind of effect.
  95680. */
  95681. /**
  95682. * Sets the vignette blend mode allowing different kind of effect.
  95683. */
  95684. vignetteBlendMode: number;
  95685. /**
  95686. * Gets wether the vignette effect is enabled.
  95687. */
  95688. /**
  95689. * Sets wether the vignette effect is enabled.
  95690. */
  95691. vignetteEnabled: boolean;
  95692. private _fromLinearSpace;
  95693. /**
  95694. * Gets wether the input of the processing is in Gamma or Linear Space.
  95695. */
  95696. /**
  95697. * Sets wether the input of the processing is in Gamma or Linear Space.
  95698. */
  95699. fromLinearSpace: boolean;
  95700. /**
  95701. * Defines cache preventing GC.
  95702. */
  95703. private _defines;
  95704. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  95705. /**
  95706. * "ImageProcessingPostProcess"
  95707. * @returns "ImageProcessingPostProcess"
  95708. */
  95709. getClassName(): string;
  95710. protected _updateParameters(): void;
  95711. dispose(camera?: Camera): void;
  95712. }
  95713. }
  95714. declare module BABYLON {
  95715. /**
  95716. * Class containing static functions to help procedurally build meshes
  95717. */
  95718. export class GroundBuilder {
  95719. /**
  95720. * Creates a ground mesh
  95721. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  95722. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  95723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95724. * @param name defines the name of the mesh
  95725. * @param options defines the options used to create the mesh
  95726. * @param scene defines the hosting scene
  95727. * @returns the ground mesh
  95728. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  95729. */
  95730. static CreateGround(name: string, options: {
  95731. width?: number;
  95732. height?: number;
  95733. subdivisions?: number;
  95734. subdivisionsX?: number;
  95735. subdivisionsY?: number;
  95736. updatable?: boolean;
  95737. }, scene: any): Mesh;
  95738. /**
  95739. * Creates a tiled ground mesh
  95740. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  95741. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  95742. * * 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
  95743. * * 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
  95744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95745. * @param name defines the name of the mesh
  95746. * @param options defines the options used to create the mesh
  95747. * @param scene defines the hosting scene
  95748. * @returns the tiled ground mesh
  95749. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  95750. */
  95751. static CreateTiledGround(name: string, options: {
  95752. xmin: number;
  95753. zmin: number;
  95754. xmax: number;
  95755. zmax: number;
  95756. subdivisions?: {
  95757. w: number;
  95758. h: number;
  95759. };
  95760. precision?: {
  95761. w: number;
  95762. h: number;
  95763. };
  95764. updatable?: boolean;
  95765. }, scene: Scene): Mesh;
  95766. /**
  95767. * Creates a ground mesh from a height map
  95768. * * The parameter `url` sets the URL of the height map image resource.
  95769. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  95770. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  95771. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  95772. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  95773. * * 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.
  95774. * * 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).
  95775. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  95776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95777. * @param name defines the name of the mesh
  95778. * @param url defines the url to the height map
  95779. * @param options defines the options used to create the mesh
  95780. * @param scene defines the hosting scene
  95781. * @returns the ground mesh
  95782. * @see https://doc.babylonjs.com/babylon101/height_map
  95783. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  95784. */
  95785. static CreateGroundFromHeightMap(name: string, url: string, options: {
  95786. width?: number;
  95787. height?: number;
  95788. subdivisions?: number;
  95789. minHeight?: number;
  95790. maxHeight?: number;
  95791. colorFilter?: Color3;
  95792. alphaFilter?: number;
  95793. updatable?: boolean;
  95794. onReady?: (mesh: GroundMesh) => void;
  95795. }, scene: Scene): GroundMesh;
  95796. }
  95797. }
  95798. declare module BABYLON {
  95799. /**
  95800. * Class containing static functions to help procedurally build meshes
  95801. */
  95802. export class TorusBuilder {
  95803. /**
  95804. * Creates a torus mesh
  95805. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  95806. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  95807. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  95808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95811. * @param name defines the name of the mesh
  95812. * @param options defines the options used to create the mesh
  95813. * @param scene defines the hosting scene
  95814. * @returns the torus mesh
  95815. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  95816. */
  95817. static CreateTorus(name: string, options: {
  95818. diameter?: number;
  95819. thickness?: number;
  95820. tessellation?: number;
  95821. updatable?: boolean;
  95822. sideOrientation?: number;
  95823. frontUVs?: Vector4;
  95824. backUVs?: Vector4;
  95825. }, scene: any): Mesh;
  95826. }
  95827. }
  95828. declare module BABYLON {
  95829. /**
  95830. * Class containing static functions to help procedurally build meshes
  95831. */
  95832. export class CylinderBuilder {
  95833. /**
  95834. * Creates a cylinder or a cone mesh
  95835. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  95836. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  95837. * * 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.
  95838. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  95839. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  95840. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  95841. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  95842. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  95843. * * 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).
  95844. * * 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
  95845. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  95846. * * 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
  95847. * * 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.
  95848. * * If `enclose` is false, a ring surface is one element.
  95849. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  95850. * * 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
  95851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95852. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95854. * @param name defines the name of the mesh
  95855. * @param options defines the options used to create the mesh
  95856. * @param scene defines the hosting scene
  95857. * @returns the cylinder mesh
  95858. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  95859. */
  95860. static CreateCylinder(name: string, options: {
  95861. height?: number;
  95862. diameterTop?: number;
  95863. diameterBottom?: number;
  95864. diameter?: number;
  95865. tessellation?: number;
  95866. subdivisions?: number;
  95867. arc?: number;
  95868. faceColors?: Color4[];
  95869. faceUV?: Vector4[];
  95870. updatable?: boolean;
  95871. hasRings?: boolean;
  95872. enclose?: boolean;
  95873. sideOrientation?: number;
  95874. frontUVs?: Vector4;
  95875. backUVs?: Vector4;
  95876. }, scene: any): Mesh;
  95877. }
  95878. }
  95879. declare module BABYLON {
  95880. /**
  95881. * Manager for handling gamepads
  95882. */
  95883. export class GamepadManager {
  95884. private _scene?;
  95885. private _babylonGamepads;
  95886. private _oneGamepadConnected;
  95887. /** @hidden */
  95888. _isMonitoring: boolean;
  95889. private _gamepadEventSupported;
  95890. private _gamepadSupport;
  95891. /**
  95892. * observable to be triggered when the gamepad controller has been connected
  95893. */
  95894. onGamepadConnectedObservable: Observable<Gamepad>;
  95895. /**
  95896. * observable to be triggered when the gamepad controller has been disconnected
  95897. */
  95898. onGamepadDisconnectedObservable: Observable<Gamepad>;
  95899. private _onGamepadConnectedEvent;
  95900. private _onGamepadDisconnectedEvent;
  95901. /**
  95902. * Initializes the gamepad manager
  95903. * @param _scene BabylonJS scene
  95904. */
  95905. constructor(_scene?: Scene | undefined);
  95906. /**
  95907. * The gamepads in the game pad manager
  95908. */
  95909. readonly gamepads: Gamepad[];
  95910. /**
  95911. * Get the gamepad controllers based on type
  95912. * @param type The type of gamepad controller
  95913. * @returns Nullable gamepad
  95914. */
  95915. getGamepadByType(type?: number): Nullable<Gamepad>;
  95916. /**
  95917. * Disposes the gamepad manager
  95918. */
  95919. dispose(): void;
  95920. private _addNewGamepad;
  95921. private _startMonitoringGamepads;
  95922. private _stopMonitoringGamepads;
  95923. /** @hidden */
  95924. _checkGamepadsStatus(): void;
  95925. private _updateGamepadObjects;
  95926. }
  95927. }
  95928. declare module BABYLON {
  95929. interface Scene {
  95930. /** @hidden */
  95931. _gamepadManager: Nullable<GamepadManager>;
  95932. /**
  95933. * Gets the gamepad manager associated with the scene
  95934. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  95935. */
  95936. gamepadManager: GamepadManager;
  95937. }
  95938. /**
  95939. * Interface representing a free camera inputs manager
  95940. */
  95941. interface FreeCameraInputsManager {
  95942. /**
  95943. * Adds gamepad input support to the FreeCameraInputsManager.
  95944. * @returns the FreeCameraInputsManager
  95945. */
  95946. addGamepad(): FreeCameraInputsManager;
  95947. }
  95948. /**
  95949. * Interface representing an arc rotate camera inputs manager
  95950. */
  95951. interface ArcRotateCameraInputsManager {
  95952. /**
  95953. * Adds gamepad input support to the ArcRotateCamera InputManager.
  95954. * @returns the camera inputs manager
  95955. */
  95956. addGamepad(): ArcRotateCameraInputsManager;
  95957. }
  95958. /**
  95959. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  95960. */
  95961. export class GamepadSystemSceneComponent implements ISceneComponent {
  95962. /**
  95963. * The component name helpfull to identify the component in the list of scene components.
  95964. */
  95965. readonly name: string;
  95966. /**
  95967. * The scene the component belongs to.
  95968. */
  95969. scene: Scene;
  95970. /**
  95971. * Creates a new instance of the component for the given scene
  95972. * @param scene Defines the scene to register the component in
  95973. */
  95974. constructor(scene: Scene);
  95975. /**
  95976. * Registers the component in a given scene
  95977. */
  95978. register(): void;
  95979. /**
  95980. * Rebuilds the elements related to this component in case of
  95981. * context lost for instance.
  95982. */
  95983. rebuild(): void;
  95984. /**
  95985. * Disposes the component and the associated ressources
  95986. */
  95987. dispose(): void;
  95988. private _beforeCameraUpdate;
  95989. }
  95990. }
  95991. declare module BABYLON {
  95992. /**
  95993. * Options to modify the vr teleportation behavior.
  95994. */
  95995. export interface VRTeleportationOptions {
  95996. /**
  95997. * The name of the mesh which should be used as the teleportation floor. (default: null)
  95998. */
  95999. floorMeshName?: string;
  96000. /**
  96001. * A list of meshes to be used as the teleportation floor. (default: empty)
  96002. */
  96003. floorMeshes?: Mesh[];
  96004. }
  96005. /**
  96006. * Options to modify the vr experience helper's behavior.
  96007. */
  96008. export interface VRExperienceHelperOptions extends WebVROptions {
  96009. /**
  96010. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  96011. */
  96012. createDeviceOrientationCamera?: boolean;
  96013. /**
  96014. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  96015. */
  96016. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  96017. /**
  96018. * Uses the main button on the controller to toggle the laser casted. (default: true)
  96019. */
  96020. laserToggle?: boolean;
  96021. /**
  96022. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  96023. */
  96024. floorMeshes?: Mesh[];
  96025. /**
  96026. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  96027. */
  96028. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  96029. }
  96030. /**
  96031. * Event containing information after VR has been entered
  96032. */
  96033. export class OnAfterEnteringVRObservableEvent {
  96034. /**
  96035. * If entering vr was successful
  96036. */
  96037. success: boolean;
  96038. }
  96039. /**
  96040. * Helps to quickly add VR support to an existing scene.
  96041. * See http://doc.babylonjs.com/how_to/webvr_helper
  96042. */
  96043. export class VRExperienceHelper {
  96044. /** Options to modify the vr experience helper's behavior. */
  96045. webVROptions: VRExperienceHelperOptions;
  96046. private _scene;
  96047. private _position;
  96048. private _btnVR;
  96049. private _btnVRDisplayed;
  96050. private _webVRsupported;
  96051. private _webVRready;
  96052. private _webVRrequesting;
  96053. private _webVRpresenting;
  96054. private _hasEnteredVR;
  96055. private _fullscreenVRpresenting;
  96056. private _canvas;
  96057. private _webVRCamera;
  96058. private _vrDeviceOrientationCamera;
  96059. private _deviceOrientationCamera;
  96060. private _existingCamera;
  96061. private _onKeyDown;
  96062. private _onVrDisplayPresentChange;
  96063. private _onVRDisplayChanged;
  96064. private _onVRRequestPresentStart;
  96065. private _onVRRequestPresentComplete;
  96066. /**
  96067. * Observable raised right before entering VR.
  96068. */
  96069. onEnteringVRObservable: Observable<VRExperienceHelper>;
  96070. /**
  96071. * Observable raised when entering VR has completed.
  96072. */
  96073. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  96074. /**
  96075. * Observable raised when exiting VR.
  96076. */
  96077. onExitingVRObservable: Observable<VRExperienceHelper>;
  96078. /**
  96079. * Observable raised when controller mesh is loaded.
  96080. */
  96081. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96082. /** Return this.onEnteringVRObservable
  96083. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  96084. */
  96085. readonly onEnteringVR: Observable<VRExperienceHelper>;
  96086. /** Return this.onExitingVRObservable
  96087. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  96088. */
  96089. readonly onExitingVR: Observable<VRExperienceHelper>;
  96090. /** Return this.onControllerMeshLoadedObservable
  96091. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  96092. */
  96093. readonly onControllerMeshLoaded: Observable<WebVRController>;
  96094. private _rayLength;
  96095. private _useCustomVRButton;
  96096. private _teleportationRequested;
  96097. private _teleportActive;
  96098. private _floorMeshName;
  96099. private _floorMeshesCollection;
  96100. private _rotationAllowed;
  96101. private _teleportBackwardsVector;
  96102. private _teleportationTarget;
  96103. private _isDefaultTeleportationTarget;
  96104. private _postProcessMove;
  96105. private _teleportationFillColor;
  96106. private _teleportationBorderColor;
  96107. private _rotationAngle;
  96108. private _haloCenter;
  96109. private _cameraGazer;
  96110. private _padSensibilityUp;
  96111. private _padSensibilityDown;
  96112. private _leftController;
  96113. private _rightController;
  96114. /**
  96115. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  96116. */
  96117. onNewMeshSelected: Observable<AbstractMesh>;
  96118. /**
  96119. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  96120. */
  96121. onNewMeshPicked: Observable<PickingInfo>;
  96122. private _circleEase;
  96123. /**
  96124. * Observable raised before camera teleportation
  96125. */
  96126. onBeforeCameraTeleport: Observable<Vector3>;
  96127. /**
  96128. * Observable raised after camera teleportation
  96129. */
  96130. onAfterCameraTeleport: Observable<Vector3>;
  96131. /**
  96132. * Observable raised when current selected mesh gets unselected
  96133. */
  96134. onSelectedMeshUnselected: Observable<AbstractMesh>;
  96135. private _raySelectionPredicate;
  96136. /**
  96137. * To be optionaly changed by user to define custom ray selection
  96138. */
  96139. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  96140. /**
  96141. * To be optionaly changed by user to define custom selection logic (after ray selection)
  96142. */
  96143. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  96144. /**
  96145. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  96146. */
  96147. teleportationEnabled: boolean;
  96148. private _defaultHeight;
  96149. private _teleportationInitialized;
  96150. private _interactionsEnabled;
  96151. private _interactionsRequested;
  96152. private _displayGaze;
  96153. private _displayLaserPointer;
  96154. /**
  96155. * The mesh used to display where the user is going to teleport.
  96156. */
  96157. /**
  96158. * Sets the mesh to be used to display where the user is going to teleport.
  96159. */
  96160. teleportationTarget: Mesh;
  96161. /**
  96162. * 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
  96163. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  96164. * See http://doc.babylonjs.com/resources/baking_transformations
  96165. */
  96166. gazeTrackerMesh: Mesh;
  96167. /**
  96168. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  96169. */
  96170. updateGazeTrackerScale: boolean;
  96171. /**
  96172. * If the gaze trackers color should be updated when selecting meshes
  96173. */
  96174. updateGazeTrackerColor: boolean;
  96175. /**
  96176. * The gaze tracking mesh corresponding to the left controller
  96177. */
  96178. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  96179. /**
  96180. * The gaze tracking mesh corresponding to the right controller
  96181. */
  96182. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  96183. /**
  96184. * If the ray of the gaze should be displayed.
  96185. */
  96186. /**
  96187. * Sets if the ray of the gaze should be displayed.
  96188. */
  96189. displayGaze: boolean;
  96190. /**
  96191. * If the ray of the LaserPointer should be displayed.
  96192. */
  96193. /**
  96194. * Sets if the ray of the LaserPointer should be displayed.
  96195. */
  96196. displayLaserPointer: boolean;
  96197. /**
  96198. * The deviceOrientationCamera used as the camera when not in VR.
  96199. */
  96200. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  96201. /**
  96202. * Based on the current WebVR support, returns the current VR camera used.
  96203. */
  96204. readonly currentVRCamera: Nullable<Camera>;
  96205. /**
  96206. * The webVRCamera which is used when in VR.
  96207. */
  96208. readonly webVRCamera: WebVRFreeCamera;
  96209. /**
  96210. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  96211. */
  96212. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  96213. private readonly _teleportationRequestInitiated;
  96214. /**
  96215. * Defines wether or not Pointer lock should be requested when switching to
  96216. * full screen.
  96217. */
  96218. requestPointerLockOnFullScreen: boolean;
  96219. /**
  96220. * Instantiates a VRExperienceHelper.
  96221. * Helps to quickly add VR support to an existing scene.
  96222. * @param scene The scene the VRExperienceHelper belongs to.
  96223. * @param webVROptions Options to modify the vr experience helper's behavior.
  96224. */
  96225. constructor(scene: Scene,
  96226. /** Options to modify the vr experience helper's behavior. */
  96227. webVROptions?: VRExperienceHelperOptions);
  96228. private _onDefaultMeshLoaded;
  96229. private _onResize;
  96230. private _onFullscreenChange;
  96231. /**
  96232. * Gets a value indicating if we are currently in VR mode.
  96233. */
  96234. readonly isInVRMode: boolean;
  96235. private onVrDisplayPresentChange;
  96236. private onVRDisplayChanged;
  96237. private moveButtonToBottomRight;
  96238. private displayVRButton;
  96239. private updateButtonVisibility;
  96240. private _cachedAngularSensibility;
  96241. /**
  96242. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  96243. * Otherwise, will use the fullscreen API.
  96244. */
  96245. enterVR(): void;
  96246. /**
  96247. * Attempt to exit VR, or fullscreen.
  96248. */
  96249. exitVR(): void;
  96250. /**
  96251. * The position of the vr experience helper.
  96252. */
  96253. /**
  96254. * Sets the position of the vr experience helper.
  96255. */
  96256. position: Vector3;
  96257. /**
  96258. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  96259. */
  96260. enableInteractions(): void;
  96261. private readonly _noControllerIsActive;
  96262. private beforeRender;
  96263. private _isTeleportationFloor;
  96264. /**
  96265. * Adds a floor mesh to be used for teleportation.
  96266. * @param floorMesh the mesh to be used for teleportation.
  96267. */
  96268. addFloorMesh(floorMesh: Mesh): void;
  96269. /**
  96270. * Removes a floor mesh from being used for teleportation.
  96271. * @param floorMesh the mesh to be removed.
  96272. */
  96273. removeFloorMesh(floorMesh: Mesh): void;
  96274. /**
  96275. * Enables interactions and teleportation using the VR controllers and gaze.
  96276. * @param vrTeleportationOptions options to modify teleportation behavior.
  96277. */
  96278. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  96279. private _onNewGamepadConnected;
  96280. private _tryEnableInteractionOnController;
  96281. private _onNewGamepadDisconnected;
  96282. private _enableInteractionOnController;
  96283. private _checkTeleportWithRay;
  96284. private _checkRotate;
  96285. private _checkTeleportBackwards;
  96286. private _enableTeleportationOnController;
  96287. private _createTeleportationCircles;
  96288. private _displayTeleportationTarget;
  96289. private _hideTeleportationTarget;
  96290. private _rotateCamera;
  96291. private _moveTeleportationSelectorTo;
  96292. private _workingVector;
  96293. private _workingQuaternion;
  96294. private _workingMatrix;
  96295. /**
  96296. * Teleports the users feet to the desired location
  96297. * @param location The location where the user's feet should be placed
  96298. */
  96299. teleportCamera(location: Vector3): void;
  96300. private _convertNormalToDirectionOfRay;
  96301. private _castRayAndSelectObject;
  96302. private _notifySelectedMeshUnselected;
  96303. /**
  96304. * Sets the color of the laser ray from the vr controllers.
  96305. * @param color new color for the ray.
  96306. */
  96307. changeLaserColor(color: Color3): void;
  96308. /**
  96309. * Sets the color of the ray from the vr headsets gaze.
  96310. * @param color new color for the ray.
  96311. */
  96312. changeGazeColor(color: Color3): void;
  96313. /**
  96314. * Exits VR and disposes of the vr experience helper
  96315. */
  96316. dispose(): void;
  96317. /**
  96318. * Gets the name of the VRExperienceHelper class
  96319. * @returns "VRExperienceHelper"
  96320. */
  96321. getClassName(): string;
  96322. }
  96323. }
  96324. declare module BABYLON {
  96325. /**
  96326. * Manages an XRSession
  96327. * @see https://doc.babylonjs.com/how_to/webxr
  96328. */
  96329. export class WebXRSessionManager implements IDisposable {
  96330. private scene;
  96331. /**
  96332. * Fires every time a new xrFrame arrives which can be used to update the camera
  96333. */
  96334. onXRFrameObservable: Observable<any>;
  96335. /**
  96336. * Fires when the xr session is ended either by the device or manually done
  96337. */
  96338. onXRSessionEnded: Observable<any>;
  96339. /** @hidden */
  96340. _xrSession: XRSession;
  96341. /** @hidden */
  96342. _frameOfReference: XRFrameOfReference;
  96343. /** @hidden */
  96344. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  96345. /** @hidden */
  96346. _currentXRFrame: Nullable<XRFrame>;
  96347. private _xrNavigator;
  96348. private _xrDevice;
  96349. private _tmpMatrix;
  96350. /**
  96351. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  96352. * @param scene The scene which the session should be created for
  96353. */
  96354. constructor(scene: Scene);
  96355. /**
  96356. * Initializes the manager
  96357. * After initialization enterXR can be called to start an XR session
  96358. * @returns Promise which resolves after it is initialized
  96359. */
  96360. initializeAsync(): Promise<void>;
  96361. /**
  96362. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  96363. * @param sessionCreationOptions xr options to create the session with
  96364. * @param frameOfReferenceType option to configure how the xr pose is expressed
  96365. * @returns Promise which resolves after it enters XR
  96366. */
  96367. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  96368. /**
  96369. * Stops the xrSession and restores the renderloop
  96370. * @returns Promise which resolves after it exits XR
  96371. */
  96372. exitXRAsync(): Promise<void>;
  96373. /**
  96374. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96375. * @param ray ray to cast into the environment
  96376. * @returns Promise which resolves with a collision point in the environment if it exists
  96377. */
  96378. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96379. /**
  96380. * Checks if a session would be supported for the creation options specified
  96381. * @param options creation options to check if they are supported
  96382. * @returns true if supported
  96383. */
  96384. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96385. /**
  96386. * @hidden
  96387. * Converts the render layer of xrSession to a render target
  96388. * @param session session to create render target for
  96389. * @param scene scene the new render target should be created for
  96390. */
  96391. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  96392. /**
  96393. * Disposes of the session manager
  96394. */
  96395. dispose(): void;
  96396. }
  96397. }
  96398. declare module BABYLON {
  96399. /**
  96400. * WebXR Camera which holds the views for the xrSession
  96401. * @see https://doc.babylonjs.com/how_to/webxr
  96402. */
  96403. export class WebXRCamera extends FreeCamera {
  96404. private static _TmpMatrix;
  96405. /**
  96406. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  96407. * @param name the name of the camera
  96408. * @param scene the scene to add the camera to
  96409. */
  96410. constructor(name: string, scene: Scene);
  96411. private _updateNumberOfRigCameras;
  96412. /** @hidden */
  96413. _updateForDualEyeDebugging(pupilDistance?: number): void;
  96414. /**
  96415. * Updates the cameras position from the current pose information of the XR session
  96416. * @param xrSessionManager the session containing pose information
  96417. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  96418. */
  96419. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  96420. }
  96421. }
  96422. declare module BABYLON {
  96423. /**
  96424. * States of the webXR experience
  96425. */
  96426. export enum WebXRState {
  96427. /**
  96428. * Transitioning to being in XR mode
  96429. */
  96430. ENTERING_XR = 0,
  96431. /**
  96432. * Transitioning to non XR mode
  96433. */
  96434. EXITING_XR = 1,
  96435. /**
  96436. * In XR mode and presenting
  96437. */
  96438. IN_XR = 2,
  96439. /**
  96440. * Not entered XR mode
  96441. */
  96442. NOT_IN_XR = 3
  96443. }
  96444. /**
  96445. * Helper class used to enable XR
  96446. * @see https://doc.babylonjs.com/how_to/webxr
  96447. */
  96448. export class WebXRExperienceHelper implements IDisposable {
  96449. private scene;
  96450. /**
  96451. * 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
  96452. */
  96453. container: AbstractMesh;
  96454. /**
  96455. * Camera used to render xr content
  96456. */
  96457. camera: WebXRCamera;
  96458. /**
  96459. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  96460. */
  96461. state: WebXRState;
  96462. private _setState;
  96463. private static _TmpVector;
  96464. /**
  96465. * Fires when the state of the experience helper has changed
  96466. */
  96467. onStateChangedObservable: Observable<WebXRState>;
  96468. /** @hidden */
  96469. _sessionManager: WebXRSessionManager;
  96470. private _nonVRCamera;
  96471. private _originalSceneAutoClear;
  96472. private _supported;
  96473. /**
  96474. * Creates the experience helper
  96475. * @param scene the scene to attach the experience helper to
  96476. * @returns a promise for the experience helper
  96477. */
  96478. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  96479. /**
  96480. * Creates a WebXRExperienceHelper
  96481. * @param scene The scene the helper should be created in
  96482. */
  96483. private constructor();
  96484. /**
  96485. * Exits XR mode and returns the scene to its original state
  96486. * @returns promise that resolves after xr mode has exited
  96487. */
  96488. exitXRAsync(): Promise<void>;
  96489. /**
  96490. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  96491. * @param sessionCreationOptions options for the XR session
  96492. * @param frameOfReference frame of reference of the XR session
  96493. * @returns promise that resolves after xr mode has entered
  96494. */
  96495. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  96496. /**
  96497. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96498. * @param ray ray to cast into the environment
  96499. * @returns Promise which resolves with a collision point in the environment if it exists
  96500. */
  96501. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96502. /**
  96503. * Updates the global position of the camera by moving the camera's container
  96504. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  96505. * @param position The desired global position of the camera
  96506. */
  96507. setPositionOfCameraUsingContainer(position: Vector3): void;
  96508. /**
  96509. * Rotates the xr camera by rotating the camera's container around the camera's position
  96510. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  96511. * @param rotation the desired quaternion rotation to apply to the camera
  96512. */
  96513. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  96514. /**
  96515. * Checks if the creation options are supported by the xr session
  96516. * @param options creation options
  96517. * @returns true if supported
  96518. */
  96519. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96520. /**
  96521. * Disposes of the experience helper
  96522. */
  96523. dispose(): void;
  96524. }
  96525. }
  96526. declare module BABYLON {
  96527. /**
  96528. * Button which can be used to enter a different mode of XR
  96529. */
  96530. export class WebXREnterExitUIButton {
  96531. /** button element */
  96532. element: HTMLElement;
  96533. /** XR initialization options for the button */
  96534. initializationOptions: XRSessionCreationOptions;
  96535. /**
  96536. * Creates a WebXREnterExitUIButton
  96537. * @param element button element
  96538. * @param initializationOptions XR initialization options for the button
  96539. */
  96540. constructor(
  96541. /** button element */
  96542. element: HTMLElement,
  96543. /** XR initialization options for the button */
  96544. initializationOptions: XRSessionCreationOptions);
  96545. /**
  96546. * Overwritable function which can be used to update the button's visuals when the state changes
  96547. * @param activeButton the current active button in the UI
  96548. */
  96549. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  96550. }
  96551. /**
  96552. * Options to create the webXR UI
  96553. */
  96554. export class WebXREnterExitUIOptions {
  96555. /**
  96556. * Context to enter xr with
  96557. */
  96558. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  96559. /**
  96560. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  96561. */
  96562. customButtons?: Array<WebXREnterExitUIButton>;
  96563. }
  96564. /**
  96565. * UI to allow the user to enter/exit XR mode
  96566. */
  96567. export class WebXREnterExitUI implements IDisposable {
  96568. private scene;
  96569. private _overlay;
  96570. private _buttons;
  96571. private _activeButton;
  96572. /**
  96573. * Fired every time the active button is changed.
  96574. *
  96575. * When xr is entered via a button that launches xr that button will be the callback parameter
  96576. *
  96577. * When exiting xr the callback parameter will be null)
  96578. */
  96579. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  96580. /**
  96581. * Creates UI to allow the user to enter/exit XR mode
  96582. * @param scene the scene to add the ui to
  96583. * @param helper the xr experience helper to enter/exit xr with
  96584. * @param options options to configure the UI
  96585. * @returns the created ui
  96586. */
  96587. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  96588. private constructor();
  96589. private _updateButtons;
  96590. /**
  96591. * Disposes of the object
  96592. */
  96593. dispose(): void;
  96594. }
  96595. }
  96596. declare module BABYLON {
  96597. /**
  96598. * Represents an XR input
  96599. */
  96600. export class WebXRController {
  96601. /**
  96602. * 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
  96603. */
  96604. grip?: AbstractMesh;
  96605. /**
  96606. * Pointer which can be used to select objects or attach a visible laser to
  96607. */
  96608. pointer: AbstractMesh;
  96609. /**
  96610. * Creates the controller
  96611. * @see https://doc.babylonjs.com/how_to/webxr
  96612. * @param scene the scene which the controller should be associated to
  96613. */
  96614. constructor(scene: Scene);
  96615. /**
  96616. * Disposes of the object
  96617. */
  96618. dispose(): void;
  96619. }
  96620. /**
  96621. * XR input used to track XR inputs such as controllers/rays
  96622. */
  96623. export class WebXRInput implements IDisposable {
  96624. private helper;
  96625. /**
  96626. * XR controllers being tracked
  96627. */
  96628. controllers: Array<WebXRController>;
  96629. private _tmpMatrix;
  96630. private _frameObserver;
  96631. /**
  96632. * Initializes the WebXRInput
  96633. * @param helper experience helper which the input should be created for
  96634. */
  96635. constructor(helper: WebXRExperienceHelper);
  96636. /**
  96637. * Disposes of the object
  96638. */
  96639. dispose(): void;
  96640. }
  96641. }
  96642. declare module BABYLON {
  96643. /**
  96644. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  96645. */
  96646. export class WebXRManagedOutputCanvas implements IDisposable {
  96647. private _canvas;
  96648. /**
  96649. * xrpresent context of the canvas which can be used to display/mirror xr content
  96650. */
  96651. canvasContext: Nullable<WebGLRenderingContext>;
  96652. /**
  96653. * Initializes the canvas to be added/removed upon entering/exiting xr
  96654. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  96655. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  96656. */
  96657. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  96658. /**
  96659. * Disposes of the object
  96660. */
  96661. dispose(): void;
  96662. private _setManagedOutputCanvas;
  96663. private _addCanvas;
  96664. private _removeCanvas;
  96665. }
  96666. }
  96667. declare module BABYLON {
  96668. /**
  96669. * Contains an array of blocks representing the octree
  96670. */
  96671. export interface IOctreeContainer<T> {
  96672. /**
  96673. * Blocks within the octree
  96674. */
  96675. blocks: Array<OctreeBlock<T>>;
  96676. }
  96677. /**
  96678. * Class used to store a cell in an octree
  96679. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96680. */
  96681. export class OctreeBlock<T> {
  96682. /**
  96683. * Gets the content of the current block
  96684. */
  96685. entries: T[];
  96686. /**
  96687. * Gets the list of block children
  96688. */
  96689. blocks: Array<OctreeBlock<T>>;
  96690. private _depth;
  96691. private _maxDepth;
  96692. private _capacity;
  96693. private _minPoint;
  96694. private _maxPoint;
  96695. private _boundingVectors;
  96696. private _creationFunc;
  96697. /**
  96698. * Creates a new block
  96699. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  96700. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  96701. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  96702. * @param depth defines the current depth of this block in the octree
  96703. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  96704. * @param creationFunc defines a callback to call when an element is added to the block
  96705. */
  96706. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  96707. /**
  96708. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  96709. */
  96710. readonly capacity: number;
  96711. /**
  96712. * Gets the minimum vector (in world space) of the block's bounding box
  96713. */
  96714. readonly minPoint: Vector3;
  96715. /**
  96716. * Gets the maximum vector (in world space) of the block's bounding box
  96717. */
  96718. readonly maxPoint: Vector3;
  96719. /**
  96720. * Add a new element to this block
  96721. * @param entry defines the element to add
  96722. */
  96723. addEntry(entry: T): void;
  96724. /**
  96725. * Remove an element from this block
  96726. * @param entry defines the element to remove
  96727. */
  96728. removeEntry(entry: T): void;
  96729. /**
  96730. * Add an array of elements to this block
  96731. * @param entries defines the array of elements to add
  96732. */
  96733. addEntries(entries: T[]): void;
  96734. /**
  96735. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  96736. * @param frustumPlanes defines the frustum planes to test
  96737. * @param selection defines the array to store current content if selection is positive
  96738. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96739. */
  96740. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  96741. /**
  96742. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  96743. * @param sphereCenter defines the bounding sphere center
  96744. * @param sphereRadius defines the bounding sphere radius
  96745. * @param selection defines the array to store current content if selection is positive
  96746. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96747. */
  96748. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  96749. /**
  96750. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  96751. * @param ray defines the ray to test with
  96752. * @param selection defines the array to store current content if selection is positive
  96753. */
  96754. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  96755. /**
  96756. * Subdivide the content into child blocks (this block will then be empty)
  96757. */
  96758. createInnerBlocks(): void;
  96759. /**
  96760. * @hidden
  96761. */
  96762. 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;
  96763. }
  96764. }
  96765. declare module BABYLON {
  96766. /**
  96767. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  96768. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96769. */
  96770. export class Octree<T> {
  96771. /** 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.) */
  96772. maxDepth: number;
  96773. /**
  96774. * Blocks within the octree containing objects
  96775. */
  96776. blocks: Array<OctreeBlock<T>>;
  96777. /**
  96778. * Content stored in the octree
  96779. */
  96780. dynamicContent: T[];
  96781. private _maxBlockCapacity;
  96782. private _selectionContent;
  96783. private _creationFunc;
  96784. /**
  96785. * Creates a octree
  96786. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96787. * @param creationFunc function to be used to instatiate the octree
  96788. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  96789. * @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.)
  96790. */
  96791. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  96792. /** 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.) */
  96793. maxDepth?: number);
  96794. /**
  96795. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  96796. * @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);
  96797. * @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);
  96798. * @param entries meshes to be added to the octree blocks
  96799. */
  96800. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  96801. /**
  96802. * Adds a mesh to the octree
  96803. * @param entry Mesh to add to the octree
  96804. */
  96805. addMesh(entry: T): void;
  96806. /**
  96807. * Remove an element from the octree
  96808. * @param entry defines the element to remove
  96809. */
  96810. removeMesh(entry: T): void;
  96811. /**
  96812. * Selects an array of meshes within the frustum
  96813. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  96814. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  96815. * @returns array of meshes within the frustum
  96816. */
  96817. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  96818. /**
  96819. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  96820. * @param sphereCenter defines the bounding sphere center
  96821. * @param sphereRadius defines the bounding sphere radius
  96822. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96823. * @returns an array of objects that intersect the sphere
  96824. */
  96825. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  96826. /**
  96827. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  96828. * @param ray defines the ray to test with
  96829. * @returns array of intersected objects
  96830. */
  96831. intersectsRay(ray: Ray): SmartArray<T>;
  96832. /**
  96833. * Adds a mesh into the octree block if it intersects the block
  96834. */
  96835. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  96836. /**
  96837. * Adds a submesh into the octree block if it intersects the block
  96838. */
  96839. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  96840. }
  96841. }
  96842. declare module BABYLON {
  96843. interface Scene {
  96844. /**
  96845. * @hidden
  96846. * Backing Filed
  96847. */
  96848. _selectionOctree: Octree<AbstractMesh>;
  96849. /**
  96850. * Gets the octree used to boost mesh selection (picking)
  96851. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96852. */
  96853. selectionOctree: Octree<AbstractMesh>;
  96854. /**
  96855. * Creates or updates the octree used to boost selection (picking)
  96856. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96857. * @param maxCapacity defines the maximum capacity per leaf
  96858. * @param maxDepth defines the maximum depth of the octree
  96859. * @returns an octree of AbstractMesh
  96860. */
  96861. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  96862. }
  96863. interface AbstractMesh {
  96864. /**
  96865. * @hidden
  96866. * Backing Field
  96867. */
  96868. _submeshesOctree: Octree<SubMesh>;
  96869. /**
  96870. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  96871. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96872. * @param maxCapacity defines the maximum size of each block (64 by default)
  96873. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  96874. * @returns the new octree
  96875. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  96876. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96877. */
  96878. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  96879. }
  96880. /**
  96881. * Defines the octree scene component responsible to manage any octrees
  96882. * in a given scene.
  96883. */
  96884. export class OctreeSceneComponent {
  96885. /**
  96886. * The component name helpfull to identify the component in the list of scene components.
  96887. */
  96888. readonly name: string;
  96889. /**
  96890. * The scene the component belongs to.
  96891. */
  96892. scene: Scene;
  96893. /**
  96894. * Indicates if the meshes have been checked to make sure they are isEnabled()
  96895. */
  96896. readonly checksIsEnabled: boolean;
  96897. /**
  96898. * Creates a new instance of the component for the given scene
  96899. * @param scene Defines the scene to register the component in
  96900. */
  96901. constructor(scene: Scene);
  96902. /**
  96903. * Registers the component in a given scene
  96904. */
  96905. register(): void;
  96906. /**
  96907. * Return the list of active meshes
  96908. * @returns the list of active meshes
  96909. */
  96910. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  96911. /**
  96912. * Return the list of active sub meshes
  96913. * @param mesh The mesh to get the candidates sub meshes from
  96914. * @returns the list of active sub meshes
  96915. */
  96916. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  96917. private _tempRay;
  96918. /**
  96919. * Return the list of sub meshes intersecting with a given local ray
  96920. * @param mesh defines the mesh to find the submesh for
  96921. * @param localRay defines the ray in local space
  96922. * @returns the list of intersecting sub meshes
  96923. */
  96924. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  96925. /**
  96926. * Return the list of sub meshes colliding with a collider
  96927. * @param mesh defines the mesh to find the submesh for
  96928. * @param collider defines the collider to evaluate the collision against
  96929. * @returns the list of colliding sub meshes
  96930. */
  96931. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  96932. /**
  96933. * Rebuilds the elements related to this component in case of
  96934. * context lost for instance.
  96935. */
  96936. rebuild(): void;
  96937. /**
  96938. * Disposes the component and the associated ressources.
  96939. */
  96940. dispose(): void;
  96941. }
  96942. }
  96943. declare module BABYLON {
  96944. /**
  96945. * Class containing static functions to help procedurally build meshes
  96946. */
  96947. export class LinesBuilder {
  96948. /**
  96949. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  96950. * * 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
  96951. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  96952. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  96953. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  96954. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  96955. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  96956. * * 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
  96957. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  96958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96959. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  96960. * @param name defines the name of the new line system
  96961. * @param options defines the options used to create the line system
  96962. * @param scene defines the hosting scene
  96963. * @returns a new line system mesh
  96964. */
  96965. static CreateLineSystem(name: string, options: {
  96966. lines: Vector3[][];
  96967. updatable?: boolean;
  96968. instance?: Nullable<LinesMesh>;
  96969. colors?: Nullable<Color4[][]>;
  96970. useVertexAlpha?: boolean;
  96971. }, scene: Nullable<Scene>): LinesMesh;
  96972. /**
  96973. * Creates a line mesh
  96974. * 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
  96975. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  96976. * * The parameter `points` is an array successive Vector3
  96977. * * 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
  96978. * * The optional parameter `colors` is an array of successive Color4, one per line point
  96979. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  96980. * * When updating an instance, remember that only point positions can change, not the number of points
  96981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96982. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  96983. * @param name defines the name of the new line system
  96984. * @param options defines the options used to create the line system
  96985. * @param scene defines the hosting scene
  96986. * @returns a new line mesh
  96987. */
  96988. static CreateLines(name: string, options: {
  96989. points: Vector3[];
  96990. updatable?: boolean;
  96991. instance?: Nullable<LinesMesh>;
  96992. colors?: Color4[];
  96993. useVertexAlpha?: boolean;
  96994. }, scene?: Nullable<Scene>): LinesMesh;
  96995. /**
  96996. * Creates a dashed line mesh
  96997. * * 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
  96998. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  96999. * * The parameter `points` is an array successive Vector3
  97000. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  97001. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  97002. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97003. * * 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
  97004. * * When updating an instance, remember that only point positions can change, not the number of points
  97005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97006. * @param name defines the name of the mesh
  97007. * @param options defines the options used to create the mesh
  97008. * @param scene defines the hosting scene
  97009. * @returns the dashed line mesh
  97010. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  97011. */
  97012. static CreateDashedLines(name: string, options: {
  97013. points: Vector3[];
  97014. dashSize?: number;
  97015. gapSize?: number;
  97016. dashNb?: number;
  97017. updatable?: boolean;
  97018. instance?: LinesMesh;
  97019. }, scene?: Nullable<Scene>): LinesMesh;
  97020. }
  97021. }
  97022. declare module BABYLON {
  97023. /**
  97024. * Renders a layer on top of an existing scene
  97025. */
  97026. export class UtilityLayerRenderer implements IDisposable {
  97027. /** the original scene that will be rendered on top of */
  97028. originalScene: Scene;
  97029. private _pointerCaptures;
  97030. private _lastPointerEvents;
  97031. private static _DefaultUtilityLayer;
  97032. private static _DefaultKeepDepthUtilityLayer;
  97033. /**
  97034. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  97035. */
  97036. pickUtilitySceneFirst: boolean;
  97037. /**
  97038. * 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)
  97039. */
  97040. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  97041. /**
  97042. * 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)
  97043. */
  97044. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  97045. /**
  97046. * The scene that is rendered on top of the original scene
  97047. */
  97048. utilityLayerScene: Scene;
  97049. /**
  97050. * If the utility layer should automatically be rendered on top of existing scene
  97051. */
  97052. shouldRender: boolean;
  97053. /**
  97054. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  97055. */
  97056. onlyCheckPointerDownEvents: boolean;
  97057. /**
  97058. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  97059. */
  97060. processAllEvents: boolean;
  97061. /**
  97062. * Observable raised when the pointer move from the utility layer scene to the main scene
  97063. */
  97064. onPointerOutObservable: Observable<number>;
  97065. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  97066. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  97067. private _afterRenderObserver;
  97068. private _sceneDisposeObserver;
  97069. private _originalPointerObserver;
  97070. /**
  97071. * Instantiates a UtilityLayerRenderer
  97072. * @param originalScene the original scene that will be rendered on top of
  97073. * @param handleEvents boolean indicating if the utility layer should handle events
  97074. */
  97075. constructor(
  97076. /** the original scene that will be rendered on top of */
  97077. originalScene: Scene, handleEvents?: boolean);
  97078. private _notifyObservers;
  97079. /**
  97080. * Renders the utility layers scene on top of the original scene
  97081. */
  97082. render(): void;
  97083. /**
  97084. * Disposes of the renderer
  97085. */
  97086. dispose(): void;
  97087. private _updateCamera;
  97088. }
  97089. }
  97090. declare module BABYLON {
  97091. /**
  97092. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  97093. */
  97094. export class Gizmo implements IDisposable {
  97095. /** The utility layer the gizmo will be added to */
  97096. gizmoLayer: UtilityLayerRenderer;
  97097. /**
  97098. * The root mesh of the gizmo
  97099. */
  97100. _rootMesh: Mesh;
  97101. private _attachedMesh;
  97102. /**
  97103. * Ratio for the scale of the gizmo (Default: 1)
  97104. */
  97105. scaleRatio: number;
  97106. private _tmpMatrix;
  97107. /**
  97108. * If a custom mesh has been set (Default: false)
  97109. */
  97110. protected _customMeshSet: boolean;
  97111. /**
  97112. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  97113. * * When set, interactions will be enabled
  97114. */
  97115. attachedMesh: Nullable<AbstractMesh>;
  97116. /**
  97117. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97118. * @param mesh The mesh to replace the default mesh of the gizmo
  97119. */
  97120. setCustomMesh(mesh: Mesh): void;
  97121. /**
  97122. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  97123. */
  97124. updateGizmoRotationToMatchAttachedMesh: boolean;
  97125. /**
  97126. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  97127. */
  97128. updateGizmoPositionToMatchAttachedMesh: boolean;
  97129. /**
  97130. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  97131. */
  97132. protected _updateScale: boolean;
  97133. protected _interactionsEnabled: boolean;
  97134. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97135. private _beforeRenderObserver;
  97136. /**
  97137. * Creates a gizmo
  97138. * @param gizmoLayer The utility layer the gizmo will be added to
  97139. */
  97140. constructor(
  97141. /** The utility layer the gizmo will be added to */
  97142. gizmoLayer?: UtilityLayerRenderer);
  97143. private _tempVector;
  97144. /**
  97145. * @hidden
  97146. * Updates the gizmo to match the attached mesh's position/rotation
  97147. */
  97148. protected _update(): void;
  97149. /**
  97150. * Disposes of the gizmo
  97151. */
  97152. dispose(): void;
  97153. }
  97154. }
  97155. declare module BABYLON {
  97156. /**
  97157. * Single axis drag gizmo
  97158. */
  97159. export class AxisDragGizmo extends Gizmo {
  97160. /**
  97161. * Drag behavior responsible for the gizmos dragging interactions
  97162. */
  97163. dragBehavior: PointerDragBehavior;
  97164. private _pointerObserver;
  97165. /**
  97166. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97167. */
  97168. snapDistance: number;
  97169. /**
  97170. * Event that fires each time the gizmo snaps to a new location.
  97171. * * snapDistance is the the change in distance
  97172. */
  97173. onSnapObservable: Observable<{
  97174. snapDistance: number;
  97175. }>;
  97176. /** @hidden */
  97177. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  97178. /** @hidden */
  97179. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  97180. /**
  97181. * Creates an AxisDragGizmo
  97182. * @param gizmoLayer The utility layer the gizmo will be added to
  97183. * @param dragAxis The axis which the gizmo will be able to drag on
  97184. * @param color The color of the gizmo
  97185. */
  97186. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97187. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97188. /**
  97189. * Disposes of the gizmo
  97190. */
  97191. dispose(): void;
  97192. }
  97193. }
  97194. declare module BABYLON.Debug {
  97195. /**
  97196. * The Axes viewer will show 3 axes in a specific point in space
  97197. */
  97198. export class AxesViewer {
  97199. private _xAxis;
  97200. private _yAxis;
  97201. private _zAxis;
  97202. private _scaleLinesFactor;
  97203. private _instanced;
  97204. /**
  97205. * Gets the hosting scene
  97206. */
  97207. scene: Scene;
  97208. /**
  97209. * Gets or sets a number used to scale line length
  97210. */
  97211. scaleLines: number;
  97212. /** Gets the node hierarchy used to render x-axis */
  97213. readonly xAxis: TransformNode;
  97214. /** Gets the node hierarchy used to render y-axis */
  97215. readonly yAxis: TransformNode;
  97216. /** Gets the node hierarchy used to render z-axis */
  97217. readonly zAxis: TransformNode;
  97218. /**
  97219. * Creates a new AxesViewer
  97220. * @param scene defines the hosting scene
  97221. * @param scaleLines defines a number used to scale line length (1 by default)
  97222. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  97223. * @param xAxis defines the node hierarchy used to render the x-axis
  97224. * @param yAxis defines the node hierarchy used to render the y-axis
  97225. * @param zAxis defines the node hierarchy used to render the z-axis
  97226. */
  97227. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  97228. /**
  97229. * Force the viewer to update
  97230. * @param position defines the position of the viewer
  97231. * @param xaxis defines the x axis of the viewer
  97232. * @param yaxis defines the y axis of the viewer
  97233. * @param zaxis defines the z axis of the viewer
  97234. */
  97235. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  97236. /**
  97237. * Creates an instance of this axes viewer.
  97238. * @returns a new axes viewer with instanced meshes
  97239. */
  97240. createInstance(): AxesViewer;
  97241. /** Releases resources */
  97242. dispose(): void;
  97243. private static _SetRenderingGroupId;
  97244. }
  97245. }
  97246. declare module BABYLON.Debug {
  97247. /**
  97248. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  97249. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  97250. */
  97251. export class BoneAxesViewer extends AxesViewer {
  97252. /**
  97253. * Gets or sets the target mesh where to display the axes viewer
  97254. */
  97255. mesh: Nullable<Mesh>;
  97256. /**
  97257. * Gets or sets the target bone where to display the axes viewer
  97258. */
  97259. bone: Nullable<Bone>;
  97260. /** Gets current position */
  97261. pos: Vector3;
  97262. /** Gets direction of X axis */
  97263. xaxis: Vector3;
  97264. /** Gets direction of Y axis */
  97265. yaxis: Vector3;
  97266. /** Gets direction of Z axis */
  97267. zaxis: Vector3;
  97268. /**
  97269. * Creates a new BoneAxesViewer
  97270. * @param scene defines the hosting scene
  97271. * @param bone defines the target bone
  97272. * @param mesh defines the target mesh
  97273. * @param scaleLines defines a scaling factor for line length (1 by default)
  97274. */
  97275. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  97276. /**
  97277. * Force the viewer to update
  97278. */
  97279. update(): void;
  97280. /** Releases resources */
  97281. dispose(): void;
  97282. }
  97283. }
  97284. declare module BABYLON {
  97285. /**
  97286. * Interface used to define scene explorer extensibility option
  97287. */
  97288. export interface IExplorerExtensibilityOption {
  97289. /**
  97290. * Define the option label
  97291. */
  97292. label: string;
  97293. /**
  97294. * Defines the action to execute on click
  97295. */
  97296. action: (entity: any) => void;
  97297. }
  97298. /**
  97299. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  97300. */
  97301. export interface IExplorerExtensibilityGroup {
  97302. /**
  97303. * Defines a predicate to test if a given type mut be extended
  97304. */
  97305. predicate: (entity: any) => boolean;
  97306. /**
  97307. * Gets the list of options added to a type
  97308. */
  97309. entries: IExplorerExtensibilityOption[];
  97310. }
  97311. /**
  97312. * Interface used to define the options to use to create the Inspector
  97313. */
  97314. export interface IInspectorOptions {
  97315. /**
  97316. * Display in overlay mode (default: false)
  97317. */
  97318. overlay?: boolean;
  97319. /**
  97320. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  97321. */
  97322. globalRoot?: HTMLElement;
  97323. /**
  97324. * Display the Scene explorer
  97325. */
  97326. showExplorer?: boolean;
  97327. /**
  97328. * Display the property inspector
  97329. */
  97330. showInspector?: boolean;
  97331. /**
  97332. * Display in embed mode (both panes on the right)
  97333. */
  97334. embedMode?: boolean;
  97335. /**
  97336. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  97337. */
  97338. handleResize?: boolean;
  97339. /**
  97340. * Allow the panes to popup (default: true)
  97341. */
  97342. enablePopup?: boolean;
  97343. /**
  97344. * Allow the panes to be closed by users (default: true)
  97345. */
  97346. enableClose?: boolean;
  97347. /**
  97348. * Optional list of extensibility entries
  97349. */
  97350. explorerExtensibility?: IExplorerExtensibilityGroup[];
  97351. /**
  97352. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  97353. */
  97354. inspectorURL?: string;
  97355. }
  97356. interface Scene {
  97357. /**
  97358. * @hidden
  97359. * Backing field
  97360. */
  97361. _debugLayer: DebugLayer;
  97362. /**
  97363. * Gets the debug layer (aka Inspector) associated with the scene
  97364. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97365. */
  97366. debugLayer: DebugLayer;
  97367. }
  97368. /**
  97369. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97370. * what is happening in your scene
  97371. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97372. */
  97373. export class DebugLayer {
  97374. /**
  97375. * Define the url to get the inspector script from.
  97376. * By default it uses the babylonjs CDN.
  97377. * @ignoreNaming
  97378. */
  97379. static InspectorURL: string;
  97380. private _scene;
  97381. private BJSINSPECTOR;
  97382. /**
  97383. * Observable triggered when a property is changed through the inspector.
  97384. */
  97385. onPropertyChangedObservable: Observable<{
  97386. object: any;
  97387. property: string;
  97388. value: any;
  97389. initialValue: any;
  97390. }>;
  97391. /**
  97392. * Instantiates a new debug layer.
  97393. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97394. * what is happening in your scene
  97395. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97396. * @param scene Defines the scene to inspect
  97397. */
  97398. constructor(scene: Scene);
  97399. /** Creates the inspector window. */
  97400. private _createInspector;
  97401. /**
  97402. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  97403. * @param entity defines the entity to select
  97404. * @param lineContainerTitle defines the specific block to highlight
  97405. */
  97406. select(entity: any, lineContainerTitle?: string): void;
  97407. /** Get the inspector from bundle or global */
  97408. private _getGlobalInspector;
  97409. /**
  97410. * Get if the inspector is visible or not.
  97411. * @returns true if visible otherwise, false
  97412. */
  97413. isVisible(): boolean;
  97414. /**
  97415. * Hide the inspector and close its window.
  97416. */
  97417. hide(): void;
  97418. /**
  97419. * Launch the debugLayer.
  97420. * @param config Define the configuration of the inspector
  97421. * @return a promise fulfilled when the debug layer is visible
  97422. */
  97423. show(config?: IInspectorOptions): Promise<DebugLayer>;
  97424. }
  97425. }
  97426. declare module BABYLON {
  97427. /**
  97428. * Class containing static functions to help procedurally build meshes
  97429. */
  97430. export class BoxBuilder {
  97431. /**
  97432. * Creates a box mesh
  97433. * * The parameter `size` sets the size (float) of each box side (default 1)
  97434. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  97435. * * 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)
  97436. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  97437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97438. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97440. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  97441. * @param name defines the name of the mesh
  97442. * @param options defines the options used to create the mesh
  97443. * @param scene defines the hosting scene
  97444. * @returns the box mesh
  97445. */
  97446. static CreateBox(name: string, options: {
  97447. size?: number;
  97448. width?: number;
  97449. height?: number;
  97450. depth?: number;
  97451. faceUV?: Vector4[];
  97452. faceColors?: Color4[];
  97453. sideOrientation?: number;
  97454. frontUVs?: Vector4;
  97455. backUVs?: Vector4;
  97456. updatable?: boolean;
  97457. }, scene?: Nullable<Scene>): Mesh;
  97458. }
  97459. }
  97460. declare module BABYLON {
  97461. /**
  97462. * Class containing static functions to help procedurally build meshes
  97463. */
  97464. export class SphereBuilder {
  97465. /**
  97466. * Creates a sphere mesh
  97467. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  97468. * * 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`)
  97469. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  97470. * * 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
  97471. * * 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)
  97472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97475. * @param name defines the name of the mesh
  97476. * @param options defines the options used to create the mesh
  97477. * @param scene defines the hosting scene
  97478. * @returns the sphere mesh
  97479. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  97480. */
  97481. static CreateSphere(name: string, options: {
  97482. segments?: number;
  97483. diameter?: number;
  97484. diameterX?: number;
  97485. diameterY?: number;
  97486. diameterZ?: number;
  97487. arc?: number;
  97488. slice?: number;
  97489. sideOrientation?: number;
  97490. frontUVs?: Vector4;
  97491. backUVs?: Vector4;
  97492. updatable?: boolean;
  97493. }, scene: any): Mesh;
  97494. }
  97495. }
  97496. declare module BABYLON.Debug {
  97497. /**
  97498. * Used to show the physics impostor around the specific mesh
  97499. */
  97500. export class PhysicsViewer {
  97501. /** @hidden */
  97502. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  97503. /** @hidden */
  97504. protected _meshes: Array<Nullable<AbstractMesh>>;
  97505. /** @hidden */
  97506. protected _scene: Nullable<Scene>;
  97507. /** @hidden */
  97508. protected _numMeshes: number;
  97509. /** @hidden */
  97510. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  97511. private _renderFunction;
  97512. private _utilityLayer;
  97513. private _debugBoxMesh;
  97514. private _debugSphereMesh;
  97515. private _debugMaterial;
  97516. /**
  97517. * Creates a new PhysicsViewer
  97518. * @param scene defines the hosting scene
  97519. */
  97520. constructor(scene: Scene);
  97521. /** @hidden */
  97522. protected _updateDebugMeshes(): void;
  97523. /**
  97524. * Renders a specified physic impostor
  97525. * @param impostor defines the impostor to render
  97526. * @returns the new debug mesh used to render the impostor
  97527. */
  97528. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  97529. /**
  97530. * Hides a specified physic impostor
  97531. * @param impostor defines the impostor to hide
  97532. */
  97533. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  97534. private _getDebugMaterial;
  97535. private _getDebugBoxMesh;
  97536. private _getDebugSphereMesh;
  97537. private _getDebugMesh;
  97538. /** Releases all resources */
  97539. dispose(): void;
  97540. }
  97541. }
  97542. declare module BABYLON {
  97543. /**
  97544. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97545. * in order to better appreciate the issue one might have.
  97546. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97547. */
  97548. export class RayHelper {
  97549. /**
  97550. * Defines the ray we are currently tryin to visualize.
  97551. */
  97552. ray: Nullable<Ray>;
  97553. private _renderPoints;
  97554. private _renderLine;
  97555. private _renderFunction;
  97556. private _scene;
  97557. private _updateToMeshFunction;
  97558. private _attachedToMesh;
  97559. private _meshSpaceDirection;
  97560. private _meshSpaceOrigin;
  97561. /**
  97562. * Helper function to create a colored helper in a scene in one line.
  97563. * @param ray Defines the ray we are currently tryin to visualize
  97564. * @param scene Defines the scene the ray is used in
  97565. * @param color Defines the color we want to see the ray in
  97566. * @returns The newly created ray helper.
  97567. */
  97568. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  97569. /**
  97570. * Instantiate a new ray helper.
  97571. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97572. * in order to better appreciate the issue one might have.
  97573. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97574. * @param ray Defines the ray we are currently tryin to visualize
  97575. */
  97576. constructor(ray: Ray);
  97577. /**
  97578. * Shows the ray we are willing to debug.
  97579. * @param scene Defines the scene the ray needs to be rendered in
  97580. * @param color Defines the color the ray needs to be rendered in
  97581. */
  97582. show(scene: Scene, color?: Color3): void;
  97583. /**
  97584. * Hides the ray we are debugging.
  97585. */
  97586. hide(): void;
  97587. private _render;
  97588. /**
  97589. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  97590. * @param mesh Defines the mesh we want the helper attached to
  97591. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  97592. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  97593. * @param length Defines the length of the ray
  97594. */
  97595. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  97596. /**
  97597. * Detach the ray helper from the mesh it has previously been attached to.
  97598. */
  97599. detachFromMesh(): void;
  97600. private _updateToMesh;
  97601. /**
  97602. * Dispose the helper and release its associated resources.
  97603. */
  97604. dispose(): void;
  97605. }
  97606. }
  97607. declare module BABYLON.Debug {
  97608. /**
  97609. * Class used to render a debug view of a given skeleton
  97610. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  97611. */
  97612. export class SkeletonViewer {
  97613. /** defines the skeleton to render */
  97614. skeleton: Skeleton;
  97615. /** defines the mesh attached to the skeleton */
  97616. mesh: AbstractMesh;
  97617. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  97618. autoUpdateBonesMatrices: boolean;
  97619. /** defines the rendering group id to use with the viewer */
  97620. renderingGroupId: number;
  97621. /** Gets or sets the color used to render the skeleton */
  97622. color: Color3;
  97623. private _scene;
  97624. private _debugLines;
  97625. private _debugMesh;
  97626. private _isEnabled;
  97627. private _renderFunction;
  97628. private _utilityLayer;
  97629. /**
  97630. * Returns the mesh used to render the bones
  97631. */
  97632. readonly debugMesh: Nullable<LinesMesh>;
  97633. /**
  97634. * Creates a new SkeletonViewer
  97635. * @param skeleton defines the skeleton to render
  97636. * @param mesh defines the mesh attached to the skeleton
  97637. * @param scene defines the hosting scene
  97638. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  97639. * @param renderingGroupId defines the rendering group id to use with the viewer
  97640. */
  97641. constructor(
  97642. /** defines the skeleton to render */
  97643. skeleton: Skeleton,
  97644. /** defines the mesh attached to the skeleton */
  97645. mesh: AbstractMesh, scene: Scene,
  97646. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  97647. autoUpdateBonesMatrices?: boolean,
  97648. /** defines the rendering group id to use with the viewer */
  97649. renderingGroupId?: number);
  97650. /** Gets or sets a boolean indicating if the viewer is enabled */
  97651. isEnabled: boolean;
  97652. private _getBonePosition;
  97653. private _getLinesForBonesWithLength;
  97654. private _getLinesForBonesNoLength;
  97655. /** Update the viewer to sync with current skeleton state */
  97656. update(): void;
  97657. /** Release associated resources */
  97658. dispose(): void;
  97659. }
  97660. }
  97661. declare module BABYLON {
  97662. /**
  97663. * Options to create the null engine
  97664. */
  97665. export class NullEngineOptions {
  97666. /**
  97667. * Render width (Default: 512)
  97668. */
  97669. renderWidth: number;
  97670. /**
  97671. * Render height (Default: 256)
  97672. */
  97673. renderHeight: number;
  97674. /**
  97675. * Texture size (Default: 512)
  97676. */
  97677. textureSize: number;
  97678. /**
  97679. * If delta time between frames should be constant
  97680. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97681. */
  97682. deterministicLockstep: boolean;
  97683. /**
  97684. * Maximum about of steps between frames (Default: 4)
  97685. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97686. */
  97687. lockstepMaxSteps: number;
  97688. }
  97689. /**
  97690. * The null engine class provides support for headless version of babylon.js.
  97691. * This can be used in server side scenario or for testing purposes
  97692. */
  97693. export class NullEngine extends Engine {
  97694. private _options;
  97695. /**
  97696. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97697. */
  97698. isDeterministicLockStep(): boolean;
  97699. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  97700. getLockstepMaxSteps(): number;
  97701. /**
  97702. * Sets hardware scaling, used to save performance if needed
  97703. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97704. */
  97705. getHardwareScalingLevel(): number;
  97706. constructor(options?: NullEngineOptions);
  97707. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  97708. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  97709. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  97710. getRenderWidth(useScreen?: boolean): number;
  97711. getRenderHeight(useScreen?: boolean): number;
  97712. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  97713. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  97714. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  97715. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  97716. bindSamplers(effect: Effect): void;
  97717. enableEffect(effect: Effect): void;
  97718. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97719. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  97720. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  97721. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  97722. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  97723. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  97724. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  97725. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  97726. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  97727. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  97728. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  97729. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  97730. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  97731. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  97732. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  97733. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  97734. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  97735. setFloat(uniform: WebGLUniformLocation, value: number): void;
  97736. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  97737. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  97738. setBool(uniform: WebGLUniformLocation, bool: number): void;
  97739. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  97740. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  97741. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  97742. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97743. bindBuffers(vertexBuffers: {
  97744. [key: string]: VertexBuffer;
  97745. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  97746. wipeCaches(bruteForce?: boolean): void;
  97747. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  97748. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  97749. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97750. /** @hidden */
  97751. _createTexture(): WebGLTexture;
  97752. /** @hidden */
  97753. _releaseTexture(texture: InternalTexture): void;
  97754. 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;
  97755. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97756. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97757. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  97758. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  97759. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  97760. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  97761. areAllEffectsReady(): boolean;
  97762. /**
  97763. * @hidden
  97764. * Get the current error code of the webGL context
  97765. * @returns the error code
  97766. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97767. */
  97768. getError(): number;
  97769. /** @hidden */
  97770. _getUnpackAlignement(): number;
  97771. /** @hidden */
  97772. _unpackFlipY(value: boolean): void;
  97773. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  97774. /**
  97775. * Updates a dynamic vertex buffer.
  97776. * @param vertexBuffer the vertex buffer to update
  97777. * @param data the data used to update the vertex buffer
  97778. * @param byteOffset the byte offset of the data (optional)
  97779. * @param byteLength the byte length of the data (optional)
  97780. */
  97781. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  97782. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  97783. /** @hidden */
  97784. _bindTexture(channel: number, texture: InternalTexture): void;
  97785. /** @hidden */
  97786. _releaseBuffer(buffer: WebGLBuffer): boolean;
  97787. releaseEffects(): void;
  97788. displayLoadingUI(): void;
  97789. hideLoadingUI(): void;
  97790. /** @hidden */
  97791. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97792. /** @hidden */
  97793. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97794. /** @hidden */
  97795. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97796. /** @hidden */
  97797. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  97798. }
  97799. }
  97800. declare module BABYLON {
  97801. /** @hidden */
  97802. export class _OcclusionDataStorage {
  97803. /** @hidden */
  97804. occlusionInternalRetryCounter: number;
  97805. /** @hidden */
  97806. isOcclusionQueryInProgress: boolean;
  97807. /** @hidden */
  97808. isOccluded: boolean;
  97809. /** @hidden */
  97810. occlusionRetryCount: number;
  97811. /** @hidden */
  97812. occlusionType: number;
  97813. /** @hidden */
  97814. occlusionQueryAlgorithmType: number;
  97815. }
  97816. interface Engine {
  97817. /**
  97818. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  97819. * @return the new query
  97820. */
  97821. createQuery(): WebGLQuery;
  97822. /**
  97823. * Delete and release a webGL query
  97824. * @param query defines the query to delete
  97825. * @return the current engine
  97826. */
  97827. deleteQuery(query: WebGLQuery): Engine;
  97828. /**
  97829. * Check if a given query has resolved and got its value
  97830. * @param query defines the query to check
  97831. * @returns true if the query got its value
  97832. */
  97833. isQueryResultAvailable(query: WebGLQuery): boolean;
  97834. /**
  97835. * Gets the value of a given query
  97836. * @param query defines the query to check
  97837. * @returns the value of the query
  97838. */
  97839. getQueryResult(query: WebGLQuery): number;
  97840. /**
  97841. * Initiates an occlusion query
  97842. * @param algorithmType defines the algorithm to use
  97843. * @param query defines the query to use
  97844. * @returns the current engine
  97845. * @see http://doc.babylonjs.com/features/occlusionquery
  97846. */
  97847. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  97848. /**
  97849. * Ends an occlusion query
  97850. * @see http://doc.babylonjs.com/features/occlusionquery
  97851. * @param algorithmType defines the algorithm to use
  97852. * @returns the current engine
  97853. */
  97854. endOcclusionQuery(algorithmType: number): Engine;
  97855. /**
  97856. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  97857. * Please note that only one query can be issued at a time
  97858. * @returns a time token used to track the time span
  97859. */
  97860. startTimeQuery(): Nullable<_TimeToken>;
  97861. /**
  97862. * Ends a time query
  97863. * @param token defines the token used to measure the time span
  97864. * @returns the time spent (in ns)
  97865. */
  97866. endTimeQuery(token: _TimeToken): int;
  97867. /** @hidden */
  97868. _currentNonTimestampToken: Nullable<_TimeToken>;
  97869. /** @hidden */
  97870. _createTimeQuery(): WebGLQuery;
  97871. /** @hidden */
  97872. _deleteTimeQuery(query: WebGLQuery): void;
  97873. /** @hidden */
  97874. _getGlAlgorithmType(algorithmType: number): number;
  97875. /** @hidden */
  97876. _getTimeQueryResult(query: WebGLQuery): any;
  97877. /** @hidden */
  97878. _getTimeQueryAvailability(query: WebGLQuery): any;
  97879. }
  97880. interface AbstractMesh {
  97881. /**
  97882. * Backing filed
  97883. * @hidden
  97884. */
  97885. __occlusionDataStorage: _OcclusionDataStorage;
  97886. /**
  97887. * Access property
  97888. * @hidden
  97889. */
  97890. _occlusionDataStorage: _OcclusionDataStorage;
  97891. /**
  97892. * 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.
  97893. * The default value is -1 which means don't break the query and wait till the result
  97894. * @see http://doc.babylonjs.com/features/occlusionquery
  97895. */
  97896. occlusionRetryCount: number;
  97897. /**
  97898. * 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:
  97899. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  97900. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  97901. * * 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.
  97902. * @see http://doc.babylonjs.com/features/occlusionquery
  97903. */
  97904. occlusionType: number;
  97905. /**
  97906. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  97907. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  97908. * * 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.
  97909. * @see http://doc.babylonjs.com/features/occlusionquery
  97910. */
  97911. occlusionQueryAlgorithmType: number;
  97912. /**
  97913. * 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
  97914. * @see http://doc.babylonjs.com/features/occlusionquery
  97915. */
  97916. isOccluded: boolean;
  97917. /**
  97918. * Flag to check the progress status of the query
  97919. * @see http://doc.babylonjs.com/features/occlusionquery
  97920. */
  97921. isOcclusionQueryInProgress: boolean;
  97922. }
  97923. }
  97924. declare module BABYLON {
  97925. /** @hidden */
  97926. export var _forceTransformFeedbackToBundle: boolean;
  97927. interface Engine {
  97928. /**
  97929. * Creates a webGL transform feedback object
  97930. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  97931. * @returns the webGL transform feedback object
  97932. */
  97933. createTransformFeedback(): WebGLTransformFeedback;
  97934. /**
  97935. * Delete a webGL transform feedback object
  97936. * @param value defines the webGL transform feedback object to delete
  97937. */
  97938. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  97939. /**
  97940. * Bind a webGL transform feedback object to the webgl context
  97941. * @param value defines the webGL transform feedback object to bind
  97942. */
  97943. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  97944. /**
  97945. * Begins a transform feedback operation
  97946. * @param usePoints defines if points or triangles must be used
  97947. */
  97948. beginTransformFeedback(usePoints: boolean): void;
  97949. /**
  97950. * Ends a transform feedback operation
  97951. */
  97952. endTransformFeedback(): void;
  97953. /**
  97954. * Specify the varyings to use with transform feedback
  97955. * @param program defines the associated webGL program
  97956. * @param value defines the list of strings representing the varying names
  97957. */
  97958. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  97959. /**
  97960. * Bind a webGL buffer for a transform feedback operation
  97961. * @param value defines the webGL buffer to bind
  97962. */
  97963. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  97964. }
  97965. }
  97966. declare module BABYLON {
  97967. /**
  97968. * Gather the list of clipboard event types as constants.
  97969. */
  97970. export class ClipboardEventTypes {
  97971. /**
  97972. * The clipboard event is fired when a copy command is active (pressed).
  97973. */
  97974. static readonly COPY: number;
  97975. /**
  97976. * The clipboard event is fired when a cut command is active (pressed).
  97977. */
  97978. static readonly CUT: number;
  97979. /**
  97980. * The clipboard event is fired when a paste command is active (pressed).
  97981. */
  97982. static readonly PASTE: number;
  97983. }
  97984. /**
  97985. * This class is used to store clipboard related info for the onClipboardObservable event.
  97986. */
  97987. export class ClipboardInfo {
  97988. /**
  97989. * Defines the type of event (BABYLON.ClipboardEventTypes)
  97990. */
  97991. type: number;
  97992. /**
  97993. * Defines the related dom event
  97994. */
  97995. event: ClipboardEvent;
  97996. /**
  97997. *Creates an instance of ClipboardInfo.
  97998. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  97999. * @param event Defines the related dom event
  98000. */
  98001. constructor(
  98002. /**
  98003. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98004. */
  98005. type: number,
  98006. /**
  98007. * Defines the related dom event
  98008. */
  98009. event: ClipboardEvent);
  98010. /**
  98011. * Get the clipboard event's type from the keycode.
  98012. * @param keyCode Defines the keyCode for the current keyboard event.
  98013. * @return {number}
  98014. */
  98015. static GetTypeFromCharacter(keyCode: number): number;
  98016. }
  98017. }
  98018. declare module BABYLON {
  98019. /**
  98020. * Class used to represent data loading progression
  98021. */
  98022. export class SceneLoaderProgressEvent {
  98023. /** defines if data length to load can be evaluated */
  98024. readonly lengthComputable: boolean;
  98025. /** defines the loaded data length */
  98026. readonly loaded: number;
  98027. /** defines the data length to load */
  98028. readonly total: number;
  98029. /**
  98030. * Create a new progress event
  98031. * @param lengthComputable defines if data length to load can be evaluated
  98032. * @param loaded defines the loaded data length
  98033. * @param total defines the data length to load
  98034. */
  98035. constructor(
  98036. /** defines if data length to load can be evaluated */
  98037. lengthComputable: boolean,
  98038. /** defines the loaded data length */
  98039. loaded: number,
  98040. /** defines the data length to load */
  98041. total: number);
  98042. /**
  98043. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  98044. * @param event defines the source event
  98045. * @returns a new SceneLoaderProgressEvent
  98046. */
  98047. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  98048. }
  98049. /**
  98050. * Interface used by SceneLoader plugins to define supported file extensions
  98051. */
  98052. export interface ISceneLoaderPluginExtensions {
  98053. /**
  98054. * Defines the list of supported extensions
  98055. */
  98056. [extension: string]: {
  98057. isBinary: boolean;
  98058. };
  98059. }
  98060. /**
  98061. * Interface used by SceneLoader plugin factory
  98062. */
  98063. export interface ISceneLoaderPluginFactory {
  98064. /**
  98065. * Defines the name of the factory
  98066. */
  98067. name: string;
  98068. /**
  98069. * Function called to create a new plugin
  98070. * @return the new plugin
  98071. */
  98072. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  98073. /**
  98074. * Boolean indicating if the plugin can direct load specific data
  98075. */
  98076. canDirectLoad?: (data: string) => boolean;
  98077. }
  98078. /**
  98079. * Interface used to define a SceneLoader plugin
  98080. */
  98081. export interface ISceneLoaderPlugin {
  98082. /**
  98083. * The friendly name of this plugin.
  98084. */
  98085. name: string;
  98086. /**
  98087. * The file extensions supported by this plugin.
  98088. */
  98089. extensions: string | ISceneLoaderPluginExtensions;
  98090. /**
  98091. * Import meshes into a scene.
  98092. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98093. * @param scene The scene to import into
  98094. * @param data The data to import
  98095. * @param rootUrl The root url for scene and resources
  98096. * @param meshes The meshes array to import into
  98097. * @param particleSystems The particle systems array to import into
  98098. * @param skeletons The skeletons array to import into
  98099. * @param onError The callback when import fails
  98100. * @returns True if successful or false otherwise
  98101. */
  98102. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  98103. /**
  98104. * Load into a scene.
  98105. * @param scene The scene to load into
  98106. * @param data The data to import
  98107. * @param rootUrl The root url for scene and resources
  98108. * @param onError The callback when import fails
  98109. * @returns true if successful or false otherwise
  98110. */
  98111. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  98112. /**
  98113. * The callback that returns true if the data can be directly loaded.
  98114. */
  98115. canDirectLoad?: (data: string) => boolean;
  98116. /**
  98117. * The callback that allows custom handling of the root url based on the response url.
  98118. */
  98119. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98120. /**
  98121. * Load into an asset container.
  98122. * @param scene The scene to load into
  98123. * @param data The data to import
  98124. * @param rootUrl The root url for scene and resources
  98125. * @param onError The callback when import fails
  98126. * @returns The loaded asset container
  98127. */
  98128. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  98129. }
  98130. /**
  98131. * Interface used to define an async SceneLoader plugin
  98132. */
  98133. export interface ISceneLoaderPluginAsync {
  98134. /**
  98135. * The friendly name of this plugin.
  98136. */
  98137. name: string;
  98138. /**
  98139. * The file extensions supported by this plugin.
  98140. */
  98141. extensions: string | ISceneLoaderPluginExtensions;
  98142. /**
  98143. * Import meshes into a scene.
  98144. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98145. * @param scene The scene to import into
  98146. * @param data The data to import
  98147. * @param rootUrl The root url for scene and resources
  98148. * @param onProgress The callback when the load progresses
  98149. * @param fileName Defines the name of the file to load
  98150. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  98151. */
  98152. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  98153. meshes: AbstractMesh[];
  98154. particleSystems: IParticleSystem[];
  98155. skeletons: Skeleton[];
  98156. animationGroups: AnimationGroup[];
  98157. }>;
  98158. /**
  98159. * Load into a scene.
  98160. * @param scene The scene to load into
  98161. * @param data The data to import
  98162. * @param rootUrl The root url for scene and resources
  98163. * @param onProgress The callback when the load progresses
  98164. * @param fileName Defines the name of the file to load
  98165. * @returns Nothing
  98166. */
  98167. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  98168. /**
  98169. * The callback that returns true if the data can be directly loaded.
  98170. */
  98171. canDirectLoad?: (data: string) => boolean;
  98172. /**
  98173. * The callback that allows custom handling of the root url based on the response url.
  98174. */
  98175. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98176. /**
  98177. * Load into an asset container.
  98178. * @param scene The scene to load into
  98179. * @param data The data to import
  98180. * @param rootUrl The root url for scene and resources
  98181. * @param onProgress The callback when the load progresses
  98182. * @param fileName Defines the name of the file to load
  98183. * @returns The loaded asset container
  98184. */
  98185. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  98186. }
  98187. /**
  98188. * Class used to load scene from various file formats using registered plugins
  98189. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  98190. */
  98191. export class SceneLoader {
  98192. /**
  98193. * No logging while loading
  98194. */
  98195. static readonly NO_LOGGING: number;
  98196. /**
  98197. * Minimal logging while loading
  98198. */
  98199. static readonly MINIMAL_LOGGING: number;
  98200. /**
  98201. * Summary logging while loading
  98202. */
  98203. static readonly SUMMARY_LOGGING: number;
  98204. /**
  98205. * Detailled logging while loading
  98206. */
  98207. static readonly DETAILED_LOGGING: number;
  98208. /**
  98209. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  98210. */
  98211. static ForceFullSceneLoadingForIncremental: boolean;
  98212. /**
  98213. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  98214. */
  98215. static ShowLoadingScreen: boolean;
  98216. /**
  98217. * Defines the current logging level (while loading the scene)
  98218. * @ignorenaming
  98219. */
  98220. static loggingLevel: number;
  98221. /**
  98222. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  98223. */
  98224. static CleanBoneMatrixWeights: boolean;
  98225. /**
  98226. * Event raised when a plugin is used to load a scene
  98227. */
  98228. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  98229. private static _registeredPlugins;
  98230. private static _getDefaultPlugin;
  98231. private static _getPluginForExtension;
  98232. private static _getPluginForDirectLoad;
  98233. private static _getPluginForFilename;
  98234. private static _getDirectLoad;
  98235. private static _loadData;
  98236. private static _getFileInfo;
  98237. /**
  98238. * Gets a plugin that can load the given extension
  98239. * @param extension defines the extension to load
  98240. * @returns a plugin or null if none works
  98241. */
  98242. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  98243. /**
  98244. * Gets a boolean indicating that the given extension can be loaded
  98245. * @param extension defines the extension to load
  98246. * @returns true if the extension is supported
  98247. */
  98248. static IsPluginForExtensionAvailable(extension: string): boolean;
  98249. /**
  98250. * Adds a new plugin to the list of registered plugins
  98251. * @param plugin defines the plugin to add
  98252. */
  98253. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  98254. /**
  98255. * Import meshes into a scene
  98256. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98257. * @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)
  98258. * @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)
  98259. * @param scene the instance of BABYLON.Scene to append to
  98260. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  98261. * @param onProgress a callback with a progress event for each file being loaded
  98262. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98263. * @param pluginExtension the extension used to determine the plugin
  98264. * @returns The loaded plugin
  98265. */
  98266. 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>;
  98267. /**
  98268. * Import meshes into a scene
  98269. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98270. * @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)
  98271. * @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)
  98272. * @param scene the instance of BABYLON.Scene to append to
  98273. * @param onProgress a callback with a progress event for each file being loaded
  98274. * @param pluginExtension the extension used to determine the plugin
  98275. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  98276. */
  98277. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  98278. meshes: AbstractMesh[];
  98279. particleSystems: IParticleSystem[];
  98280. skeletons: Skeleton[];
  98281. animationGroups: AnimationGroup[];
  98282. }>;
  98283. /**
  98284. * Load a scene
  98285. * @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)
  98286. * @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)
  98287. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98288. * @param onSuccess a callback with the scene when import succeeds
  98289. * @param onProgress a callback with a progress event for each file being loaded
  98290. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98291. * @param pluginExtension the extension used to determine the plugin
  98292. * @returns The loaded plugin
  98293. */
  98294. 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>;
  98295. /**
  98296. * Load a scene
  98297. * @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)
  98298. * @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)
  98299. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98300. * @param onProgress a callback with a progress event for each file being loaded
  98301. * @param pluginExtension the extension used to determine the plugin
  98302. * @returns The loaded scene
  98303. */
  98304. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98305. /**
  98306. * Append a scene
  98307. * @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)
  98308. * @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)
  98309. * @param scene is the instance of BABYLON.Scene to append to
  98310. * @param onSuccess a callback with the scene when import succeeds
  98311. * @param onProgress a callback with a progress event for each file being loaded
  98312. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98313. * @param pluginExtension the extension used to determine the plugin
  98314. * @returns The loaded plugin
  98315. */
  98316. 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>;
  98317. /**
  98318. * Append a scene
  98319. * @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)
  98320. * @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)
  98321. * @param scene is the instance of BABYLON.Scene to append to
  98322. * @param onProgress a callback with a progress event for each file being loaded
  98323. * @param pluginExtension the extension used to determine the plugin
  98324. * @returns The given scene
  98325. */
  98326. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98327. /**
  98328. * Load a scene into an asset container
  98329. * @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)
  98330. * @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)
  98331. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  98332. * @param onSuccess a callback with the scene when import succeeds
  98333. * @param onProgress a callback with a progress event for each file being loaded
  98334. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98335. * @param pluginExtension the extension used to determine the plugin
  98336. * @returns The loaded plugin
  98337. */
  98338. 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>;
  98339. /**
  98340. * Load a scene into an asset container
  98341. * @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)
  98342. * @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)
  98343. * @param scene is the instance of Scene to append to
  98344. * @param onProgress a callback with a progress event for each file being loaded
  98345. * @param pluginExtension the extension used to determine the plugin
  98346. * @returns The loaded asset container
  98347. */
  98348. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  98349. }
  98350. }
  98351. declare module BABYLON {
  98352. /**
  98353. * Google Daydream controller
  98354. */
  98355. export class DaydreamController extends WebVRController {
  98356. /**
  98357. * Base Url for the controller model.
  98358. */
  98359. static MODEL_BASE_URL: string;
  98360. /**
  98361. * File name for the controller model.
  98362. */
  98363. static MODEL_FILENAME: string;
  98364. /**
  98365. * Gamepad Id prefix used to identify Daydream Controller.
  98366. */
  98367. static readonly GAMEPAD_ID_PREFIX: string;
  98368. /**
  98369. * Creates a new DaydreamController from a gamepad
  98370. * @param vrGamepad the gamepad that the controller should be created from
  98371. */
  98372. constructor(vrGamepad: any);
  98373. /**
  98374. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98375. * @param scene scene in which to add meshes
  98376. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98377. */
  98378. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98379. /**
  98380. * Called once for each button that changed state since the last frame
  98381. * @param buttonIdx Which button index changed
  98382. * @param state New state of the button
  98383. * @param changes Which properties on the state changed since last frame
  98384. */
  98385. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98386. }
  98387. }
  98388. declare module BABYLON {
  98389. /**
  98390. * Gear VR Controller
  98391. */
  98392. export class GearVRController extends WebVRController {
  98393. /**
  98394. * Base Url for the controller model.
  98395. */
  98396. static MODEL_BASE_URL: string;
  98397. /**
  98398. * File name for the controller model.
  98399. */
  98400. static MODEL_FILENAME: string;
  98401. /**
  98402. * Gamepad Id prefix used to identify this controller.
  98403. */
  98404. static readonly GAMEPAD_ID_PREFIX: string;
  98405. private readonly _buttonIndexToObservableNameMap;
  98406. /**
  98407. * Creates a new GearVRController from a gamepad
  98408. * @param vrGamepad the gamepad that the controller should be created from
  98409. */
  98410. constructor(vrGamepad: any);
  98411. /**
  98412. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98413. * @param scene scene in which to add meshes
  98414. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98415. */
  98416. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98417. /**
  98418. * Called once for each button that changed state since the last frame
  98419. * @param buttonIdx Which button index changed
  98420. * @param state New state of the button
  98421. * @param changes Which properties on the state changed since last frame
  98422. */
  98423. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98424. }
  98425. }
  98426. declare module BABYLON {
  98427. /**
  98428. * Generic Controller
  98429. */
  98430. export class GenericController extends WebVRController {
  98431. /**
  98432. * Base Url for the controller model.
  98433. */
  98434. static readonly MODEL_BASE_URL: string;
  98435. /**
  98436. * File name for the controller model.
  98437. */
  98438. static readonly MODEL_FILENAME: string;
  98439. /**
  98440. * Creates a new GenericController from a gamepad
  98441. * @param vrGamepad the gamepad that the controller should be created from
  98442. */
  98443. constructor(vrGamepad: any);
  98444. /**
  98445. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98446. * @param scene scene in which to add meshes
  98447. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98448. */
  98449. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98450. /**
  98451. * Called once for each button that changed state since the last frame
  98452. * @param buttonIdx Which button index changed
  98453. * @param state New state of the button
  98454. * @param changes Which properties on the state changed since last frame
  98455. */
  98456. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98457. }
  98458. }
  98459. declare module BABYLON {
  98460. /**
  98461. * Oculus Touch Controller
  98462. */
  98463. export class OculusTouchController extends WebVRController {
  98464. /**
  98465. * Base Url for the controller model.
  98466. */
  98467. static MODEL_BASE_URL: string;
  98468. /**
  98469. * File name for the left controller model.
  98470. */
  98471. static MODEL_LEFT_FILENAME: string;
  98472. /**
  98473. * File name for the right controller model.
  98474. */
  98475. static MODEL_RIGHT_FILENAME: string;
  98476. /**
  98477. * Fired when the secondary trigger on this controller is modified
  98478. */
  98479. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98480. /**
  98481. * Fired when the thumb rest on this controller is modified
  98482. */
  98483. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  98484. /**
  98485. * Creates a new OculusTouchController from a gamepad
  98486. * @param vrGamepad the gamepad that the controller should be created from
  98487. */
  98488. constructor(vrGamepad: any);
  98489. /**
  98490. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98491. * @param scene scene in which to add meshes
  98492. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98493. */
  98494. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98495. /**
  98496. * Fired when the A button on this controller is modified
  98497. */
  98498. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98499. /**
  98500. * Fired when the B button on this controller is modified
  98501. */
  98502. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98503. /**
  98504. * Fired when the X button on this controller is modified
  98505. */
  98506. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98507. /**
  98508. * Fired when the Y button on this controller is modified
  98509. */
  98510. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98511. /**
  98512. * Called once for each button that changed state since the last frame
  98513. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  98514. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  98515. * 2) secondary trigger (same)
  98516. * 3) A (right) X (left), touch, pressed = value
  98517. * 4) B / Y
  98518. * 5) thumb rest
  98519. * @param buttonIdx Which button index changed
  98520. * @param state New state of the button
  98521. * @param changes Which properties on the state changed since last frame
  98522. */
  98523. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98524. }
  98525. }
  98526. declare module BABYLON {
  98527. /**
  98528. * Vive Controller
  98529. */
  98530. export class ViveController extends WebVRController {
  98531. /**
  98532. * Base Url for the controller model.
  98533. */
  98534. static MODEL_BASE_URL: string;
  98535. /**
  98536. * File name for the controller model.
  98537. */
  98538. static MODEL_FILENAME: string;
  98539. /**
  98540. * Creates a new ViveController from a gamepad
  98541. * @param vrGamepad the gamepad that the controller should be created from
  98542. */
  98543. constructor(vrGamepad: any);
  98544. /**
  98545. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98546. * @param scene scene in which to add meshes
  98547. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98548. */
  98549. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98550. /**
  98551. * Fired when the left button on this controller is modified
  98552. */
  98553. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98554. /**
  98555. * Fired when the right button on this controller is modified
  98556. */
  98557. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98558. /**
  98559. * Fired when the menu button on this controller is modified
  98560. */
  98561. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98562. /**
  98563. * Called once for each button that changed state since the last frame
  98564. * Vive mapping:
  98565. * 0: touchpad
  98566. * 1: trigger
  98567. * 2: left AND right buttons
  98568. * 3: menu button
  98569. * @param buttonIdx Which button index changed
  98570. * @param state New state of the button
  98571. * @param changes Which properties on the state changed since last frame
  98572. */
  98573. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98574. }
  98575. }
  98576. declare module BABYLON {
  98577. /**
  98578. * Defines the WindowsMotionController object that the state of the windows motion controller
  98579. */
  98580. export class WindowsMotionController extends WebVRController {
  98581. /**
  98582. * The base url used to load the left and right controller models
  98583. */
  98584. static MODEL_BASE_URL: string;
  98585. /**
  98586. * The name of the left controller model file
  98587. */
  98588. static MODEL_LEFT_FILENAME: string;
  98589. /**
  98590. * The name of the right controller model file
  98591. */
  98592. static MODEL_RIGHT_FILENAME: string;
  98593. /**
  98594. * The controller name prefix for this controller type
  98595. */
  98596. static readonly GAMEPAD_ID_PREFIX: string;
  98597. /**
  98598. * The controller id pattern for this controller type
  98599. */
  98600. private static readonly GAMEPAD_ID_PATTERN;
  98601. private _loadedMeshInfo;
  98602. private readonly _mapping;
  98603. /**
  98604. * Fired when the trackpad on this controller is clicked
  98605. */
  98606. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  98607. /**
  98608. * Fired when the trackpad on this controller is modified
  98609. */
  98610. onTrackpadValuesChangedObservable: Observable<StickValues>;
  98611. /**
  98612. * The current x and y values of this controller's trackpad
  98613. */
  98614. trackpad: StickValues;
  98615. /**
  98616. * Creates a new WindowsMotionController from a gamepad
  98617. * @param vrGamepad the gamepad that the controller should be created from
  98618. */
  98619. constructor(vrGamepad: any);
  98620. /**
  98621. * Fired when the trigger on this controller is modified
  98622. */
  98623. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98624. /**
  98625. * Fired when the menu button on this controller is modified
  98626. */
  98627. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98628. /**
  98629. * Fired when the grip button on this controller is modified
  98630. */
  98631. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98632. /**
  98633. * Fired when the thumbstick button on this controller is modified
  98634. */
  98635. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98636. /**
  98637. * Fired when the touchpad button on this controller is modified
  98638. */
  98639. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98640. /**
  98641. * Fired when the touchpad values on this controller are modified
  98642. */
  98643. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  98644. private _updateTrackpad;
  98645. /**
  98646. * Called once per frame by the engine.
  98647. */
  98648. update(): void;
  98649. /**
  98650. * Called once for each button that changed state since the last frame
  98651. * @param buttonIdx Which button index changed
  98652. * @param state New state of the button
  98653. * @param changes Which properties on the state changed since last frame
  98654. */
  98655. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98656. /**
  98657. * Moves the buttons on the controller mesh based on their current state
  98658. * @param buttonName the name of the button to move
  98659. * @param buttonValue the value of the button which determines the buttons new position
  98660. */
  98661. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  98662. /**
  98663. * Moves the axis on the controller mesh based on its current state
  98664. * @param axis the index of the axis
  98665. * @param axisValue the value of the axis which determines the meshes new position
  98666. * @hidden
  98667. */
  98668. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  98669. /**
  98670. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98671. * @param scene scene in which to add meshes
  98672. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98673. */
  98674. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  98675. /**
  98676. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  98677. * can be transformed by button presses and axes values, based on this._mapping.
  98678. *
  98679. * @param scene scene in which the meshes exist
  98680. * @param meshes list of meshes that make up the controller model to process
  98681. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  98682. */
  98683. private processModel;
  98684. private createMeshInfo;
  98685. /**
  98686. * Gets the ray of the controller in the direction the controller is pointing
  98687. * @param length the length the resulting ray should be
  98688. * @returns a ray in the direction the controller is pointing
  98689. */
  98690. getForwardRay(length?: number): Ray;
  98691. /**
  98692. * Disposes of the controller
  98693. */
  98694. dispose(): void;
  98695. }
  98696. }
  98697. declare module BABYLON {
  98698. /**
  98699. * Single axis scale gizmo
  98700. */
  98701. export class AxisScaleGizmo extends Gizmo {
  98702. private _coloredMaterial;
  98703. /**
  98704. * Drag behavior responsible for the gizmos dragging interactions
  98705. */
  98706. dragBehavior: PointerDragBehavior;
  98707. private _pointerObserver;
  98708. /**
  98709. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98710. */
  98711. snapDistance: number;
  98712. /**
  98713. * Event that fires each time the gizmo snaps to a new location.
  98714. * * snapDistance is the the change in distance
  98715. */
  98716. onSnapObservable: Observable<{
  98717. snapDistance: number;
  98718. }>;
  98719. /**
  98720. * If the scaling operation should be done on all axis (default: false)
  98721. */
  98722. uniformScaling: boolean;
  98723. /**
  98724. * Creates an AxisScaleGizmo
  98725. * @param gizmoLayer The utility layer the gizmo will be added to
  98726. * @param dragAxis The axis which the gizmo will be able to scale on
  98727. * @param color The color of the gizmo
  98728. */
  98729. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98730. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98731. /**
  98732. * Disposes of the gizmo
  98733. */
  98734. dispose(): void;
  98735. /**
  98736. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  98737. * @param mesh The mesh to replace the default mesh of the gizmo
  98738. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  98739. */
  98740. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  98741. }
  98742. }
  98743. declare module BABYLON {
  98744. /**
  98745. * Bounding box gizmo
  98746. */
  98747. export class BoundingBoxGizmo extends Gizmo {
  98748. private _lineBoundingBox;
  98749. private _rotateSpheresParent;
  98750. private _scaleBoxesParent;
  98751. private _boundingDimensions;
  98752. private _renderObserver;
  98753. private _pointerObserver;
  98754. private _scaleDragSpeed;
  98755. private _tmpQuaternion;
  98756. private _tmpVector;
  98757. private _tmpRotationMatrix;
  98758. /**
  98759. * 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)
  98760. */
  98761. ignoreChildren: boolean;
  98762. /**
  98763. * 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)
  98764. */
  98765. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  98766. /**
  98767. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  98768. */
  98769. rotationSphereSize: number;
  98770. /**
  98771. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  98772. */
  98773. scaleBoxSize: number;
  98774. /**
  98775. * 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)
  98776. */
  98777. fixedDragMeshScreenSize: boolean;
  98778. /**
  98779. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  98780. */
  98781. fixedDragMeshScreenSizeDistanceFactor: number;
  98782. /**
  98783. * Fired when a rotation sphere or scale box is dragged
  98784. */
  98785. onDragStartObservable: Observable<{}>;
  98786. /**
  98787. * Fired when a scale box is dragged
  98788. */
  98789. onScaleBoxDragObservable: Observable<{}>;
  98790. /**
  98791. * Fired when a scale box drag is ended
  98792. */
  98793. onScaleBoxDragEndObservable: Observable<{}>;
  98794. /**
  98795. * Fired when a rotation sphere is dragged
  98796. */
  98797. onRotationSphereDragObservable: Observable<{}>;
  98798. /**
  98799. * Fired when a rotation sphere drag is ended
  98800. */
  98801. onRotationSphereDragEndObservable: Observable<{}>;
  98802. /**
  98803. * 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)
  98804. */
  98805. scalePivot: Nullable<Vector3>;
  98806. private _anchorMesh;
  98807. private _existingMeshScale;
  98808. private _dragMesh;
  98809. private pointerDragBehavior;
  98810. private coloredMaterial;
  98811. private hoverColoredMaterial;
  98812. /**
  98813. * Sets the color of the bounding box gizmo
  98814. * @param color the color to set
  98815. */
  98816. setColor(color: Color3): void;
  98817. /**
  98818. * Creates an BoundingBoxGizmo
  98819. * @param gizmoLayer The utility layer the gizmo will be added to
  98820. * @param color The color of the gizmo
  98821. */
  98822. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98823. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98824. private _selectNode;
  98825. /**
  98826. * Updates the bounding box information for the Gizmo
  98827. */
  98828. updateBoundingBox(): void;
  98829. private _updateRotationSpheres;
  98830. private _updateScaleBoxes;
  98831. /**
  98832. * Enables rotation on the specified axis and disables rotation on the others
  98833. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  98834. */
  98835. setEnabledRotationAxis(axis: string): void;
  98836. /**
  98837. * Enables/disables scaling
  98838. * @param enable if scaling should be enabled
  98839. */
  98840. setEnabledScaling(enable: boolean): void;
  98841. private _updateDummy;
  98842. /**
  98843. * Enables a pointer drag behavior on the bounding box of the gizmo
  98844. */
  98845. enableDragBehavior(): void;
  98846. /**
  98847. * Disposes of the gizmo
  98848. */
  98849. dispose(): void;
  98850. /**
  98851. * 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)
  98852. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  98853. * @returns the bounding box mesh with the passed in mesh as a child
  98854. */
  98855. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  98856. /**
  98857. * CustomMeshes are not supported by this gizmo
  98858. * @param mesh The mesh to replace the default mesh of the gizmo
  98859. */
  98860. setCustomMesh(mesh: Mesh): void;
  98861. }
  98862. }
  98863. declare module BABYLON {
  98864. /**
  98865. * Single plane rotation gizmo
  98866. */
  98867. export class PlaneRotationGizmo extends Gizmo {
  98868. /**
  98869. * Drag behavior responsible for the gizmos dragging interactions
  98870. */
  98871. dragBehavior: PointerDragBehavior;
  98872. private _pointerObserver;
  98873. /**
  98874. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  98875. */
  98876. snapDistance: number;
  98877. /**
  98878. * Event that fires each time the gizmo snaps to a new location.
  98879. * * snapDistance is the the change in distance
  98880. */
  98881. onSnapObservable: Observable<{
  98882. snapDistance: number;
  98883. }>;
  98884. /**
  98885. * Creates a PlaneRotationGizmo
  98886. * @param gizmoLayer The utility layer the gizmo will be added to
  98887. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  98888. * @param color The color of the gizmo
  98889. * @param tessellation Amount of tessellation to be used when creating rotation circles
  98890. */
  98891. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  98892. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98893. /**
  98894. * Disposes of the gizmo
  98895. */
  98896. dispose(): void;
  98897. }
  98898. }
  98899. declare module BABYLON {
  98900. /**
  98901. * Gizmo that enables rotating a mesh along 3 axis
  98902. */
  98903. export class RotationGizmo extends Gizmo {
  98904. /**
  98905. * Internal gizmo used for interactions on the x axis
  98906. */
  98907. xGizmo: PlaneRotationGizmo;
  98908. /**
  98909. * Internal gizmo used for interactions on the y axis
  98910. */
  98911. yGizmo: PlaneRotationGizmo;
  98912. /**
  98913. * Internal gizmo used for interactions on the z axis
  98914. */
  98915. zGizmo: PlaneRotationGizmo;
  98916. /** Fires an event when any of it's sub gizmos are dragged */
  98917. onDragStartObservable: Observable<{}>;
  98918. /** Fires an event when any of it's sub gizmos are released from dragging */
  98919. onDragEndObservable: Observable<{}>;
  98920. attachedMesh: Nullable<AbstractMesh>;
  98921. /**
  98922. * Creates a RotationGizmo
  98923. * @param gizmoLayer The utility layer the gizmo will be added to
  98924. * @param tessellation Amount of tessellation to be used when creating rotation circles
  98925. */
  98926. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  98927. updateGizmoRotationToMatchAttachedMesh: boolean;
  98928. /**
  98929. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98930. */
  98931. snapDistance: number;
  98932. /**
  98933. * Ratio for the scale of the gizmo (Default: 1)
  98934. */
  98935. scaleRatio: number;
  98936. /**
  98937. * Disposes of the gizmo
  98938. */
  98939. dispose(): void;
  98940. /**
  98941. * CustomMeshes are not supported by this gizmo
  98942. * @param mesh The mesh to replace the default mesh of the gizmo
  98943. */
  98944. setCustomMesh(mesh: Mesh): void;
  98945. }
  98946. }
  98947. declare module BABYLON {
  98948. /**
  98949. * Gizmo that enables dragging a mesh along 3 axis
  98950. */
  98951. export class PositionGizmo extends Gizmo {
  98952. /**
  98953. * Internal gizmo used for interactions on the x axis
  98954. */
  98955. xGizmo: AxisDragGizmo;
  98956. /**
  98957. * Internal gizmo used for interactions on the y axis
  98958. */
  98959. yGizmo: AxisDragGizmo;
  98960. /**
  98961. * Internal gizmo used for interactions on the z axis
  98962. */
  98963. zGizmo: AxisDragGizmo;
  98964. /** Fires an event when any of it's sub gizmos are dragged */
  98965. onDragStartObservable: Observable<{}>;
  98966. /** Fires an event when any of it's sub gizmos are released from dragging */
  98967. onDragEndObservable: Observable<{}>;
  98968. attachedMesh: Nullable<AbstractMesh>;
  98969. /**
  98970. * Creates a PositionGizmo
  98971. * @param gizmoLayer The utility layer the gizmo will be added to
  98972. */
  98973. constructor(gizmoLayer?: UtilityLayerRenderer);
  98974. updateGizmoRotationToMatchAttachedMesh: boolean;
  98975. /**
  98976. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98977. */
  98978. snapDistance: number;
  98979. /**
  98980. * Ratio for the scale of the gizmo (Default: 1)
  98981. */
  98982. scaleRatio: number;
  98983. /**
  98984. * Disposes of the gizmo
  98985. */
  98986. dispose(): void;
  98987. /**
  98988. * CustomMeshes are not supported by this gizmo
  98989. * @param mesh The mesh to replace the default mesh of the gizmo
  98990. */
  98991. setCustomMesh(mesh: Mesh): void;
  98992. }
  98993. }
  98994. declare module BABYLON {
  98995. /**
  98996. * Class containing static functions to help procedurally build meshes
  98997. */
  98998. export class PolyhedronBuilder {
  98999. /**
  99000. * Creates a polyhedron mesh
  99001. * * 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
  99002. * * The parameter `size` (positive float, default 1) sets the polygon size
  99003. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99004. * * 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`
  99005. * * 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
  99006. * * 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)`)
  99007. * * 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
  99008. * * 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
  99009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99012. * @param name defines the name of the mesh
  99013. * @param options defines the options used to create the mesh
  99014. * @param scene defines the hosting scene
  99015. * @returns the polyhedron mesh
  99016. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  99017. */
  99018. static CreatePolyhedron(name: string, options: {
  99019. type?: number;
  99020. size?: number;
  99021. sizeX?: number;
  99022. sizeY?: number;
  99023. sizeZ?: number;
  99024. custom?: any;
  99025. faceUV?: Vector4[];
  99026. faceColors?: Color4[];
  99027. flat?: boolean;
  99028. updatable?: boolean;
  99029. sideOrientation?: number;
  99030. frontUVs?: Vector4;
  99031. backUVs?: Vector4;
  99032. }, scene: Scene): Mesh;
  99033. }
  99034. }
  99035. declare module BABYLON {
  99036. /**
  99037. * Gizmo that enables scaling a mesh along 3 axis
  99038. */
  99039. export class ScaleGizmo extends Gizmo {
  99040. /**
  99041. * Internal gizmo used for interactions on the x axis
  99042. */
  99043. xGizmo: AxisScaleGizmo;
  99044. /**
  99045. * Internal gizmo used for interactions on the y axis
  99046. */
  99047. yGizmo: AxisScaleGizmo;
  99048. /**
  99049. * Internal gizmo used for interactions on the z axis
  99050. */
  99051. zGizmo: AxisScaleGizmo;
  99052. /**
  99053. * Internal gizmo used to scale all axis equally
  99054. */
  99055. uniformScaleGizmo: AxisScaleGizmo;
  99056. /** Fires an event when any of it's sub gizmos are dragged */
  99057. onDragStartObservable: Observable<{}>;
  99058. /** Fires an event when any of it's sub gizmos are released from dragging */
  99059. onDragEndObservable: Observable<{}>;
  99060. attachedMesh: Nullable<AbstractMesh>;
  99061. /**
  99062. * Creates a ScaleGizmo
  99063. * @param gizmoLayer The utility layer the gizmo will be added to
  99064. */
  99065. constructor(gizmoLayer?: UtilityLayerRenderer);
  99066. updateGizmoRotationToMatchAttachedMesh: boolean;
  99067. /**
  99068. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99069. */
  99070. snapDistance: number;
  99071. /**
  99072. * Ratio for the scale of the gizmo (Default: 1)
  99073. */
  99074. scaleRatio: number;
  99075. /**
  99076. * Disposes of the gizmo
  99077. */
  99078. dispose(): void;
  99079. }
  99080. }
  99081. declare module BABYLON {
  99082. /**
  99083. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  99084. */
  99085. export class GizmoManager implements IDisposable {
  99086. private scene;
  99087. /**
  99088. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  99089. */
  99090. gizmos: {
  99091. positionGizmo: Nullable<PositionGizmo>;
  99092. rotationGizmo: Nullable<RotationGizmo>;
  99093. scaleGizmo: Nullable<ScaleGizmo>;
  99094. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  99095. };
  99096. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  99097. clearGizmoOnEmptyPointerEvent: boolean;
  99098. /** Fires an event when the manager is attached to a mesh */
  99099. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  99100. private _gizmosEnabled;
  99101. private _pointerObserver;
  99102. private _attachedMesh;
  99103. private _boundingBoxColor;
  99104. private _defaultUtilityLayer;
  99105. private _defaultKeepDepthUtilityLayer;
  99106. /**
  99107. * When bounding box gizmo is enabled, this can be used to track drag/end events
  99108. */
  99109. boundingBoxDragBehavior: SixDofDragBehavior;
  99110. /**
  99111. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  99112. */
  99113. attachableMeshes: Nullable<Array<AbstractMesh>>;
  99114. /**
  99115. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  99116. */
  99117. usePointerToAttachGizmos: boolean;
  99118. /**
  99119. * Instatiates a gizmo manager
  99120. * @param scene the scene to overlay the gizmos on top of
  99121. */
  99122. constructor(scene: Scene);
  99123. /**
  99124. * Attaches a set of gizmos to the specified mesh
  99125. * @param mesh The mesh the gizmo's should be attached to
  99126. */
  99127. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  99128. /**
  99129. * If the position gizmo is enabled
  99130. */
  99131. positionGizmoEnabled: boolean;
  99132. /**
  99133. * If the rotation gizmo is enabled
  99134. */
  99135. rotationGizmoEnabled: boolean;
  99136. /**
  99137. * If the scale gizmo is enabled
  99138. */
  99139. scaleGizmoEnabled: boolean;
  99140. /**
  99141. * If the boundingBox gizmo is enabled
  99142. */
  99143. boundingBoxGizmoEnabled: boolean;
  99144. /**
  99145. * Disposes of the gizmo manager
  99146. */
  99147. dispose(): void;
  99148. }
  99149. }
  99150. declare module BABYLON {
  99151. /**
  99152. * Gizmo that enables viewing a light
  99153. */
  99154. export class LightGizmo extends Gizmo {
  99155. private _box;
  99156. /**
  99157. * Creates a LightGizmo
  99158. * @param gizmoLayer The utility layer the gizmo will be added to
  99159. */
  99160. constructor(gizmoLayer?: UtilityLayerRenderer);
  99161. private _light;
  99162. /**
  99163. * The light that the gizmo is attached to
  99164. */
  99165. light: Nullable<Light>;
  99166. /**
  99167. * @hidden
  99168. * Updates the gizmo to match the attached mesh's position/rotation
  99169. */
  99170. protected _update(): void;
  99171. }
  99172. }
  99173. declare module BABYLON {
  99174. /** @hidden */
  99175. export var backgroundFragmentDeclaration: {
  99176. name: string;
  99177. shader: string;
  99178. };
  99179. }
  99180. declare module BABYLON {
  99181. /** @hidden */
  99182. export var backgroundUboDeclaration: {
  99183. name: string;
  99184. shader: string;
  99185. };
  99186. }
  99187. declare module BABYLON {
  99188. /** @hidden */
  99189. export var backgroundPixelShader: {
  99190. name: string;
  99191. shader: string;
  99192. };
  99193. }
  99194. declare module BABYLON {
  99195. /** @hidden */
  99196. export var backgroundVertexDeclaration: {
  99197. name: string;
  99198. shader: string;
  99199. };
  99200. }
  99201. declare module BABYLON {
  99202. /** @hidden */
  99203. export var backgroundVertexShader: {
  99204. name: string;
  99205. shader: string;
  99206. };
  99207. }
  99208. declare module BABYLON {
  99209. /**
  99210. * Background material used to create an efficient environement around your scene.
  99211. */
  99212. export class BackgroundMaterial extends PushMaterial {
  99213. /**
  99214. * Standard reflectance value at parallel view angle.
  99215. */
  99216. static StandardReflectance0: number;
  99217. /**
  99218. * Standard reflectance value at grazing angle.
  99219. */
  99220. static StandardReflectance90: number;
  99221. protected _primaryColor: Color3;
  99222. /**
  99223. * Key light Color (multiply against the environement texture)
  99224. */
  99225. primaryColor: Color3;
  99226. protected __perceptualColor: Nullable<Color3>;
  99227. /**
  99228. * Experimental Internal Use Only.
  99229. *
  99230. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  99231. * This acts as a helper to set the primary color to a more "human friendly" value.
  99232. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  99233. * output color as close as possible from the chosen value.
  99234. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  99235. * part of lighting setup.)
  99236. */
  99237. _perceptualColor: Nullable<Color3>;
  99238. protected _primaryColorShadowLevel: float;
  99239. /**
  99240. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  99241. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  99242. */
  99243. primaryColorShadowLevel: float;
  99244. protected _primaryColorHighlightLevel: float;
  99245. /**
  99246. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  99247. * The primary color is used at the level chosen to define what the white area would look.
  99248. */
  99249. primaryColorHighlightLevel: float;
  99250. protected _reflectionTexture: Nullable<BaseTexture>;
  99251. /**
  99252. * Reflection Texture used in the material.
  99253. * Should be author in a specific way for the best result (refer to the documentation).
  99254. */
  99255. reflectionTexture: Nullable<BaseTexture>;
  99256. protected _reflectionBlur: float;
  99257. /**
  99258. * Reflection Texture level of blur.
  99259. *
  99260. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  99261. * texture twice.
  99262. */
  99263. reflectionBlur: float;
  99264. protected _diffuseTexture: Nullable<BaseTexture>;
  99265. /**
  99266. * Diffuse Texture used in the material.
  99267. * Should be author in a specific way for the best result (refer to the documentation).
  99268. */
  99269. diffuseTexture: Nullable<BaseTexture>;
  99270. protected _shadowLights: Nullable<IShadowLight[]>;
  99271. /**
  99272. * Specify the list of lights casting shadow on the material.
  99273. * All scene shadow lights will be included if null.
  99274. */
  99275. shadowLights: Nullable<IShadowLight[]>;
  99276. protected _shadowLevel: float;
  99277. /**
  99278. * Helps adjusting the shadow to a softer level if required.
  99279. * 0 means black shadows and 1 means no shadows.
  99280. */
  99281. shadowLevel: float;
  99282. protected _sceneCenter: Vector3;
  99283. /**
  99284. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  99285. * It is usually zero but might be interesting to modify according to your setup.
  99286. */
  99287. sceneCenter: Vector3;
  99288. protected _opacityFresnel: boolean;
  99289. /**
  99290. * This helps specifying that the material is falling off to the sky box at grazing angle.
  99291. * This helps ensuring a nice transition when the camera goes under the ground.
  99292. */
  99293. opacityFresnel: boolean;
  99294. protected _reflectionFresnel: boolean;
  99295. /**
  99296. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  99297. * This helps adding a mirror texture on the ground.
  99298. */
  99299. reflectionFresnel: boolean;
  99300. protected _reflectionFalloffDistance: number;
  99301. /**
  99302. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  99303. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  99304. */
  99305. reflectionFalloffDistance: number;
  99306. protected _reflectionAmount: number;
  99307. /**
  99308. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  99309. */
  99310. reflectionAmount: number;
  99311. protected _reflectionReflectance0: number;
  99312. /**
  99313. * This specifies the weight of the reflection at grazing angle.
  99314. */
  99315. reflectionReflectance0: number;
  99316. protected _reflectionReflectance90: number;
  99317. /**
  99318. * This specifies the weight of the reflection at a perpendicular point of view.
  99319. */
  99320. reflectionReflectance90: number;
  99321. /**
  99322. * Sets the reflection reflectance fresnel values according to the default standard
  99323. * empirically know to work well :-)
  99324. */
  99325. reflectionStandardFresnelWeight: number;
  99326. protected _useRGBColor: boolean;
  99327. /**
  99328. * Helps to directly use the maps channels instead of their level.
  99329. */
  99330. useRGBColor: boolean;
  99331. protected _enableNoise: boolean;
  99332. /**
  99333. * This helps reducing the banding effect that could occur on the background.
  99334. */
  99335. enableNoise: boolean;
  99336. /**
  99337. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99338. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  99339. * Recommended to be keep at 1.0 except for special cases.
  99340. */
  99341. fovMultiplier: number;
  99342. private _fovMultiplier;
  99343. /**
  99344. * Enable the FOV adjustment feature controlled by fovMultiplier.
  99345. */
  99346. useEquirectangularFOV: boolean;
  99347. private _maxSimultaneousLights;
  99348. /**
  99349. * Number of Simultaneous lights allowed on the material.
  99350. */
  99351. maxSimultaneousLights: int;
  99352. /**
  99353. * Default configuration related to image processing available in the Background Material.
  99354. */
  99355. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99356. /**
  99357. * Keep track of the image processing observer to allow dispose and replace.
  99358. */
  99359. private _imageProcessingObserver;
  99360. /**
  99361. * Attaches a new image processing configuration to the PBR Material.
  99362. * @param configuration (if null the scene configuration will be use)
  99363. */
  99364. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99365. /**
  99366. * Gets the image processing configuration used either in this material.
  99367. */
  99368. /**
  99369. * Sets the Default image processing configuration used either in the this material.
  99370. *
  99371. * If sets to null, the scene one is in use.
  99372. */
  99373. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  99374. /**
  99375. * Gets wether the color curves effect is enabled.
  99376. */
  99377. /**
  99378. * Sets wether the color curves effect is enabled.
  99379. */
  99380. cameraColorCurvesEnabled: boolean;
  99381. /**
  99382. * Gets wether the color grading effect is enabled.
  99383. */
  99384. /**
  99385. * Gets wether the color grading effect is enabled.
  99386. */
  99387. cameraColorGradingEnabled: boolean;
  99388. /**
  99389. * Gets wether tonemapping is enabled or not.
  99390. */
  99391. /**
  99392. * Sets wether tonemapping is enabled or not
  99393. */
  99394. cameraToneMappingEnabled: boolean;
  99395. /**
  99396. * The camera exposure used on this material.
  99397. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99398. * This corresponds to a photographic exposure.
  99399. */
  99400. /**
  99401. * The camera exposure used on this material.
  99402. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99403. * This corresponds to a photographic exposure.
  99404. */
  99405. cameraExposure: float;
  99406. /**
  99407. * Gets The camera contrast used on this material.
  99408. */
  99409. /**
  99410. * Sets The camera contrast used on this material.
  99411. */
  99412. cameraContrast: float;
  99413. /**
  99414. * Gets the Color Grading 2D Lookup Texture.
  99415. */
  99416. /**
  99417. * Sets the Color Grading 2D Lookup Texture.
  99418. */
  99419. cameraColorGradingTexture: Nullable<BaseTexture>;
  99420. /**
  99421. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99422. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99423. * 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;
  99424. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99425. */
  99426. /**
  99427. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99428. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99429. * 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;
  99430. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99431. */
  99432. cameraColorCurves: Nullable<ColorCurves>;
  99433. /**
  99434. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  99435. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  99436. */
  99437. switchToBGR: boolean;
  99438. private _renderTargets;
  99439. private _reflectionControls;
  99440. private _white;
  99441. private _primaryShadowColor;
  99442. private _primaryHighlightColor;
  99443. /**
  99444. * Instantiates a Background Material in the given scene
  99445. * @param name The friendly name of the material
  99446. * @param scene The scene to add the material to
  99447. */
  99448. constructor(name: string, scene: Scene);
  99449. /**
  99450. * Gets a boolean indicating that current material needs to register RTT
  99451. */
  99452. readonly hasRenderTargetTextures: boolean;
  99453. /**
  99454. * The entire material has been created in order to prevent overdraw.
  99455. * @returns false
  99456. */
  99457. needAlphaTesting(): boolean;
  99458. /**
  99459. * The entire material has been created in order to prevent overdraw.
  99460. * @returns true if blending is enable
  99461. */
  99462. needAlphaBlending(): boolean;
  99463. /**
  99464. * Checks wether the material is ready to be rendered for a given mesh.
  99465. * @param mesh The mesh to render
  99466. * @param subMesh The submesh to check against
  99467. * @param useInstances Specify wether or not the material is used with instances
  99468. * @returns true if all the dependencies are ready (Textures, Effects...)
  99469. */
  99470. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99471. /**
  99472. * Compute the primary color according to the chosen perceptual color.
  99473. */
  99474. private _computePrimaryColorFromPerceptualColor;
  99475. /**
  99476. * Compute the highlights and shadow colors according to their chosen levels.
  99477. */
  99478. private _computePrimaryColors;
  99479. /**
  99480. * Build the uniform buffer used in the material.
  99481. */
  99482. buildUniformLayout(): void;
  99483. /**
  99484. * Unbind the material.
  99485. */
  99486. unbind(): void;
  99487. /**
  99488. * Bind only the world matrix to the material.
  99489. * @param world The world matrix to bind.
  99490. */
  99491. bindOnlyWorldMatrix(world: Matrix): void;
  99492. /**
  99493. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  99494. * @param world The world matrix to bind.
  99495. * @param subMesh The submesh to bind for.
  99496. */
  99497. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99498. /**
  99499. * Dispose the material.
  99500. * @param forceDisposeEffect Force disposal of the associated effect.
  99501. * @param forceDisposeTextures Force disposal of the associated textures.
  99502. */
  99503. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99504. /**
  99505. * Clones the material.
  99506. * @param name The cloned name.
  99507. * @returns The cloned material.
  99508. */
  99509. clone(name: string): BackgroundMaterial;
  99510. /**
  99511. * Serializes the current material to its JSON representation.
  99512. * @returns The JSON representation.
  99513. */
  99514. serialize(): any;
  99515. /**
  99516. * Gets the class name of the material
  99517. * @returns "BackgroundMaterial"
  99518. */
  99519. getClassName(): string;
  99520. /**
  99521. * Parse a JSON input to create back a background material.
  99522. * @param source The JSON data to parse
  99523. * @param scene The scene to create the parsed material in
  99524. * @param rootUrl The root url of the assets the material depends upon
  99525. * @returns the instantiated BackgroundMaterial.
  99526. */
  99527. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  99528. }
  99529. }
  99530. declare module BABYLON {
  99531. /**
  99532. * Represents the different options available during the creation of
  99533. * a Environment helper.
  99534. *
  99535. * This can control the default ground, skybox and image processing setup of your scene.
  99536. */
  99537. export interface IEnvironmentHelperOptions {
  99538. /**
  99539. * Specifies wether or not to create a ground.
  99540. * True by default.
  99541. */
  99542. createGround: boolean;
  99543. /**
  99544. * Specifies the ground size.
  99545. * 15 by default.
  99546. */
  99547. groundSize: number;
  99548. /**
  99549. * The texture used on the ground for the main color.
  99550. * Comes from the BabylonJS CDN by default.
  99551. *
  99552. * Remarks: Can be either a texture or a url.
  99553. */
  99554. groundTexture: string | BaseTexture;
  99555. /**
  99556. * The color mixed in the ground texture by default.
  99557. * BabylonJS clearColor by default.
  99558. */
  99559. groundColor: Color3;
  99560. /**
  99561. * Specifies the ground opacity.
  99562. * 1 by default.
  99563. */
  99564. groundOpacity: number;
  99565. /**
  99566. * Enables the ground to receive shadows.
  99567. * True by default.
  99568. */
  99569. enableGroundShadow: boolean;
  99570. /**
  99571. * Helps preventing the shadow to be fully black on the ground.
  99572. * 0.5 by default.
  99573. */
  99574. groundShadowLevel: number;
  99575. /**
  99576. * Creates a mirror texture attach to the ground.
  99577. * false by default.
  99578. */
  99579. enableGroundMirror: boolean;
  99580. /**
  99581. * Specifies the ground mirror size ratio.
  99582. * 0.3 by default as the default kernel is 64.
  99583. */
  99584. groundMirrorSizeRatio: number;
  99585. /**
  99586. * Specifies the ground mirror blur kernel size.
  99587. * 64 by default.
  99588. */
  99589. groundMirrorBlurKernel: number;
  99590. /**
  99591. * Specifies the ground mirror visibility amount.
  99592. * 1 by default
  99593. */
  99594. groundMirrorAmount: number;
  99595. /**
  99596. * Specifies the ground mirror reflectance weight.
  99597. * This uses the standard weight of the background material to setup the fresnel effect
  99598. * of the mirror.
  99599. * 1 by default.
  99600. */
  99601. groundMirrorFresnelWeight: number;
  99602. /**
  99603. * Specifies the ground mirror Falloff distance.
  99604. * This can helps reducing the size of the reflection.
  99605. * 0 by Default.
  99606. */
  99607. groundMirrorFallOffDistance: number;
  99608. /**
  99609. * Specifies the ground mirror texture type.
  99610. * Unsigned Int by Default.
  99611. */
  99612. groundMirrorTextureType: number;
  99613. /**
  99614. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  99615. * the shown objects.
  99616. */
  99617. groundYBias: number;
  99618. /**
  99619. * Specifies wether or not to create a skybox.
  99620. * True by default.
  99621. */
  99622. createSkybox: boolean;
  99623. /**
  99624. * Specifies the skybox size.
  99625. * 20 by default.
  99626. */
  99627. skyboxSize: number;
  99628. /**
  99629. * The texture used on the skybox for the main color.
  99630. * Comes from the BabylonJS CDN by default.
  99631. *
  99632. * Remarks: Can be either a texture or a url.
  99633. */
  99634. skyboxTexture: string | BaseTexture;
  99635. /**
  99636. * The color mixed in the skybox texture by default.
  99637. * BabylonJS clearColor by default.
  99638. */
  99639. skyboxColor: Color3;
  99640. /**
  99641. * The background rotation around the Y axis of the scene.
  99642. * This helps aligning the key lights of your scene with the background.
  99643. * 0 by default.
  99644. */
  99645. backgroundYRotation: number;
  99646. /**
  99647. * Compute automatically the size of the elements to best fit with the scene.
  99648. */
  99649. sizeAuto: boolean;
  99650. /**
  99651. * Default position of the rootMesh if autoSize is not true.
  99652. */
  99653. rootPosition: Vector3;
  99654. /**
  99655. * Sets up the image processing in the scene.
  99656. * true by default.
  99657. */
  99658. setupImageProcessing: boolean;
  99659. /**
  99660. * The texture used as your environment texture in the scene.
  99661. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  99662. *
  99663. * Remarks: Can be either a texture or a url.
  99664. */
  99665. environmentTexture: string | BaseTexture;
  99666. /**
  99667. * The value of the exposure to apply to the scene.
  99668. * 0.6 by default if setupImageProcessing is true.
  99669. */
  99670. cameraExposure: number;
  99671. /**
  99672. * The value of the contrast to apply to the scene.
  99673. * 1.6 by default if setupImageProcessing is true.
  99674. */
  99675. cameraContrast: number;
  99676. /**
  99677. * Specifies wether or not tonemapping should be enabled in the scene.
  99678. * true by default if setupImageProcessing is true.
  99679. */
  99680. toneMappingEnabled: boolean;
  99681. }
  99682. /**
  99683. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  99684. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  99685. * It also helps with the default setup of your imageProcessing configuration.
  99686. */
  99687. export class EnvironmentHelper {
  99688. /**
  99689. * Default ground texture URL.
  99690. */
  99691. private static _groundTextureCDNUrl;
  99692. /**
  99693. * Default skybox texture URL.
  99694. */
  99695. private static _skyboxTextureCDNUrl;
  99696. /**
  99697. * Default environment texture URL.
  99698. */
  99699. private static _environmentTextureCDNUrl;
  99700. /**
  99701. * Creates the default options for the helper.
  99702. */
  99703. private static _getDefaultOptions;
  99704. private _rootMesh;
  99705. /**
  99706. * Gets the root mesh created by the helper.
  99707. */
  99708. readonly rootMesh: Mesh;
  99709. private _skybox;
  99710. /**
  99711. * Gets the skybox created by the helper.
  99712. */
  99713. readonly skybox: Nullable<Mesh>;
  99714. private _skyboxTexture;
  99715. /**
  99716. * Gets the skybox texture created by the helper.
  99717. */
  99718. readonly skyboxTexture: Nullable<BaseTexture>;
  99719. private _skyboxMaterial;
  99720. /**
  99721. * Gets the skybox material created by the helper.
  99722. */
  99723. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  99724. private _ground;
  99725. /**
  99726. * Gets the ground mesh created by the helper.
  99727. */
  99728. readonly ground: Nullable<Mesh>;
  99729. private _groundTexture;
  99730. /**
  99731. * Gets the ground texture created by the helper.
  99732. */
  99733. readonly groundTexture: Nullable<BaseTexture>;
  99734. private _groundMirror;
  99735. /**
  99736. * Gets the ground mirror created by the helper.
  99737. */
  99738. readonly groundMirror: Nullable<MirrorTexture>;
  99739. /**
  99740. * Gets the ground mirror render list to helps pushing the meshes
  99741. * you wish in the ground reflection.
  99742. */
  99743. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  99744. private _groundMaterial;
  99745. /**
  99746. * Gets the ground material created by the helper.
  99747. */
  99748. readonly groundMaterial: Nullable<BackgroundMaterial>;
  99749. /**
  99750. * Stores the creation options.
  99751. */
  99752. private readonly _scene;
  99753. private _options;
  99754. /**
  99755. * This observable will be notified with any error during the creation of the environment,
  99756. * mainly texture creation errors.
  99757. */
  99758. onErrorObservable: Observable<{
  99759. message?: string;
  99760. exception?: any;
  99761. }>;
  99762. /**
  99763. * constructor
  99764. * @param options Defines the options we want to customize the helper
  99765. * @param scene The scene to add the material to
  99766. */
  99767. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  99768. /**
  99769. * Updates the background according to the new options
  99770. * @param options
  99771. */
  99772. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  99773. /**
  99774. * Sets the primary color of all the available elements.
  99775. * @param color the main color to affect to the ground and the background
  99776. */
  99777. setMainColor(color: Color3): void;
  99778. /**
  99779. * Setup the image processing according to the specified options.
  99780. */
  99781. private _setupImageProcessing;
  99782. /**
  99783. * Setup the environment texture according to the specified options.
  99784. */
  99785. private _setupEnvironmentTexture;
  99786. /**
  99787. * Setup the background according to the specified options.
  99788. */
  99789. private _setupBackground;
  99790. /**
  99791. * Get the scene sizes according to the setup.
  99792. */
  99793. private _getSceneSize;
  99794. /**
  99795. * Setup the ground according to the specified options.
  99796. */
  99797. private _setupGround;
  99798. /**
  99799. * Setup the ground material according to the specified options.
  99800. */
  99801. private _setupGroundMaterial;
  99802. /**
  99803. * Setup the ground diffuse texture according to the specified options.
  99804. */
  99805. private _setupGroundDiffuseTexture;
  99806. /**
  99807. * Setup the ground mirror texture according to the specified options.
  99808. */
  99809. private _setupGroundMirrorTexture;
  99810. /**
  99811. * Setup the ground to receive the mirror texture.
  99812. */
  99813. private _setupMirrorInGroundMaterial;
  99814. /**
  99815. * Setup the skybox according to the specified options.
  99816. */
  99817. private _setupSkybox;
  99818. /**
  99819. * Setup the skybox material according to the specified options.
  99820. */
  99821. private _setupSkyboxMaterial;
  99822. /**
  99823. * Setup the skybox reflection texture according to the specified options.
  99824. */
  99825. private _setupSkyboxReflectionTexture;
  99826. private _errorHandler;
  99827. /**
  99828. * Dispose all the elements created by the Helper.
  99829. */
  99830. dispose(): void;
  99831. }
  99832. }
  99833. declare module BABYLON {
  99834. /**
  99835. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  99836. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  99837. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  99838. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  99839. */
  99840. export class PhotoDome extends TransformNode {
  99841. private _useDirectMapping;
  99842. /**
  99843. * The texture being displayed on the sphere
  99844. */
  99845. protected _photoTexture: Texture;
  99846. /**
  99847. * Gets or sets the texture being displayed on the sphere
  99848. */
  99849. photoTexture: Texture;
  99850. /**
  99851. * Observable raised when an error occured while loading the 360 image
  99852. */
  99853. onLoadErrorObservable: Observable<string>;
  99854. /**
  99855. * The skybox material
  99856. */
  99857. protected _material: BackgroundMaterial;
  99858. /**
  99859. * The surface used for the skybox
  99860. */
  99861. protected _mesh: Mesh;
  99862. /**
  99863. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99864. * Also see the options.resolution property.
  99865. */
  99866. fovMultiplier: number;
  99867. /**
  99868. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  99869. * @param name Element's name, child elements will append suffixes for their own names.
  99870. * @param urlsOfPhoto defines the url of the photo to display
  99871. * @param options defines an object containing optional or exposed sub element properties
  99872. * @param onError defines a callback called when an error occured while loading the texture
  99873. */
  99874. constructor(name: string, urlOfPhoto: string, options: {
  99875. resolution?: number;
  99876. size?: number;
  99877. useDirectMapping?: boolean;
  99878. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  99879. /**
  99880. * Releases resources associated with this node.
  99881. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99882. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99883. */
  99884. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99885. }
  99886. }
  99887. declare module BABYLON {
  99888. /**
  99889. * Class used to host texture specific utilities
  99890. */
  99891. export class TextureTools {
  99892. /**
  99893. * Uses the GPU to create a copy texture rescaled at a given size
  99894. * @param texture Texture to copy from
  99895. * @param width defines the desired width
  99896. * @param height defines the desired height
  99897. * @param useBilinearMode defines if bilinear mode has to be used
  99898. * @return the generated texture
  99899. */
  99900. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  99901. /**
  99902. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  99903. * @param scene defines the hosting scene
  99904. * @returns the environment BRDF texture
  99905. */
  99906. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  99907. private static _environmentBRDFBase64Texture;
  99908. }
  99909. }
  99910. declare module BABYLON {
  99911. /**
  99912. * @hidden
  99913. */
  99914. export interface IMaterialClearCoatDefines {
  99915. CLEARCOAT: boolean;
  99916. CLEARCOAT_DEFAULTIOR: boolean;
  99917. CLEARCOAT_TEXTURE: boolean;
  99918. CLEARCOAT_TEXTUREDIRECTUV: number;
  99919. CLEARCOAT_BUMP: boolean;
  99920. CLEARCOAT_BUMPDIRECTUV: number;
  99921. CLEARCOAT_TINT: boolean;
  99922. CLEARCOAT_TINT_TEXTURE: boolean;
  99923. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  99924. /** @hidden */
  99925. _areTexturesDirty: boolean;
  99926. }
  99927. /**
  99928. * Define the code related to the clear coat parameters of the pbr material.
  99929. */
  99930. export class PBRClearCoatConfiguration {
  99931. /**
  99932. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  99933. * The default fits with a polyurethane material.
  99934. */
  99935. private static readonly _DefaultIndiceOfRefraction;
  99936. private _isEnabled;
  99937. /**
  99938. * Defines if the clear coat is enabled in the material.
  99939. */
  99940. isEnabled: boolean;
  99941. /**
  99942. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  99943. */
  99944. intensity: number;
  99945. /**
  99946. * Defines the clear coat layer roughness.
  99947. */
  99948. roughness: number;
  99949. private _indiceOfRefraction;
  99950. /**
  99951. * Defines the indice of refraction of the clear coat.
  99952. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  99953. * The default fits with a polyurethane material.
  99954. * Changing the default value is more performance intensive.
  99955. */
  99956. indiceOfRefraction: number;
  99957. private _texture;
  99958. /**
  99959. * Stores the clear coat values in a texture.
  99960. */
  99961. texture: Nullable<BaseTexture>;
  99962. private _bumpTexture;
  99963. /**
  99964. * Define the clear coat specific bump texture.
  99965. */
  99966. bumpTexture: Nullable<BaseTexture>;
  99967. private _isTintEnabled;
  99968. /**
  99969. * Defines if the clear coat tint is enabled in the material.
  99970. */
  99971. isTintEnabled: boolean;
  99972. /**
  99973. * Defines if the clear coat tint is enabled in the material.
  99974. * This is only use if tint is enabled
  99975. */
  99976. tintColor: Color3;
  99977. /**
  99978. * Defines if the distance at which the tint color should be found in the
  99979. * clear coat media.
  99980. * This is only use if tint is enabled
  99981. */
  99982. tintColorAtDistance: number;
  99983. /**
  99984. * Defines the clear coat layer thickness.
  99985. * This is only use if tint is enabled
  99986. */
  99987. tintThickness: number;
  99988. private _tintTexture;
  99989. /**
  99990. * Stores the clear tint values in a texture.
  99991. * rgb is tint
  99992. * a is a thickness factor
  99993. */
  99994. tintTexture: Nullable<BaseTexture>;
  99995. /** @hidden */
  99996. private _internalMarkAllSubMeshesAsTexturesDirty;
  99997. /** @hidden */
  99998. _markAllSubMeshesAsTexturesDirty(): void;
  99999. /**
  100000. * Instantiate a new istance of clear coat configuration.
  100001. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100002. */
  100003. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100004. /**
  100005. * Specifies that the submesh is ready to be used.
  100006. * @param defines the list of "defines" to update.
  100007. * @param scene defines the scene the material belongs to.
  100008. * @param engine defines the engine the material belongs to.
  100009. * @param disableBumpMap defines wether the material disables bump or not.
  100010. * @returns - boolean indicating that the submesh is ready or not.
  100011. */
  100012. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  100013. /**
  100014. * Checks to see if a texture is used in the material.
  100015. * @param defines the list of "defines" to update.
  100016. * @param scene defines the scene to the material belongs to.
  100017. */
  100018. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  100019. /**
  100020. * Binds the material data.
  100021. * @param uniformBuffer defines the Uniform buffer to fill in.
  100022. * @param scene defines the scene the material belongs to.
  100023. * @param engine defines the engine the material belongs to.
  100024. * @param disableBumpMap defines wether the material disables bump or not.
  100025. * @param isFrozen defines wether the material is frozen or not.
  100026. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100027. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100028. */
  100029. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  100030. /**
  100031. * Checks to see if a texture is used in the material.
  100032. * @param texture - Base texture to use.
  100033. * @returns - Boolean specifying if a texture is used in the material.
  100034. */
  100035. hasTexture(texture: BaseTexture): boolean;
  100036. /**
  100037. * Returns an array of the actively used textures.
  100038. * @param activeTextures Array of BaseTextures
  100039. */
  100040. getActiveTextures(activeTextures: BaseTexture[]): void;
  100041. /**
  100042. * Returns the animatable textures.
  100043. * @param animatables Array of animatable textures.
  100044. */
  100045. getAnimatables(animatables: IAnimatable[]): void;
  100046. /**
  100047. * Disposes the resources of the material.
  100048. * @param forceDisposeTextures - Forces the disposal of all textures.
  100049. */
  100050. dispose(forceDisposeTextures?: boolean): void;
  100051. /**
  100052. * Get the current class name of the texture useful for serialization or dynamic coding.
  100053. * @returns "PBRClearCoatConfiguration"
  100054. */
  100055. getClassName(): string;
  100056. /**
  100057. * Makes a duplicate of the current configuration into another one.
  100058. * @param clearCoatConfiguration define the config where to copy the info
  100059. */
  100060. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  100061. /**
  100062. * Serializes this clear coat configuration.
  100063. * @returns - An object with the serialized config.
  100064. */
  100065. serialize(): any;
  100066. /**
  100067. * Parses a Clear Coat Configuration from a serialized object.
  100068. * @param source - Serialized object.
  100069. */
  100070. parse(source: any): void;
  100071. /**
  100072. * Add fallbacks to the effect fallbacks list.
  100073. * @param defines defines the Base texture to use.
  100074. * @param fallbacks defines the current fallback list.
  100075. * @param currentRank defines the current fallback rank.
  100076. * @returns the new fallback rank.
  100077. */
  100078. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100079. /**
  100080. * Add the required uniforms to the current list.
  100081. * @param uniforms defines the current uniform list.
  100082. */
  100083. static AddUniforms(uniforms: string[]): void;
  100084. /**
  100085. * Add the required samplers to the current list.
  100086. * @param samplers defines the current sampler list.
  100087. */
  100088. static AddSamplers(samplers: string[]): void;
  100089. /**
  100090. * Add the required uniforms to the current buffer.
  100091. * @param uniformBuffer defines the current uniform buffer.
  100092. */
  100093. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100094. }
  100095. }
  100096. declare module BABYLON {
  100097. /**
  100098. * @hidden
  100099. */
  100100. export interface IMaterialAnisotropicDefines {
  100101. ANISOTROPIC: boolean;
  100102. MAINUV1: boolean;
  100103. _areMiscDirty: boolean;
  100104. _needUVs: boolean;
  100105. }
  100106. /**
  100107. * Define the code related to the anisotropic parameters of the pbr material.
  100108. */
  100109. export class PBRAnisotropicConfiguration {
  100110. private _isEnabled;
  100111. /**
  100112. * Defines if the anisotropy is enabled in the material.
  100113. */
  100114. isEnabled: boolean;
  100115. /**
  100116. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  100117. */
  100118. intensity: number;
  100119. /**
  100120. * Defines if the effect is along the tangents or bitangents.
  100121. * By default, the effect is "strectching" the highlights along the tangents.
  100122. */
  100123. followTangents: boolean;
  100124. /** @hidden */
  100125. private _internalMarkAllSubMeshesAsMiscDirty;
  100126. /** @hidden */
  100127. _markAllSubMeshesAsMiscDirty(): void;
  100128. /**
  100129. * Instantiate a new istance of clear coat configuration.
  100130. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100131. */
  100132. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100133. /**
  100134. * Checks to see if a texture is used in the material.
  100135. * @param defines the list of "defines" to update.
  100136. * @param mesh the mesh we are preparing the defines for.
  100137. */
  100138. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  100139. /**
  100140. * Binds the material data.
  100141. * @param uniformBuffer defines the Uniform buffer to fill in.
  100142. * @param isFrozen defines wether the material is frozen or not.
  100143. */
  100144. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  100145. /**
  100146. * Get the current class name of the texture useful for serialization or dynamic coding.
  100147. * @returns "PBRAnisotropicConfiguration"
  100148. */
  100149. getClassName(): string;
  100150. /**
  100151. * Makes a duplicate of the current configuration into another one.
  100152. * @param anisotropicConfiguration define the config where to copy the info
  100153. */
  100154. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  100155. /**
  100156. * Serializes this clear coat configuration.
  100157. * @returns - An object with the serialized config.
  100158. */
  100159. serialize(): any;
  100160. /**
  100161. * Parses a Clear Coat Configuration from a serialized object.
  100162. * @param source - Serialized object.
  100163. */
  100164. parse(source: any): void;
  100165. /**
  100166. * Add fallbacks to the effect fallbacks list.
  100167. * @param defines defines the Base texture to use.
  100168. * @param fallbacks defines the current fallback list.
  100169. * @param currentRank defines the current fallback rank.
  100170. * @returns the new fallback rank.
  100171. */
  100172. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100173. /**
  100174. * Add the required uniforms to the current list.
  100175. * @param uniforms defines the current uniform list.
  100176. */
  100177. static AddUniforms(uniforms: string[]): void;
  100178. /**
  100179. * Add the required uniforms to the current buffer.
  100180. * @param uniformBuffer defines the current uniform buffer.
  100181. */
  100182. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100183. }
  100184. }
  100185. declare module BABYLON {
  100186. /**
  100187. * @hidden
  100188. */
  100189. export interface IMaterialBRDFDefines {
  100190. BRDF_V_HEIGHT_CORRELATED: boolean;
  100191. MS_BRDF_ENERGY_CONSERVATION: boolean;
  100192. /** @hidden */
  100193. _areMiscDirty: boolean;
  100194. }
  100195. /**
  100196. * Define the code related to the BRDF parameters of the pbr material.
  100197. */
  100198. export class PBRBRDFConfiguration {
  100199. private _useEnergyConservation;
  100200. /**
  100201. * Defines if the material uses energy conservation.
  100202. */
  100203. useEnergyConservation: boolean;
  100204. private _useSmithVisibilityHeightCorrelated;
  100205. /**
  100206. * LEGACY Mode set to false
  100207. * Defines if the material uses height smith correlated visibility term.
  100208. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  100209. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  100210. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  100211. * Not relying on height correlated will also disable energy conservation.
  100212. */
  100213. useSmithVisibilityHeightCorrelated: boolean;
  100214. /** @hidden */
  100215. private _internalMarkAllSubMeshesAsMiscDirty;
  100216. /** @hidden */
  100217. _markAllSubMeshesAsMiscDirty(): void;
  100218. /**
  100219. * Instantiate a new istance of clear coat configuration.
  100220. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100221. */
  100222. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100223. /**
  100224. * Checks to see if a texture is used in the material.
  100225. * @param defines the list of "defines" to update.
  100226. */
  100227. prepareDefines(defines: IMaterialBRDFDefines): void;
  100228. /**
  100229. * Get the current class name of the texture useful for serialization or dynamic coding.
  100230. * @returns "PBRClearCoatConfiguration"
  100231. */
  100232. getClassName(): string;
  100233. /**
  100234. * Makes a duplicate of the current configuration into another one.
  100235. * @param brdfConfiguration define the config where to copy the info
  100236. */
  100237. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  100238. /**
  100239. * Serializes this BRDF configuration.
  100240. * @returns - An object with the serialized config.
  100241. */
  100242. serialize(): any;
  100243. /**
  100244. * Parses a BRDF Configuration from a serialized object.
  100245. * @param source - Serialized object.
  100246. */
  100247. parse(source: any): void;
  100248. }
  100249. }
  100250. declare module BABYLON {
  100251. /** @hidden */
  100252. export var pbrFragmentDeclaration: {
  100253. name: string;
  100254. shader: string;
  100255. };
  100256. }
  100257. declare module BABYLON {
  100258. /** @hidden */
  100259. export var pbrUboDeclaration: {
  100260. name: string;
  100261. shader: string;
  100262. };
  100263. }
  100264. declare module BABYLON {
  100265. /** @hidden */
  100266. export var pbrFunctions: {
  100267. name: string;
  100268. shader: string;
  100269. };
  100270. }
  100271. declare module BABYLON {
  100272. /** @hidden */
  100273. export var harmonicsFunctions: {
  100274. name: string;
  100275. shader: string;
  100276. };
  100277. }
  100278. declare module BABYLON {
  100279. /** @hidden */
  100280. export var pbrPreLightingFunctions: {
  100281. name: string;
  100282. shader: string;
  100283. };
  100284. }
  100285. declare module BABYLON {
  100286. /** @hidden */
  100287. export var pbrFalloffLightingFunctions: {
  100288. name: string;
  100289. shader: string;
  100290. };
  100291. }
  100292. declare module BABYLON {
  100293. /** @hidden */
  100294. export var pbrLightingFunctions: {
  100295. name: string;
  100296. shader: string;
  100297. };
  100298. }
  100299. declare module BABYLON {
  100300. /** @hidden */
  100301. export var pbrPixelShader: {
  100302. name: string;
  100303. shader: string;
  100304. };
  100305. }
  100306. declare module BABYLON {
  100307. /** @hidden */
  100308. export var pbrVertexDeclaration: {
  100309. name: string;
  100310. shader: string;
  100311. };
  100312. }
  100313. declare module BABYLON {
  100314. /** @hidden */
  100315. export var pbrVertexShader: {
  100316. name: string;
  100317. shader: string;
  100318. };
  100319. }
  100320. declare module BABYLON {
  100321. /**
  100322. * The Physically based material base class of BJS.
  100323. *
  100324. * This offers the main features of a standard PBR material.
  100325. * For more information, please refer to the documentation :
  100326. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  100327. */
  100328. export abstract class PBRBaseMaterial extends PushMaterial {
  100329. /**
  100330. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100331. */
  100332. static readonly PBRMATERIAL_OPAQUE: number;
  100333. /**
  100334. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100335. */
  100336. static readonly PBRMATERIAL_ALPHATEST: number;
  100337. /**
  100338. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100339. */
  100340. static readonly PBRMATERIAL_ALPHABLEND: number;
  100341. /**
  100342. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100343. * They are also discarded below the alpha cutoff threshold to improve performances.
  100344. */
  100345. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  100346. /**
  100347. * Defines the default value of how much AO map is occluding the analytical lights
  100348. * (point spot...).
  100349. */
  100350. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  100351. /**
  100352. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  100353. */
  100354. static readonly LIGHTFALLOFF_PHYSICAL: number;
  100355. /**
  100356. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  100357. * to enhance interoperability with other engines.
  100358. */
  100359. static readonly LIGHTFALLOFF_GLTF: number;
  100360. /**
  100361. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  100362. * to enhance interoperability with other materials.
  100363. */
  100364. static readonly LIGHTFALLOFF_STANDARD: number;
  100365. /**
  100366. * Intensity of the direct lights e.g. the four lights available in your scene.
  100367. * This impacts both the direct diffuse and specular highlights.
  100368. */
  100369. protected _directIntensity: number;
  100370. /**
  100371. * Intensity of the emissive part of the material.
  100372. * This helps controlling the emissive effect without modifying the emissive color.
  100373. */
  100374. protected _emissiveIntensity: number;
  100375. /**
  100376. * Intensity of the environment e.g. how much the environment will light the object
  100377. * either through harmonics for rough material or through the refelction for shiny ones.
  100378. */
  100379. protected _environmentIntensity: number;
  100380. /**
  100381. * This is a special control allowing the reduction of the specular highlights coming from the
  100382. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  100383. */
  100384. protected _specularIntensity: number;
  100385. /**
  100386. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  100387. */
  100388. private _lightingInfos;
  100389. /**
  100390. * Debug Control allowing disabling the bump map on this material.
  100391. */
  100392. protected _disableBumpMap: boolean;
  100393. /**
  100394. * AKA Diffuse Texture in standard nomenclature.
  100395. */
  100396. protected _albedoTexture: BaseTexture;
  100397. /**
  100398. * AKA Occlusion Texture in other nomenclature.
  100399. */
  100400. protected _ambientTexture: BaseTexture;
  100401. /**
  100402. * AKA Occlusion Texture Intensity in other nomenclature.
  100403. */
  100404. protected _ambientTextureStrength: number;
  100405. /**
  100406. * Defines how much the AO map is occluding the analytical lights (point spot...).
  100407. * 1 means it completely occludes it
  100408. * 0 mean it has no impact
  100409. */
  100410. protected _ambientTextureImpactOnAnalyticalLights: number;
  100411. /**
  100412. * Stores the alpha values in a texture.
  100413. */
  100414. protected _opacityTexture: BaseTexture;
  100415. /**
  100416. * Stores the reflection values in a texture.
  100417. */
  100418. protected _reflectionTexture: BaseTexture;
  100419. /**
  100420. * Stores the refraction values in a texture.
  100421. */
  100422. protected _refractionTexture: BaseTexture;
  100423. /**
  100424. * Stores the emissive values in a texture.
  100425. */
  100426. protected _emissiveTexture: BaseTexture;
  100427. /**
  100428. * AKA Specular texture in other nomenclature.
  100429. */
  100430. protected _reflectivityTexture: BaseTexture;
  100431. /**
  100432. * Used to switch from specular/glossiness to metallic/roughness workflow.
  100433. */
  100434. protected _metallicTexture: BaseTexture;
  100435. /**
  100436. * Specifies the metallic scalar of the metallic/roughness workflow.
  100437. * Can also be used to scale the metalness values of the metallic texture.
  100438. */
  100439. protected _metallic: Nullable<number>;
  100440. /**
  100441. * Specifies the roughness scalar of the metallic/roughness workflow.
  100442. * Can also be used to scale the roughness values of the metallic texture.
  100443. */
  100444. protected _roughness: Nullable<number>;
  100445. /**
  100446. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  100447. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  100448. */
  100449. protected _microSurfaceTexture: BaseTexture;
  100450. /**
  100451. * Stores surface normal data used to displace a mesh in a texture.
  100452. */
  100453. protected _bumpTexture: BaseTexture;
  100454. /**
  100455. * Stores the pre-calculated light information of a mesh in a texture.
  100456. */
  100457. protected _lightmapTexture: BaseTexture;
  100458. /**
  100459. * The color of a material in ambient lighting.
  100460. */
  100461. protected _ambientColor: Color3;
  100462. /**
  100463. * AKA Diffuse Color in other nomenclature.
  100464. */
  100465. protected _albedoColor: Color3;
  100466. /**
  100467. * AKA Specular Color in other nomenclature.
  100468. */
  100469. protected _reflectivityColor: Color3;
  100470. /**
  100471. * The color applied when light is reflected from a material.
  100472. */
  100473. protected _reflectionColor: Color3;
  100474. /**
  100475. * The color applied when light is emitted from a material.
  100476. */
  100477. protected _emissiveColor: Color3;
  100478. /**
  100479. * AKA Glossiness in other nomenclature.
  100480. */
  100481. protected _microSurface: number;
  100482. /**
  100483. * source material index of refraction (IOR)' / 'destination material IOR.
  100484. */
  100485. protected _indexOfRefraction: number;
  100486. /**
  100487. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  100488. */
  100489. protected _invertRefractionY: boolean;
  100490. /**
  100491. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  100492. * Materials half opaque for instance using refraction could benefit from this control.
  100493. */
  100494. protected _linkRefractionWithTransparency: boolean;
  100495. /**
  100496. * Specifies that the material will use the light map as a show map.
  100497. */
  100498. protected _useLightmapAsShadowmap: boolean;
  100499. /**
  100500. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  100501. * makes the reflect vector face the model (under horizon).
  100502. */
  100503. protected _useHorizonOcclusion: boolean;
  100504. /**
  100505. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  100506. * too much the area relying on ambient texture to define their ambient occlusion.
  100507. */
  100508. protected _useRadianceOcclusion: boolean;
  100509. /**
  100510. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  100511. */
  100512. protected _useAlphaFromAlbedoTexture: boolean;
  100513. /**
  100514. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  100515. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100516. */
  100517. protected _useSpecularOverAlpha: boolean;
  100518. /**
  100519. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  100520. */
  100521. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  100522. /**
  100523. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  100524. */
  100525. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  100526. /**
  100527. * Specifies if the metallic texture contains the roughness information in its green channel.
  100528. */
  100529. protected _useRoughnessFromMetallicTextureGreen: boolean;
  100530. /**
  100531. * Specifies if the metallic texture contains the metallness information in its blue channel.
  100532. */
  100533. protected _useMetallnessFromMetallicTextureBlue: boolean;
  100534. /**
  100535. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  100536. */
  100537. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  100538. /**
  100539. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  100540. */
  100541. protected _useAmbientInGrayScale: boolean;
  100542. /**
  100543. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  100544. * The material will try to infer what glossiness each pixel should be.
  100545. */
  100546. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  100547. /**
  100548. * Defines the falloff type used in this material.
  100549. * It by default is Physical.
  100550. */
  100551. protected _lightFalloff: number;
  100552. /**
  100553. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100554. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100555. */
  100556. protected _useRadianceOverAlpha: boolean;
  100557. /**
  100558. * Allows using an object space normal map (instead of tangent space).
  100559. */
  100560. protected _useObjectSpaceNormalMap: boolean;
  100561. /**
  100562. * Allows using the bump map in parallax mode.
  100563. */
  100564. protected _useParallax: boolean;
  100565. /**
  100566. * Allows using the bump map in parallax occlusion mode.
  100567. */
  100568. protected _useParallaxOcclusion: boolean;
  100569. /**
  100570. * Controls the scale bias of the parallax mode.
  100571. */
  100572. protected _parallaxScaleBias: number;
  100573. /**
  100574. * If sets to true, disables all the lights affecting the material.
  100575. */
  100576. protected _disableLighting: boolean;
  100577. /**
  100578. * Number of Simultaneous lights allowed on the material.
  100579. */
  100580. protected _maxSimultaneousLights: number;
  100581. /**
  100582. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100583. */
  100584. protected _invertNormalMapX: boolean;
  100585. /**
  100586. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100587. */
  100588. protected _invertNormalMapY: boolean;
  100589. /**
  100590. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100591. */
  100592. protected _twoSidedLighting: boolean;
  100593. /**
  100594. * Defines the alpha limits in alpha test mode.
  100595. */
  100596. protected _alphaCutOff: number;
  100597. /**
  100598. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  100599. */
  100600. protected _forceAlphaTest: boolean;
  100601. /**
  100602. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100603. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  100604. */
  100605. protected _useAlphaFresnel: boolean;
  100606. /**
  100607. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100608. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  100609. */
  100610. protected _useLinearAlphaFresnel: boolean;
  100611. /**
  100612. * The transparency mode of the material.
  100613. */
  100614. protected _transparencyMode: Nullable<number>;
  100615. /**
  100616. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  100617. * from cos thetav and roughness:
  100618. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  100619. */
  100620. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  100621. /**
  100622. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  100623. */
  100624. protected _forceIrradianceInFragment: boolean;
  100625. /**
  100626. * Force normal to face away from face.
  100627. */
  100628. protected _forceNormalForward: boolean;
  100629. /**
  100630. * Enables specular anti aliasing in the PBR shader.
  100631. * It will both interacts on the Geometry for analytical and IBL lighting.
  100632. * It also prefilter the roughness map based on the bump values.
  100633. */
  100634. protected _enableSpecularAntiAliasing: boolean;
  100635. /**
  100636. * Default configuration related to image processing available in the PBR Material.
  100637. */
  100638. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100639. /**
  100640. * Keep track of the image processing observer to allow dispose and replace.
  100641. */
  100642. private _imageProcessingObserver;
  100643. /**
  100644. * Attaches a new image processing configuration to the PBR Material.
  100645. * @param configuration
  100646. */
  100647. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100648. /**
  100649. * Stores the available render targets.
  100650. */
  100651. private _renderTargets;
  100652. /**
  100653. * Sets the global ambient color for the material used in lighting calculations.
  100654. */
  100655. private _globalAmbientColor;
  100656. /**
  100657. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  100658. */
  100659. private _useLogarithmicDepth;
  100660. /**
  100661. * If set to true, no lighting calculations will be applied.
  100662. */
  100663. private _unlit;
  100664. /**
  100665. * Defines the clear coat layer parameters for the material.
  100666. */
  100667. readonly clearCoat: PBRClearCoatConfiguration;
  100668. /**
  100669. * Defines the anisotropic parameters for the material.
  100670. */
  100671. readonly anisotropy: PBRAnisotropicConfiguration;
  100672. /**
  100673. * Defines the BRDF parameters for the material.
  100674. */
  100675. readonly brdf: PBRBRDFConfiguration;
  100676. /**
  100677. * Instantiates a new PBRMaterial instance.
  100678. *
  100679. * @param name The material name
  100680. * @param scene The scene the material will be use in.
  100681. */
  100682. constructor(name: string, scene: Scene);
  100683. /**
  100684. * Gets a boolean indicating that current material needs to register RTT
  100685. */
  100686. readonly hasRenderTargetTextures: boolean;
  100687. /**
  100688. * Gets the name of the material class.
  100689. */
  100690. getClassName(): string;
  100691. /**
  100692. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  100693. */
  100694. /**
  100695. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  100696. */
  100697. useLogarithmicDepth: boolean;
  100698. /**
  100699. * Gets the current transparency mode.
  100700. */
  100701. /**
  100702. * Sets the transparency mode of the material.
  100703. *
  100704. * | Value | Type | Description |
  100705. * | ----- | ----------------------------------- | ----------- |
  100706. * | 0 | OPAQUE | |
  100707. * | 1 | ALPHATEST | |
  100708. * | 2 | ALPHABLEND | |
  100709. * | 3 | ALPHATESTANDBLEND | |
  100710. *
  100711. */
  100712. transparencyMode: Nullable<number>;
  100713. /**
  100714. * Returns true if alpha blending should be disabled.
  100715. */
  100716. private readonly _disableAlphaBlending;
  100717. /**
  100718. * Specifies whether or not this material should be rendered in alpha blend mode.
  100719. */
  100720. needAlphaBlending(): boolean;
  100721. /**
  100722. * Specifies if the mesh will require alpha blending.
  100723. * @param mesh - BJS mesh.
  100724. */
  100725. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  100726. /**
  100727. * Specifies whether or not this material should be rendered in alpha test mode.
  100728. */
  100729. needAlphaTesting(): boolean;
  100730. /**
  100731. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  100732. */
  100733. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  100734. /**
  100735. * Gets the texture used for the alpha test.
  100736. */
  100737. getAlphaTestTexture(): BaseTexture;
  100738. /**
  100739. * Specifies that the submesh is ready to be used.
  100740. * @param mesh - BJS mesh.
  100741. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  100742. * @param useInstances - Specifies that instances should be used.
  100743. * @returns - boolean indicating that the submesh is ready or not.
  100744. */
  100745. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100746. /**
  100747. * Specifies if the material uses metallic roughness workflow.
  100748. * @returns boolean specifiying if the material uses metallic roughness workflow.
  100749. */
  100750. isMetallicWorkflow(): boolean;
  100751. private _prepareEffect;
  100752. private _prepareDefines;
  100753. /**
  100754. * Force shader compilation
  100755. */
  100756. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  100757. clipPlane: boolean;
  100758. }>): void;
  100759. /**
  100760. * Initializes the uniform buffer layout for the shader.
  100761. */
  100762. buildUniformLayout(): void;
  100763. /**
  100764. * Unbinds the textures.
  100765. */
  100766. unbind(): void;
  100767. /**
  100768. * Binds the submesh data.
  100769. * @param world - The world matrix.
  100770. * @param mesh - The BJS mesh.
  100771. * @param subMesh - A submesh of the BJS mesh.
  100772. */
  100773. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100774. /**
  100775. * Returns the animatable textures.
  100776. * @returns - Array of animatable textures.
  100777. */
  100778. getAnimatables(): IAnimatable[];
  100779. /**
  100780. * Returns the texture used for reflections.
  100781. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  100782. */
  100783. private _getReflectionTexture;
  100784. /**
  100785. * Returns the texture used for refraction or null if none is used.
  100786. * @returns - Refection texture if present. If no refraction texture and refraction
  100787. * is linked with transparency, returns environment texture. Otherwise, returns null.
  100788. */
  100789. private _getRefractionTexture;
  100790. /**
  100791. * Returns an array of the actively used textures.
  100792. * @returns - Array of BaseTextures
  100793. */
  100794. getActiveTextures(): BaseTexture[];
  100795. /**
  100796. * Checks to see if a texture is used in the material.
  100797. * @param texture - Base texture to use.
  100798. * @returns - Boolean specifying if a texture is used in the material.
  100799. */
  100800. hasTexture(texture: BaseTexture): boolean;
  100801. /**
  100802. * Disposes the resources of the material.
  100803. * @param forceDisposeEffect - Forces the disposal of effects.
  100804. * @param forceDisposeTextures - Forces the disposal of all textures.
  100805. */
  100806. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100807. }
  100808. }
  100809. declare module BABYLON {
  100810. /**
  100811. * The Physically based material of BJS.
  100812. *
  100813. * This offers the main features of a standard PBR material.
  100814. * For more information, please refer to the documentation :
  100815. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  100816. */
  100817. export class PBRMaterial extends PBRBaseMaterial {
  100818. /**
  100819. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100820. */
  100821. static readonly PBRMATERIAL_OPAQUE: number;
  100822. /**
  100823. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100824. */
  100825. static readonly PBRMATERIAL_ALPHATEST: number;
  100826. /**
  100827. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100828. */
  100829. static readonly PBRMATERIAL_ALPHABLEND: number;
  100830. /**
  100831. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100832. * They are also discarded below the alpha cutoff threshold to improve performances.
  100833. */
  100834. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  100835. /**
  100836. * Defines the default value of how much AO map is occluding the analytical lights
  100837. * (point spot...).
  100838. */
  100839. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  100840. /**
  100841. * Intensity of the direct lights e.g. the four lights available in your scene.
  100842. * This impacts both the direct diffuse and specular highlights.
  100843. */
  100844. directIntensity: number;
  100845. /**
  100846. * Intensity of the emissive part of the material.
  100847. * This helps controlling the emissive effect without modifying the emissive color.
  100848. */
  100849. emissiveIntensity: number;
  100850. /**
  100851. * Intensity of the environment e.g. how much the environment will light the object
  100852. * either through harmonics for rough material or through the refelction for shiny ones.
  100853. */
  100854. environmentIntensity: number;
  100855. /**
  100856. * This is a special control allowing the reduction of the specular highlights coming from the
  100857. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  100858. */
  100859. specularIntensity: number;
  100860. /**
  100861. * Debug Control allowing disabling the bump map on this material.
  100862. */
  100863. disableBumpMap: boolean;
  100864. /**
  100865. * AKA Diffuse Texture in standard nomenclature.
  100866. */
  100867. albedoTexture: BaseTexture;
  100868. /**
  100869. * AKA Occlusion Texture in other nomenclature.
  100870. */
  100871. ambientTexture: BaseTexture;
  100872. /**
  100873. * AKA Occlusion Texture Intensity in other nomenclature.
  100874. */
  100875. ambientTextureStrength: number;
  100876. /**
  100877. * Defines how much the AO map is occluding the analytical lights (point spot...).
  100878. * 1 means it completely occludes it
  100879. * 0 mean it has no impact
  100880. */
  100881. ambientTextureImpactOnAnalyticalLights: number;
  100882. /**
  100883. * Stores the alpha values in a texture.
  100884. */
  100885. opacityTexture: BaseTexture;
  100886. /**
  100887. * Stores the reflection values in a texture.
  100888. */
  100889. reflectionTexture: Nullable<BaseTexture>;
  100890. /**
  100891. * Stores the emissive values in a texture.
  100892. */
  100893. emissiveTexture: BaseTexture;
  100894. /**
  100895. * AKA Specular texture in other nomenclature.
  100896. */
  100897. reflectivityTexture: BaseTexture;
  100898. /**
  100899. * Used to switch from specular/glossiness to metallic/roughness workflow.
  100900. */
  100901. metallicTexture: BaseTexture;
  100902. /**
  100903. * Specifies the metallic scalar of the metallic/roughness workflow.
  100904. * Can also be used to scale the metalness values of the metallic texture.
  100905. */
  100906. metallic: Nullable<number>;
  100907. /**
  100908. * Specifies the roughness scalar of the metallic/roughness workflow.
  100909. * Can also be used to scale the roughness values of the metallic texture.
  100910. */
  100911. roughness: Nullable<number>;
  100912. /**
  100913. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  100914. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  100915. */
  100916. microSurfaceTexture: BaseTexture;
  100917. /**
  100918. * Stores surface normal data used to displace a mesh in a texture.
  100919. */
  100920. bumpTexture: BaseTexture;
  100921. /**
  100922. * Stores the pre-calculated light information of a mesh in a texture.
  100923. */
  100924. lightmapTexture: BaseTexture;
  100925. /**
  100926. * Stores the refracted light information in a texture.
  100927. */
  100928. refractionTexture: BaseTexture;
  100929. /**
  100930. * The color of a material in ambient lighting.
  100931. */
  100932. ambientColor: Color3;
  100933. /**
  100934. * AKA Diffuse Color in other nomenclature.
  100935. */
  100936. albedoColor: Color3;
  100937. /**
  100938. * AKA Specular Color in other nomenclature.
  100939. */
  100940. reflectivityColor: Color3;
  100941. /**
  100942. * The color reflected from the material.
  100943. */
  100944. reflectionColor: Color3;
  100945. /**
  100946. * The color emitted from the material.
  100947. */
  100948. emissiveColor: Color3;
  100949. /**
  100950. * AKA Glossiness in other nomenclature.
  100951. */
  100952. microSurface: number;
  100953. /**
  100954. * source material index of refraction (IOR)' / 'destination material IOR.
  100955. */
  100956. indexOfRefraction: number;
  100957. /**
  100958. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  100959. */
  100960. invertRefractionY: boolean;
  100961. /**
  100962. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  100963. * Materials half opaque for instance using refraction could benefit from this control.
  100964. */
  100965. linkRefractionWithTransparency: boolean;
  100966. /**
  100967. * If true, the light map contains occlusion information instead of lighting info.
  100968. */
  100969. useLightmapAsShadowmap: boolean;
  100970. /**
  100971. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  100972. */
  100973. useAlphaFromAlbedoTexture: boolean;
  100974. /**
  100975. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  100976. */
  100977. forceAlphaTest: boolean;
  100978. /**
  100979. * Defines the alpha limits in alpha test mode.
  100980. */
  100981. alphaCutOff: number;
  100982. /**
  100983. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  100984. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100985. */
  100986. useSpecularOverAlpha: boolean;
  100987. /**
  100988. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  100989. */
  100990. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  100991. /**
  100992. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  100993. */
  100994. useRoughnessFromMetallicTextureAlpha: boolean;
  100995. /**
  100996. * Specifies if the metallic texture contains the roughness information in its green channel.
  100997. */
  100998. useRoughnessFromMetallicTextureGreen: boolean;
  100999. /**
  101000. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101001. */
  101002. useMetallnessFromMetallicTextureBlue: boolean;
  101003. /**
  101004. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101005. */
  101006. useAmbientOcclusionFromMetallicTextureRed: boolean;
  101007. /**
  101008. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101009. */
  101010. useAmbientInGrayScale: boolean;
  101011. /**
  101012. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101013. * The material will try to infer what glossiness each pixel should be.
  101014. */
  101015. useAutoMicroSurfaceFromReflectivityMap: boolean;
  101016. /**
  101017. * BJS is using an harcoded light falloff based on a manually sets up range.
  101018. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101019. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101020. */
  101021. /**
  101022. * BJS is using an harcoded light falloff based on a manually sets up range.
  101023. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101024. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101025. */
  101026. usePhysicalLightFalloff: boolean;
  101027. /**
  101028. * In order to support the falloff compatibility with gltf, a special mode has been added
  101029. * to reproduce the gltf light falloff.
  101030. */
  101031. /**
  101032. * In order to support the falloff compatibility with gltf, a special mode has been added
  101033. * to reproduce the gltf light falloff.
  101034. */
  101035. useGLTFLightFalloff: boolean;
  101036. /**
  101037. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101038. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101039. */
  101040. useRadianceOverAlpha: boolean;
  101041. /**
  101042. * Allows using an object space normal map (instead of tangent space).
  101043. */
  101044. useObjectSpaceNormalMap: boolean;
  101045. /**
  101046. * Allows using the bump map in parallax mode.
  101047. */
  101048. useParallax: boolean;
  101049. /**
  101050. * Allows using the bump map in parallax occlusion mode.
  101051. */
  101052. useParallaxOcclusion: boolean;
  101053. /**
  101054. * Controls the scale bias of the parallax mode.
  101055. */
  101056. parallaxScaleBias: number;
  101057. /**
  101058. * If sets to true, disables all the lights affecting the material.
  101059. */
  101060. disableLighting: boolean;
  101061. /**
  101062. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101063. */
  101064. forceIrradianceInFragment: boolean;
  101065. /**
  101066. * Number of Simultaneous lights allowed on the material.
  101067. */
  101068. maxSimultaneousLights: number;
  101069. /**
  101070. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101071. */
  101072. invertNormalMapX: boolean;
  101073. /**
  101074. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101075. */
  101076. invertNormalMapY: boolean;
  101077. /**
  101078. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101079. */
  101080. twoSidedLighting: boolean;
  101081. /**
  101082. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101083. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101084. */
  101085. useAlphaFresnel: boolean;
  101086. /**
  101087. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101088. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101089. */
  101090. useLinearAlphaFresnel: boolean;
  101091. /**
  101092. * Let user defines the brdf lookup texture used for IBL.
  101093. * A default 8bit version is embedded but you could point at :
  101094. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  101095. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101096. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101097. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101098. */
  101099. environmentBRDFTexture: Nullable<BaseTexture>;
  101100. /**
  101101. * Force normal to face away from face.
  101102. */
  101103. forceNormalForward: boolean;
  101104. /**
  101105. * Enables specular anti aliasing in the PBR shader.
  101106. * It will both interacts on the Geometry for analytical and IBL lighting.
  101107. * It also prefilter the roughness map based on the bump values.
  101108. */
  101109. enableSpecularAntiAliasing: boolean;
  101110. /**
  101111. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101112. * makes the reflect vector face the model (under horizon).
  101113. */
  101114. useHorizonOcclusion: boolean;
  101115. /**
  101116. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101117. * too much the area relying on ambient texture to define their ambient occlusion.
  101118. */
  101119. useRadianceOcclusion: boolean;
  101120. /**
  101121. * If set to true, no lighting calculations will be applied.
  101122. */
  101123. unlit: boolean;
  101124. /**
  101125. * Gets the image processing configuration used either in this material.
  101126. */
  101127. /**
  101128. * Sets the Default image processing configuration used either in the this material.
  101129. *
  101130. * If sets to null, the scene one is in use.
  101131. */
  101132. imageProcessingConfiguration: ImageProcessingConfiguration;
  101133. /**
  101134. * Gets wether the color curves effect is enabled.
  101135. */
  101136. /**
  101137. * Sets wether the color curves effect is enabled.
  101138. */
  101139. cameraColorCurvesEnabled: boolean;
  101140. /**
  101141. * Gets wether the color grading effect is enabled.
  101142. */
  101143. /**
  101144. * Gets wether the color grading effect is enabled.
  101145. */
  101146. cameraColorGradingEnabled: boolean;
  101147. /**
  101148. * Gets wether tonemapping is enabled or not.
  101149. */
  101150. /**
  101151. * Sets wether tonemapping is enabled or not
  101152. */
  101153. cameraToneMappingEnabled: boolean;
  101154. /**
  101155. * The camera exposure used on this material.
  101156. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101157. * This corresponds to a photographic exposure.
  101158. */
  101159. /**
  101160. * The camera exposure used on this material.
  101161. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101162. * This corresponds to a photographic exposure.
  101163. */
  101164. cameraExposure: number;
  101165. /**
  101166. * Gets The camera contrast used on this material.
  101167. */
  101168. /**
  101169. * Sets The camera contrast used on this material.
  101170. */
  101171. cameraContrast: number;
  101172. /**
  101173. * Gets the Color Grading 2D Lookup Texture.
  101174. */
  101175. /**
  101176. * Sets the Color Grading 2D Lookup Texture.
  101177. */
  101178. cameraColorGradingTexture: Nullable<BaseTexture>;
  101179. /**
  101180. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101181. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101182. * 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;
  101183. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101184. */
  101185. /**
  101186. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101187. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101188. * 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;
  101189. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101190. */
  101191. cameraColorCurves: Nullable<ColorCurves>;
  101192. /**
  101193. * Instantiates a new PBRMaterial instance.
  101194. *
  101195. * @param name The material name
  101196. * @param scene The scene the material will be use in.
  101197. */
  101198. constructor(name: string, scene: Scene);
  101199. /**
  101200. * Returns the name of this material class.
  101201. */
  101202. getClassName(): string;
  101203. /**
  101204. * Makes a duplicate of the current material.
  101205. * @param name - name to use for the new material.
  101206. */
  101207. clone(name: string): PBRMaterial;
  101208. /**
  101209. * Serializes this PBR Material.
  101210. * @returns - An object with the serialized material.
  101211. */
  101212. serialize(): any;
  101213. /**
  101214. * Parses a PBR Material from a serialized object.
  101215. * @param source - Serialized object.
  101216. * @param scene - BJS scene instance.
  101217. * @param rootUrl - url for the scene object
  101218. * @returns - PBRMaterial
  101219. */
  101220. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  101221. }
  101222. }
  101223. declare module BABYLON {
  101224. /** @hidden */
  101225. export var _forceSceneHelpersToBundle: boolean;
  101226. interface Scene {
  101227. /**
  101228. * Creates a default light for the scene.
  101229. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  101230. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  101231. */
  101232. createDefaultLight(replace?: boolean): void;
  101233. /**
  101234. * Creates a default camera for the scene.
  101235. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  101236. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  101237. * @param replace has default false, when true replaces the active camera in the scene
  101238. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  101239. */
  101240. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  101241. /**
  101242. * Creates a default camera and a default light.
  101243. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  101244. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  101245. * @param replace has the default false, when true replaces the active camera/light in the scene
  101246. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  101247. */
  101248. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  101249. /**
  101250. * Creates a new sky box
  101251. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  101252. * @param environmentTexture defines the texture to use as environment texture
  101253. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  101254. * @param scale defines the overall scale of the skybox
  101255. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  101256. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  101257. * @returns a new mesh holding the sky box
  101258. */
  101259. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  101260. /**
  101261. * Creates a new environment
  101262. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  101263. * @param options defines the options you can use to configure the environment
  101264. * @returns the new EnvironmentHelper
  101265. */
  101266. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  101267. /**
  101268. * Creates a new VREXperienceHelper
  101269. * @see http://doc.babylonjs.com/how_to/webvr_helper
  101270. * @param webVROptions defines the options used to create the new VREXperienceHelper
  101271. * @returns a new VREXperienceHelper
  101272. */
  101273. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  101274. /**
  101275. * Creates a new XREXperienceHelper
  101276. * @see http://doc.babylonjs.com/how_to/webxr
  101277. * @returns a promise for a new XREXperienceHelper
  101278. */
  101279. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  101280. }
  101281. }
  101282. declare module BABYLON {
  101283. /**
  101284. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  101285. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  101286. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  101287. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  101288. */
  101289. export class VideoDome extends TransformNode {
  101290. /**
  101291. * Define the video source as a Monoscopic panoramic 360 video.
  101292. */
  101293. static readonly MODE_MONOSCOPIC: number;
  101294. /**
  101295. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  101296. */
  101297. static readonly MODE_TOPBOTTOM: number;
  101298. /**
  101299. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  101300. */
  101301. static readonly MODE_SIDEBYSIDE: number;
  101302. private _useDirectMapping;
  101303. /**
  101304. * The video texture being displayed on the sphere
  101305. */
  101306. protected _videoTexture: VideoTexture;
  101307. /**
  101308. * Gets the video texture being displayed on the sphere
  101309. */
  101310. readonly videoTexture: VideoTexture;
  101311. /**
  101312. * The skybox material
  101313. */
  101314. protected _material: BackgroundMaterial;
  101315. /**
  101316. * The surface used for the skybox
  101317. */
  101318. protected _mesh: Mesh;
  101319. /**
  101320. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  101321. * Also see the options.resolution property.
  101322. */
  101323. fovMultiplier: number;
  101324. private _videoMode;
  101325. /**
  101326. * Gets or set the current video mode for the video. It can be:
  101327. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  101328. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  101329. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  101330. */
  101331. videoMode: number;
  101332. /**
  101333. * Oberserver used in Stereoscopic VR Mode.
  101334. */
  101335. private _onBeforeCameraRenderObserver;
  101336. /**
  101337. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  101338. * @param name Element's name, child elements will append suffixes for their own names.
  101339. * @param urlsOrVideo defines the url(s) or the video element to use
  101340. * @param options An object containing optional or exposed sub element properties
  101341. */
  101342. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  101343. resolution?: number;
  101344. clickToPlay?: boolean;
  101345. autoPlay?: boolean;
  101346. loop?: boolean;
  101347. size?: number;
  101348. poster?: string;
  101349. useDirectMapping?: boolean;
  101350. }, scene: Scene);
  101351. private _changeVideoMode;
  101352. /**
  101353. * Releases resources associated with this node.
  101354. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101355. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101356. */
  101357. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101358. }
  101359. }
  101360. declare module BABYLON {
  101361. /**
  101362. * This class can be used to get instrumentation data from a Babylon engine
  101363. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  101364. */
  101365. export class EngineInstrumentation implements IDisposable {
  101366. /**
  101367. * Define the instrumented engine.
  101368. */
  101369. engine: Engine;
  101370. private _captureGPUFrameTime;
  101371. private _gpuFrameTimeToken;
  101372. private _gpuFrameTime;
  101373. private _captureShaderCompilationTime;
  101374. private _shaderCompilationTime;
  101375. private _onBeginFrameObserver;
  101376. private _onEndFrameObserver;
  101377. private _onBeforeShaderCompilationObserver;
  101378. private _onAfterShaderCompilationObserver;
  101379. /**
  101380. * Gets the perf counter used for GPU frame time
  101381. */
  101382. readonly gpuFrameTimeCounter: PerfCounter;
  101383. /**
  101384. * Gets the GPU frame time capture status
  101385. */
  101386. /**
  101387. * Enable or disable the GPU frame time capture
  101388. */
  101389. captureGPUFrameTime: boolean;
  101390. /**
  101391. * Gets the perf counter used for shader compilation time
  101392. */
  101393. readonly shaderCompilationTimeCounter: PerfCounter;
  101394. /**
  101395. * Gets the shader compilation time capture status
  101396. */
  101397. /**
  101398. * Enable or disable the shader compilation time capture
  101399. */
  101400. captureShaderCompilationTime: boolean;
  101401. /**
  101402. * Instantiates a new engine instrumentation.
  101403. * This class can be used to get instrumentation data from a Babylon engine
  101404. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  101405. * @param engine Defines the engine to instrument
  101406. */
  101407. constructor(
  101408. /**
  101409. * Define the instrumented engine.
  101410. */
  101411. engine: Engine);
  101412. /**
  101413. * Dispose and release associated resources.
  101414. */
  101415. dispose(): void;
  101416. }
  101417. }
  101418. declare module BABYLON {
  101419. /**
  101420. * This class can be used to get instrumentation data from a Babylon engine
  101421. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  101422. */
  101423. export class SceneInstrumentation implements IDisposable {
  101424. /**
  101425. * Defines the scene to instrument
  101426. */
  101427. scene: Scene;
  101428. private _captureActiveMeshesEvaluationTime;
  101429. private _activeMeshesEvaluationTime;
  101430. private _captureRenderTargetsRenderTime;
  101431. private _renderTargetsRenderTime;
  101432. private _captureFrameTime;
  101433. private _frameTime;
  101434. private _captureRenderTime;
  101435. private _renderTime;
  101436. private _captureInterFrameTime;
  101437. private _interFrameTime;
  101438. private _captureParticlesRenderTime;
  101439. private _particlesRenderTime;
  101440. private _captureSpritesRenderTime;
  101441. private _spritesRenderTime;
  101442. private _capturePhysicsTime;
  101443. private _physicsTime;
  101444. private _captureAnimationsTime;
  101445. private _animationsTime;
  101446. private _captureCameraRenderTime;
  101447. private _cameraRenderTime;
  101448. private _onBeforeActiveMeshesEvaluationObserver;
  101449. private _onAfterActiveMeshesEvaluationObserver;
  101450. private _onBeforeRenderTargetsRenderObserver;
  101451. private _onAfterRenderTargetsRenderObserver;
  101452. private _onAfterRenderObserver;
  101453. private _onBeforeDrawPhaseObserver;
  101454. private _onAfterDrawPhaseObserver;
  101455. private _onBeforeAnimationsObserver;
  101456. private _onBeforeParticlesRenderingObserver;
  101457. private _onAfterParticlesRenderingObserver;
  101458. private _onBeforeSpritesRenderingObserver;
  101459. private _onAfterSpritesRenderingObserver;
  101460. private _onBeforePhysicsObserver;
  101461. private _onAfterPhysicsObserver;
  101462. private _onAfterAnimationsObserver;
  101463. private _onBeforeCameraRenderObserver;
  101464. private _onAfterCameraRenderObserver;
  101465. /**
  101466. * Gets the perf counter used for active meshes evaluation time
  101467. */
  101468. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  101469. /**
  101470. * Gets the active meshes evaluation time capture status
  101471. */
  101472. /**
  101473. * Enable or disable the active meshes evaluation time capture
  101474. */
  101475. captureActiveMeshesEvaluationTime: boolean;
  101476. /**
  101477. * Gets the perf counter used for render targets render time
  101478. */
  101479. readonly renderTargetsRenderTimeCounter: PerfCounter;
  101480. /**
  101481. * Gets the render targets render time capture status
  101482. */
  101483. /**
  101484. * Enable or disable the render targets render time capture
  101485. */
  101486. captureRenderTargetsRenderTime: boolean;
  101487. /**
  101488. * Gets the perf counter used for particles render time
  101489. */
  101490. readonly particlesRenderTimeCounter: PerfCounter;
  101491. /**
  101492. * Gets the particles render time capture status
  101493. */
  101494. /**
  101495. * Enable or disable the particles render time capture
  101496. */
  101497. captureParticlesRenderTime: boolean;
  101498. /**
  101499. * Gets the perf counter used for sprites render time
  101500. */
  101501. readonly spritesRenderTimeCounter: PerfCounter;
  101502. /**
  101503. * Gets the sprites render time capture status
  101504. */
  101505. /**
  101506. * Enable or disable the sprites render time capture
  101507. */
  101508. captureSpritesRenderTime: boolean;
  101509. /**
  101510. * Gets the perf counter used for physics time
  101511. */
  101512. readonly physicsTimeCounter: PerfCounter;
  101513. /**
  101514. * Gets the physics time capture status
  101515. */
  101516. /**
  101517. * Enable or disable the physics time capture
  101518. */
  101519. capturePhysicsTime: boolean;
  101520. /**
  101521. * Gets the perf counter used for animations time
  101522. */
  101523. readonly animationsTimeCounter: PerfCounter;
  101524. /**
  101525. * Gets the animations time capture status
  101526. */
  101527. /**
  101528. * Enable or disable the animations time capture
  101529. */
  101530. captureAnimationsTime: boolean;
  101531. /**
  101532. * Gets the perf counter used for frame time capture
  101533. */
  101534. readonly frameTimeCounter: PerfCounter;
  101535. /**
  101536. * Gets the frame time capture status
  101537. */
  101538. /**
  101539. * Enable or disable the frame time capture
  101540. */
  101541. captureFrameTime: boolean;
  101542. /**
  101543. * Gets the perf counter used for inter-frames time capture
  101544. */
  101545. readonly interFrameTimeCounter: PerfCounter;
  101546. /**
  101547. * Gets the inter-frames time capture status
  101548. */
  101549. /**
  101550. * Enable or disable the inter-frames time capture
  101551. */
  101552. captureInterFrameTime: boolean;
  101553. /**
  101554. * Gets the perf counter used for render time capture
  101555. */
  101556. readonly renderTimeCounter: PerfCounter;
  101557. /**
  101558. * Gets the render time capture status
  101559. */
  101560. /**
  101561. * Enable or disable the render time capture
  101562. */
  101563. captureRenderTime: boolean;
  101564. /**
  101565. * Gets the perf counter used for camera render time capture
  101566. */
  101567. readonly cameraRenderTimeCounter: PerfCounter;
  101568. /**
  101569. * Gets the camera render time capture status
  101570. */
  101571. /**
  101572. * Enable or disable the camera render time capture
  101573. */
  101574. captureCameraRenderTime: boolean;
  101575. /**
  101576. * Gets the perf counter used for draw calls
  101577. */
  101578. readonly drawCallsCounter: PerfCounter;
  101579. /**
  101580. * Gets the perf counter used for texture collisions
  101581. */
  101582. readonly textureCollisionsCounter: PerfCounter;
  101583. /**
  101584. * Instantiates a new scene instrumentation.
  101585. * This class can be used to get instrumentation data from a Babylon engine
  101586. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  101587. * @param scene Defines the scene to instrument
  101588. */
  101589. constructor(
  101590. /**
  101591. * Defines the scene to instrument
  101592. */
  101593. scene: Scene);
  101594. /**
  101595. * Dispose and release associated resources.
  101596. */
  101597. dispose(): void;
  101598. }
  101599. }
  101600. declare module BABYLON {
  101601. /** @hidden */
  101602. export var glowMapGenerationPixelShader: {
  101603. name: string;
  101604. shader: string;
  101605. };
  101606. }
  101607. declare module BABYLON {
  101608. /** @hidden */
  101609. export var glowMapGenerationVertexShader: {
  101610. name: string;
  101611. shader: string;
  101612. };
  101613. }
  101614. declare module BABYLON {
  101615. /**
  101616. * Effect layer options. This helps customizing the behaviour
  101617. * of the effect layer.
  101618. */
  101619. export interface IEffectLayerOptions {
  101620. /**
  101621. * Multiplication factor apply to the canvas size to compute the render target size
  101622. * used to generated the objects (the smaller the faster).
  101623. */
  101624. mainTextureRatio: number;
  101625. /**
  101626. * Enforces a fixed size texture to ensure effect stability across devices.
  101627. */
  101628. mainTextureFixedSize?: number;
  101629. /**
  101630. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  101631. */
  101632. alphaBlendingMode: number;
  101633. /**
  101634. * The camera attached to the layer.
  101635. */
  101636. camera: Nullable<Camera>;
  101637. /**
  101638. * The rendering group to draw the layer in.
  101639. */
  101640. renderingGroupId: number;
  101641. }
  101642. /**
  101643. * The effect layer Helps adding post process effect blended with the main pass.
  101644. *
  101645. * This can be for instance use to generate glow or higlight effects on the scene.
  101646. *
  101647. * The effect layer class can not be used directly and is intented to inherited from to be
  101648. * customized per effects.
  101649. */
  101650. export abstract class EffectLayer {
  101651. private _vertexBuffers;
  101652. private _indexBuffer;
  101653. private _cachedDefines;
  101654. private _effectLayerMapGenerationEffect;
  101655. private _effectLayerOptions;
  101656. private _mergeEffect;
  101657. protected _scene: Scene;
  101658. protected _engine: Engine;
  101659. protected _maxSize: number;
  101660. protected _mainTextureDesiredSize: ISize;
  101661. protected _mainTexture: RenderTargetTexture;
  101662. protected _shouldRender: boolean;
  101663. protected _postProcesses: PostProcess[];
  101664. protected _textures: BaseTexture[];
  101665. protected _emissiveTextureAndColor: {
  101666. texture: Nullable<BaseTexture>;
  101667. color: Color4;
  101668. };
  101669. /**
  101670. * The name of the layer
  101671. */
  101672. name: string;
  101673. /**
  101674. * The clear color of the texture used to generate the glow map.
  101675. */
  101676. neutralColor: Color4;
  101677. /**
  101678. * Specifies wether the highlight layer is enabled or not.
  101679. */
  101680. isEnabled: boolean;
  101681. /**
  101682. * Gets the camera attached to the layer.
  101683. */
  101684. readonly camera: Nullable<Camera>;
  101685. /**
  101686. * Gets the rendering group id the layer should render in.
  101687. */
  101688. readonly renderingGroupId: number;
  101689. /**
  101690. * An event triggered when the effect layer has been disposed.
  101691. */
  101692. onDisposeObservable: Observable<EffectLayer>;
  101693. /**
  101694. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  101695. */
  101696. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  101697. /**
  101698. * An event triggered when the generated texture is being merged in the scene.
  101699. */
  101700. onBeforeComposeObservable: Observable<EffectLayer>;
  101701. /**
  101702. * An event triggered when the generated texture has been merged in the scene.
  101703. */
  101704. onAfterComposeObservable: Observable<EffectLayer>;
  101705. /**
  101706. * An event triggered when the efffect layer changes its size.
  101707. */
  101708. onSizeChangedObservable: Observable<EffectLayer>;
  101709. /** @hidden */
  101710. static _SceneComponentInitialization: (scene: Scene) => void;
  101711. /**
  101712. * Instantiates a new effect Layer and references it in the scene.
  101713. * @param name The name of the layer
  101714. * @param scene The scene to use the layer in
  101715. */
  101716. constructor(
  101717. /** The Friendly of the effect in the scene */
  101718. name: string, scene: Scene);
  101719. /**
  101720. * Get the effect name of the layer.
  101721. * @return The effect name
  101722. */
  101723. abstract getEffectName(): string;
  101724. /**
  101725. * Checks for the readiness of the element composing the layer.
  101726. * @param subMesh the mesh to check for
  101727. * @param useInstances specify wether or not to use instances to render the mesh
  101728. * @return true if ready otherwise, false
  101729. */
  101730. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  101731. /**
  101732. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  101733. * @returns true if the effect requires stencil during the main canvas render pass.
  101734. */
  101735. abstract needStencil(): boolean;
  101736. /**
  101737. * Create the merge effect. This is the shader use to blit the information back
  101738. * to the main canvas at the end of the scene rendering.
  101739. * @returns The effect containing the shader used to merge the effect on the main canvas
  101740. */
  101741. protected abstract _createMergeEffect(): Effect;
  101742. /**
  101743. * Creates the render target textures and post processes used in the effect layer.
  101744. */
  101745. protected abstract _createTextureAndPostProcesses(): void;
  101746. /**
  101747. * Implementation specific of rendering the generating effect on the main canvas.
  101748. * @param effect The effect used to render through
  101749. */
  101750. protected abstract _internalRender(effect: Effect): void;
  101751. /**
  101752. * Sets the required values for both the emissive texture and and the main color.
  101753. */
  101754. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  101755. /**
  101756. * Free any resources and references associated to a mesh.
  101757. * Internal use
  101758. * @param mesh The mesh to free.
  101759. */
  101760. abstract _disposeMesh(mesh: Mesh): void;
  101761. /**
  101762. * Serializes this layer (Glow or Highlight for example)
  101763. * @returns a serialized layer object
  101764. */
  101765. abstract serialize?(): any;
  101766. /**
  101767. * Initializes the effect layer with the required options.
  101768. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  101769. */
  101770. protected _init(options: Partial<IEffectLayerOptions>): void;
  101771. /**
  101772. * Generates the index buffer of the full screen quad blending to the main canvas.
  101773. */
  101774. private _generateIndexBuffer;
  101775. /**
  101776. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  101777. */
  101778. private _genrateVertexBuffer;
  101779. /**
  101780. * Sets the main texture desired size which is the closest power of two
  101781. * of the engine canvas size.
  101782. */
  101783. private _setMainTextureSize;
  101784. /**
  101785. * Creates the main texture for the effect layer.
  101786. */
  101787. protected _createMainTexture(): void;
  101788. /**
  101789. * Adds specific effects defines.
  101790. * @param defines The defines to add specifics to.
  101791. */
  101792. protected _addCustomEffectDefines(defines: string[]): void;
  101793. /**
  101794. * Checks for the readiness of the element composing the layer.
  101795. * @param subMesh the mesh to check for
  101796. * @param useInstances specify wether or not to use instances to render the mesh
  101797. * @param emissiveTexture the associated emissive texture used to generate the glow
  101798. * @return true if ready otherwise, false
  101799. */
  101800. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  101801. /**
  101802. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  101803. */
  101804. render(): void;
  101805. /**
  101806. * Determine if a given mesh will be used in the current effect.
  101807. * @param mesh mesh to test
  101808. * @returns true if the mesh will be used
  101809. */
  101810. hasMesh(mesh: AbstractMesh): boolean;
  101811. /**
  101812. * Returns true if the layer contains information to display, otherwise false.
  101813. * @returns true if the glow layer should be rendered
  101814. */
  101815. shouldRender(): boolean;
  101816. /**
  101817. * Returns true if the mesh should render, otherwise false.
  101818. * @param mesh The mesh to render
  101819. * @returns true if it should render otherwise false
  101820. */
  101821. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  101822. /**
  101823. * Returns true if the mesh can be rendered, otherwise false.
  101824. * @param mesh The mesh to render
  101825. * @param material The material used on the mesh
  101826. * @returns true if it can be rendered otherwise false
  101827. */
  101828. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  101829. /**
  101830. * Returns true if the mesh should render, otherwise false.
  101831. * @param mesh The mesh to render
  101832. * @returns true if it should render otherwise false
  101833. */
  101834. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  101835. /**
  101836. * Renders the submesh passed in parameter to the generation map.
  101837. */
  101838. protected _renderSubMesh(subMesh: SubMesh): void;
  101839. /**
  101840. * Rebuild the required buffers.
  101841. * @hidden Internal use only.
  101842. */
  101843. _rebuild(): void;
  101844. /**
  101845. * Dispose only the render target textures and post process.
  101846. */
  101847. private _disposeTextureAndPostProcesses;
  101848. /**
  101849. * Dispose the highlight layer and free resources.
  101850. */
  101851. dispose(): void;
  101852. /**
  101853. * Gets the class name of the effect layer
  101854. * @returns the string with the class name of the effect layer
  101855. */
  101856. getClassName(): string;
  101857. /**
  101858. * Creates an effect layer from parsed effect layer data
  101859. * @param parsedEffectLayer defines effect layer data
  101860. * @param scene defines the current scene
  101861. * @param rootUrl defines the root URL containing the effect layer information
  101862. * @returns a parsed effect Layer
  101863. */
  101864. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  101865. }
  101866. }
  101867. declare module BABYLON {
  101868. interface AbstractScene {
  101869. /**
  101870. * The list of effect layers (highlights/glow) added to the scene
  101871. * @see http://doc.babylonjs.com/how_to/highlight_layer
  101872. * @see http://doc.babylonjs.com/how_to/glow_layer
  101873. */
  101874. effectLayers: Array<EffectLayer>;
  101875. /**
  101876. * Removes the given effect layer from this scene.
  101877. * @param toRemove defines the effect layer to remove
  101878. * @returns the index of the removed effect layer
  101879. */
  101880. removeEffectLayer(toRemove: EffectLayer): number;
  101881. /**
  101882. * Adds the given effect layer to this scene
  101883. * @param newEffectLayer defines the effect layer to add
  101884. */
  101885. addEffectLayer(newEffectLayer: EffectLayer): void;
  101886. }
  101887. /**
  101888. * Defines the layer scene component responsible to manage any effect layers
  101889. * in a given scene.
  101890. */
  101891. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  101892. /**
  101893. * The component name helpfull to identify the component in the list of scene components.
  101894. */
  101895. readonly name: string;
  101896. /**
  101897. * The scene the component belongs to.
  101898. */
  101899. scene: Scene;
  101900. private _engine;
  101901. private _renderEffects;
  101902. private _needStencil;
  101903. private _previousStencilState;
  101904. /**
  101905. * Creates a new instance of the component for the given scene
  101906. * @param scene Defines the scene to register the component in
  101907. */
  101908. constructor(scene: Scene);
  101909. /**
  101910. * Registers the component in a given scene
  101911. */
  101912. register(): void;
  101913. /**
  101914. * Rebuilds the elements related to this component in case of
  101915. * context lost for instance.
  101916. */
  101917. rebuild(): void;
  101918. /**
  101919. * Serializes the component data to the specified json object
  101920. * @param serializationObject The object to serialize to
  101921. */
  101922. serialize(serializationObject: any): void;
  101923. /**
  101924. * Adds all the element from the container to the scene
  101925. * @param container the container holding the elements
  101926. */
  101927. addFromContainer(container: AbstractScene): void;
  101928. /**
  101929. * Removes all the elements in the container from the scene
  101930. * @param container contains the elements to remove
  101931. */
  101932. removeFromContainer(container: AbstractScene): void;
  101933. /**
  101934. * Disposes the component and the associated ressources.
  101935. */
  101936. dispose(): void;
  101937. private _isReadyForMesh;
  101938. private _renderMainTexture;
  101939. private _setStencil;
  101940. private _setStencilBack;
  101941. private _draw;
  101942. private _drawCamera;
  101943. private _drawRenderingGroup;
  101944. }
  101945. }
  101946. declare module BABYLON {
  101947. /** @hidden */
  101948. export var glowMapMergePixelShader: {
  101949. name: string;
  101950. shader: string;
  101951. };
  101952. }
  101953. declare module BABYLON {
  101954. /** @hidden */
  101955. export var glowMapMergeVertexShader: {
  101956. name: string;
  101957. shader: string;
  101958. };
  101959. }
  101960. declare module BABYLON {
  101961. interface AbstractScene {
  101962. /**
  101963. * Return a the first highlight layer of the scene with a given name.
  101964. * @param name The name of the highlight layer to look for.
  101965. * @return The highlight layer if found otherwise null.
  101966. */
  101967. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  101968. }
  101969. /**
  101970. * Glow layer options. This helps customizing the behaviour
  101971. * of the glow layer.
  101972. */
  101973. export interface IGlowLayerOptions {
  101974. /**
  101975. * Multiplication factor apply to the canvas size to compute the render target size
  101976. * used to generated the glowing objects (the smaller the faster).
  101977. */
  101978. mainTextureRatio: number;
  101979. /**
  101980. * Enforces a fixed size texture to ensure resize independant blur.
  101981. */
  101982. mainTextureFixedSize?: number;
  101983. /**
  101984. * How big is the kernel of the blur texture.
  101985. */
  101986. blurKernelSize: number;
  101987. /**
  101988. * The camera attached to the layer.
  101989. */
  101990. camera: Nullable<Camera>;
  101991. /**
  101992. * Enable MSAA by chosing the number of samples.
  101993. */
  101994. mainTextureSamples?: number;
  101995. /**
  101996. * The rendering group to draw the layer in.
  101997. */
  101998. renderingGroupId: number;
  101999. }
  102000. /**
  102001. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  102002. *
  102003. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  102004. * glowy meshes to your scene.
  102005. *
  102006. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  102007. */
  102008. export class GlowLayer extends EffectLayer {
  102009. /**
  102010. * Effect Name of the layer.
  102011. */
  102012. static readonly EffectName: string;
  102013. /**
  102014. * The default blur kernel size used for the glow.
  102015. */
  102016. static DefaultBlurKernelSize: number;
  102017. /**
  102018. * The default texture size ratio used for the glow.
  102019. */
  102020. static DefaultTextureRatio: number;
  102021. /**
  102022. * Sets the kernel size of the blur.
  102023. */
  102024. /**
  102025. * Gets the kernel size of the blur.
  102026. */
  102027. blurKernelSize: number;
  102028. /**
  102029. * Sets the glow intensity.
  102030. */
  102031. /**
  102032. * Gets the glow intensity.
  102033. */
  102034. intensity: number;
  102035. private _options;
  102036. private _intensity;
  102037. private _horizontalBlurPostprocess1;
  102038. private _verticalBlurPostprocess1;
  102039. private _horizontalBlurPostprocess2;
  102040. private _verticalBlurPostprocess2;
  102041. private _blurTexture1;
  102042. private _blurTexture2;
  102043. private _postProcesses1;
  102044. private _postProcesses2;
  102045. private _includedOnlyMeshes;
  102046. private _excludedMeshes;
  102047. /**
  102048. * Callback used to let the user override the color selection on a per mesh basis
  102049. */
  102050. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  102051. /**
  102052. * Callback used to let the user override the texture selection on a per mesh basis
  102053. */
  102054. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  102055. /**
  102056. * Instantiates a new glow Layer and references it to the scene.
  102057. * @param name The name of the layer
  102058. * @param scene The scene to use the layer in
  102059. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  102060. */
  102061. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  102062. /**
  102063. * Get the effect name of the layer.
  102064. * @return The effect name
  102065. */
  102066. getEffectName(): string;
  102067. /**
  102068. * Create the merge effect. This is the shader use to blit the information back
  102069. * to the main canvas at the end of the scene rendering.
  102070. */
  102071. protected _createMergeEffect(): Effect;
  102072. /**
  102073. * Creates the render target textures and post processes used in the glow layer.
  102074. */
  102075. protected _createTextureAndPostProcesses(): void;
  102076. /**
  102077. * Checks for the readiness of the element composing the layer.
  102078. * @param subMesh the mesh to check for
  102079. * @param useInstances specify wether or not to use instances to render the mesh
  102080. * @param emissiveTexture the associated emissive texture used to generate the glow
  102081. * @return true if ready otherwise, false
  102082. */
  102083. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102084. /**
  102085. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102086. */
  102087. needStencil(): boolean;
  102088. /**
  102089. * Returns true if the mesh can be rendered, otherwise false.
  102090. * @param mesh The mesh to render
  102091. * @param material The material used on the mesh
  102092. * @returns true if it can be rendered otherwise false
  102093. */
  102094. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  102095. /**
  102096. * Implementation specific of rendering the generating effect on the main canvas.
  102097. * @param effect The effect used to render through
  102098. */
  102099. protected _internalRender(effect: Effect): void;
  102100. /**
  102101. * Sets the required values for both the emissive texture and and the main color.
  102102. */
  102103. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  102104. /**
  102105. * Returns true if the mesh should render, otherwise false.
  102106. * @param mesh The mesh to render
  102107. * @returns true if it should render otherwise false
  102108. */
  102109. protected _shouldRenderMesh(mesh: Mesh): boolean;
  102110. /**
  102111. * Adds specific effects defines.
  102112. * @param defines The defines to add specifics to.
  102113. */
  102114. protected _addCustomEffectDefines(defines: string[]): void;
  102115. /**
  102116. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  102117. * @param mesh The mesh to exclude from the glow layer
  102118. */
  102119. addExcludedMesh(mesh: Mesh): void;
  102120. /**
  102121. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  102122. * @param mesh The mesh to remove
  102123. */
  102124. removeExcludedMesh(mesh: Mesh): void;
  102125. /**
  102126. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  102127. * @param mesh The mesh to include in the glow layer
  102128. */
  102129. addIncludedOnlyMesh(mesh: Mesh): void;
  102130. /**
  102131. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  102132. * @param mesh The mesh to remove
  102133. */
  102134. removeIncludedOnlyMesh(mesh: Mesh): void;
  102135. /**
  102136. * Determine if a given mesh will be used in the glow layer
  102137. * @param mesh The mesh to test
  102138. * @returns true if the mesh will be highlighted by the current glow layer
  102139. */
  102140. hasMesh(mesh: AbstractMesh): boolean;
  102141. /**
  102142. * Free any resources and references associated to a mesh.
  102143. * Internal use
  102144. * @param mesh The mesh to free.
  102145. * @hidden
  102146. */
  102147. _disposeMesh(mesh: Mesh): void;
  102148. /**
  102149. * Gets the class name of the effect layer
  102150. * @returns the string with the class name of the effect layer
  102151. */
  102152. getClassName(): string;
  102153. /**
  102154. * Serializes this glow layer
  102155. * @returns a serialized glow layer object
  102156. */
  102157. serialize(): any;
  102158. /**
  102159. * Creates a Glow Layer from parsed glow layer data
  102160. * @param parsedGlowLayer defines glow layer data
  102161. * @param scene defines the current scene
  102162. * @param rootUrl defines the root URL containing the glow layer information
  102163. * @returns a parsed Glow Layer
  102164. */
  102165. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  102166. }
  102167. }
  102168. declare module BABYLON {
  102169. /** @hidden */
  102170. export var glowBlurPostProcessPixelShader: {
  102171. name: string;
  102172. shader: string;
  102173. };
  102174. }
  102175. declare module BABYLON {
  102176. interface AbstractScene {
  102177. /**
  102178. * Return a the first highlight layer of the scene with a given name.
  102179. * @param name The name of the highlight layer to look for.
  102180. * @return The highlight layer if found otherwise null.
  102181. */
  102182. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  102183. }
  102184. /**
  102185. * Highlight layer options. This helps customizing the behaviour
  102186. * of the highlight layer.
  102187. */
  102188. export interface IHighlightLayerOptions {
  102189. /**
  102190. * Multiplication factor apply to the canvas size to compute the render target size
  102191. * used to generated the glowing objects (the smaller the faster).
  102192. */
  102193. mainTextureRatio: number;
  102194. /**
  102195. * Enforces a fixed size texture to ensure resize independant blur.
  102196. */
  102197. mainTextureFixedSize?: number;
  102198. /**
  102199. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  102200. * of the picture to blur (the smaller the faster).
  102201. */
  102202. blurTextureSizeRatio: number;
  102203. /**
  102204. * How big in texel of the blur texture is the vertical blur.
  102205. */
  102206. blurVerticalSize: number;
  102207. /**
  102208. * How big in texel of the blur texture is the horizontal blur.
  102209. */
  102210. blurHorizontalSize: number;
  102211. /**
  102212. * Alpha blending mode used to apply the blur. Default is combine.
  102213. */
  102214. alphaBlendingMode: number;
  102215. /**
  102216. * The camera attached to the layer.
  102217. */
  102218. camera: Nullable<Camera>;
  102219. /**
  102220. * Should we display highlight as a solid stroke?
  102221. */
  102222. isStroke?: boolean;
  102223. /**
  102224. * The rendering group to draw the layer in.
  102225. */
  102226. renderingGroupId: number;
  102227. }
  102228. /**
  102229. * The highlight layer Helps adding a glow effect around a mesh.
  102230. *
  102231. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  102232. * glowy meshes to your scene.
  102233. *
  102234. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  102235. */
  102236. export class HighlightLayer extends EffectLayer {
  102237. name: string;
  102238. /**
  102239. * Effect Name of the highlight layer.
  102240. */
  102241. static readonly EffectName: string;
  102242. /**
  102243. * The neutral color used during the preparation of the glow effect.
  102244. * This is black by default as the blend operation is a blend operation.
  102245. */
  102246. static NeutralColor: Color4;
  102247. /**
  102248. * Stencil value used for glowing meshes.
  102249. */
  102250. static GlowingMeshStencilReference: number;
  102251. /**
  102252. * Stencil value used for the other meshes in the scene.
  102253. */
  102254. static NormalMeshStencilReference: number;
  102255. /**
  102256. * Specifies whether or not the inner glow is ACTIVE in the layer.
  102257. */
  102258. innerGlow: boolean;
  102259. /**
  102260. * Specifies whether or not the outer glow is ACTIVE in the layer.
  102261. */
  102262. outerGlow: boolean;
  102263. /**
  102264. * Specifies the horizontal size of the blur.
  102265. */
  102266. /**
  102267. * Gets the horizontal size of the blur.
  102268. */
  102269. blurHorizontalSize: number;
  102270. /**
  102271. * Specifies the vertical size of the blur.
  102272. */
  102273. /**
  102274. * Gets the vertical size of the blur.
  102275. */
  102276. blurVerticalSize: number;
  102277. /**
  102278. * An event triggered when the highlight layer is being blurred.
  102279. */
  102280. onBeforeBlurObservable: Observable<HighlightLayer>;
  102281. /**
  102282. * An event triggered when the highlight layer has been blurred.
  102283. */
  102284. onAfterBlurObservable: Observable<HighlightLayer>;
  102285. private _instanceGlowingMeshStencilReference;
  102286. private _options;
  102287. private _downSamplePostprocess;
  102288. private _horizontalBlurPostprocess;
  102289. private _verticalBlurPostprocess;
  102290. private _blurTexture;
  102291. private _meshes;
  102292. private _excludedMeshes;
  102293. /**
  102294. * Instantiates a new highlight Layer and references it to the scene..
  102295. * @param name The name of the layer
  102296. * @param scene The scene to use the layer in
  102297. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  102298. */
  102299. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  102300. /**
  102301. * Get the effect name of the layer.
  102302. * @return The effect name
  102303. */
  102304. getEffectName(): string;
  102305. /**
  102306. * Create the merge effect. This is the shader use to blit the information back
  102307. * to the main canvas at the end of the scene rendering.
  102308. */
  102309. protected _createMergeEffect(): Effect;
  102310. /**
  102311. * Creates the render target textures and post processes used in the highlight layer.
  102312. */
  102313. protected _createTextureAndPostProcesses(): void;
  102314. /**
  102315. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102316. */
  102317. needStencil(): boolean;
  102318. /**
  102319. * Checks for the readiness of the element composing the layer.
  102320. * @param subMesh the mesh to check for
  102321. * @param useInstances specify wether or not to use instances to render the mesh
  102322. * @param emissiveTexture the associated emissive texture used to generate the glow
  102323. * @return true if ready otherwise, false
  102324. */
  102325. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102326. /**
  102327. * Implementation specific of rendering the generating effect on the main canvas.
  102328. * @param effect The effect used to render through
  102329. */
  102330. protected _internalRender(effect: Effect): void;
  102331. /**
  102332. * Returns true if the layer contains information to display, otherwise false.
  102333. */
  102334. shouldRender(): boolean;
  102335. /**
  102336. * Returns true if the mesh should render, otherwise false.
  102337. * @param mesh The mesh to render
  102338. * @returns true if it should render otherwise false
  102339. */
  102340. protected _shouldRenderMesh(mesh: Mesh): boolean;
  102341. /**
  102342. * Sets the required values for both the emissive texture and and the main color.
  102343. */
  102344. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  102345. /**
  102346. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  102347. * @param mesh The mesh to exclude from the highlight layer
  102348. */
  102349. addExcludedMesh(mesh: Mesh): void;
  102350. /**
  102351. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  102352. * @param mesh The mesh to highlight
  102353. */
  102354. removeExcludedMesh(mesh: Mesh): void;
  102355. /**
  102356. * Determine if a given mesh will be highlighted by the current HighlightLayer
  102357. * @param mesh mesh to test
  102358. * @returns true if the mesh will be highlighted by the current HighlightLayer
  102359. */
  102360. hasMesh(mesh: AbstractMesh): boolean;
  102361. /**
  102362. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  102363. * @param mesh The mesh to highlight
  102364. * @param color The color of the highlight
  102365. * @param glowEmissiveOnly Extract the glow from the emissive texture
  102366. */
  102367. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  102368. /**
  102369. * Remove a mesh from the highlight layer in order to make it stop glowing.
  102370. * @param mesh The mesh to highlight
  102371. */
  102372. removeMesh(mesh: Mesh): void;
  102373. /**
  102374. * Force the stencil to the normal expected value for none glowing parts
  102375. */
  102376. private _defaultStencilReference;
  102377. /**
  102378. * Free any resources and references associated to a mesh.
  102379. * Internal use
  102380. * @param mesh The mesh to free.
  102381. * @hidden
  102382. */
  102383. _disposeMesh(mesh: Mesh): void;
  102384. /**
  102385. * Dispose the highlight layer and free resources.
  102386. */
  102387. dispose(): void;
  102388. /**
  102389. * Gets the class name of the effect layer
  102390. * @returns the string with the class name of the effect layer
  102391. */
  102392. getClassName(): string;
  102393. /**
  102394. * Serializes this Highlight layer
  102395. * @returns a serialized Highlight layer object
  102396. */
  102397. serialize(): any;
  102398. /**
  102399. * Creates a Highlight layer from parsed Highlight layer data
  102400. * @param parsedHightlightLayer defines the Highlight layer data
  102401. * @param scene defines the current scene
  102402. * @param rootUrl defines the root URL containing the Highlight layer information
  102403. * @returns a parsed Highlight layer
  102404. */
  102405. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  102406. }
  102407. }
  102408. declare module BABYLON {
  102409. /** @hidden */
  102410. export var lensFlarePixelShader: {
  102411. name: string;
  102412. shader: string;
  102413. };
  102414. }
  102415. declare module BABYLON {
  102416. /** @hidden */
  102417. export var lensFlareVertexShader: {
  102418. name: string;
  102419. shader: string;
  102420. };
  102421. }
  102422. declare module BABYLON {
  102423. /**
  102424. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  102425. * It is usually composed of several `lensFlare`.
  102426. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102427. */
  102428. export class LensFlareSystem {
  102429. /**
  102430. * Define the name of the lens flare system
  102431. */
  102432. name: string;
  102433. /**
  102434. * List of lens flares used in this system.
  102435. */
  102436. lensFlares: LensFlare[];
  102437. /**
  102438. * Define a limit from the border the lens flare can be visible.
  102439. */
  102440. borderLimit: number;
  102441. /**
  102442. * Define a viewport border we do not want to see the lens flare in.
  102443. */
  102444. viewportBorder: number;
  102445. /**
  102446. * Define a predicate which could limit the list of meshes able to occlude the effect.
  102447. */
  102448. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  102449. /**
  102450. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  102451. */
  102452. layerMask: number;
  102453. /**
  102454. * Define the id of the lens flare system in the scene.
  102455. * (equal to name by default)
  102456. */
  102457. id: string;
  102458. private _scene;
  102459. private _emitter;
  102460. private _vertexBuffers;
  102461. private _indexBuffer;
  102462. private _effect;
  102463. private _positionX;
  102464. private _positionY;
  102465. private _isEnabled;
  102466. /** @hidden */
  102467. static _SceneComponentInitialization: (scene: Scene) => void;
  102468. /**
  102469. * Instantiates a lens flare system.
  102470. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  102471. * It is usually composed of several `lensFlare`.
  102472. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102473. * @param name Define the name of the lens flare system in the scene
  102474. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  102475. * @param scene Define the scene the lens flare system belongs to
  102476. */
  102477. constructor(
  102478. /**
  102479. * Define the name of the lens flare system
  102480. */
  102481. name: string, emitter: any, scene: Scene);
  102482. /**
  102483. * Define if the lens flare system is enabled.
  102484. */
  102485. isEnabled: boolean;
  102486. /**
  102487. * Get the scene the effects belongs to.
  102488. * @returns the scene holding the lens flare system
  102489. */
  102490. getScene(): Scene;
  102491. /**
  102492. * Get the emitter of the lens flare system.
  102493. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  102494. * @returns the emitter of the lens flare system
  102495. */
  102496. getEmitter(): any;
  102497. /**
  102498. * Set the emitter of the lens flare system.
  102499. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  102500. * @param newEmitter Define the new emitter of the system
  102501. */
  102502. setEmitter(newEmitter: any): void;
  102503. /**
  102504. * Get the lens flare system emitter position.
  102505. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  102506. * @returns the position
  102507. */
  102508. getEmitterPosition(): Vector3;
  102509. /**
  102510. * @hidden
  102511. */
  102512. computeEffectivePosition(globalViewport: Viewport): boolean;
  102513. /** @hidden */
  102514. _isVisible(): boolean;
  102515. /**
  102516. * @hidden
  102517. */
  102518. render(): boolean;
  102519. /**
  102520. * Dispose and release the lens flare with its associated resources.
  102521. */
  102522. dispose(): void;
  102523. /**
  102524. * Parse a lens flare system from a JSON repressentation
  102525. * @param parsedLensFlareSystem Define the JSON to parse
  102526. * @param scene Define the scene the parsed system should be instantiated in
  102527. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  102528. * @returns the parsed system
  102529. */
  102530. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  102531. /**
  102532. * Serialize the current Lens Flare System into a JSON representation.
  102533. * @returns the serialized JSON
  102534. */
  102535. serialize(): any;
  102536. }
  102537. }
  102538. declare module BABYLON {
  102539. /**
  102540. * This represents one of the lens effect in a `lensFlareSystem`.
  102541. * It controls one of the indiviual texture used in the effect.
  102542. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102543. */
  102544. export class LensFlare {
  102545. /**
  102546. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  102547. */
  102548. size: number;
  102549. /**
  102550. * 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.
  102551. */
  102552. position: number;
  102553. /**
  102554. * Define the lens color.
  102555. */
  102556. color: Color3;
  102557. /**
  102558. * Define the lens texture.
  102559. */
  102560. texture: Nullable<Texture>;
  102561. /**
  102562. * Define the alpha mode to render this particular lens.
  102563. */
  102564. alphaMode: number;
  102565. private _system;
  102566. /**
  102567. * Creates a new Lens Flare.
  102568. * This represents one of the lens effect in a `lensFlareSystem`.
  102569. * It controls one of the indiviual texture used in the effect.
  102570. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102571. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  102572. * @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.
  102573. * @param color Define the lens color
  102574. * @param imgUrl Define the lens texture url
  102575. * @param system Define the `lensFlareSystem` this flare is part of
  102576. * @returns The newly created Lens Flare
  102577. */
  102578. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  102579. /**
  102580. * Instantiates a new Lens Flare.
  102581. * This represents one of the lens effect in a `lensFlareSystem`.
  102582. * It controls one of the indiviual texture used in the effect.
  102583. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102584. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  102585. * @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.
  102586. * @param color Define the lens color
  102587. * @param imgUrl Define the lens texture url
  102588. * @param system Define the `lensFlareSystem` this flare is part of
  102589. */
  102590. constructor(
  102591. /**
  102592. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  102593. */
  102594. size: number,
  102595. /**
  102596. * 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.
  102597. */
  102598. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  102599. /**
  102600. * Dispose and release the lens flare with its associated resources.
  102601. */
  102602. dispose(): void;
  102603. }
  102604. }
  102605. declare module BABYLON {
  102606. interface AbstractScene {
  102607. /**
  102608. * The list of lens flare system added to the scene
  102609. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102610. */
  102611. lensFlareSystems: Array<LensFlareSystem>;
  102612. /**
  102613. * Removes the given lens flare system from this scene.
  102614. * @param toRemove The lens flare system to remove
  102615. * @returns The index of the removed lens flare system
  102616. */
  102617. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  102618. /**
  102619. * Adds the given lens flare system to this scene
  102620. * @param newLensFlareSystem The lens flare system to add
  102621. */
  102622. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  102623. /**
  102624. * Gets a lens flare system using its name
  102625. * @param name defines the name to look for
  102626. * @returns the lens flare system or null if not found
  102627. */
  102628. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  102629. /**
  102630. * Gets a lens flare system using its id
  102631. * @param id defines the id to look for
  102632. * @returns the lens flare system or null if not found
  102633. */
  102634. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  102635. }
  102636. /**
  102637. * Defines the lens flare scene component responsible to manage any lens flares
  102638. * in a given scene.
  102639. */
  102640. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  102641. /**
  102642. * The component name helpfull to identify the component in the list of scene components.
  102643. */
  102644. readonly name: string;
  102645. /**
  102646. * The scene the component belongs to.
  102647. */
  102648. scene: Scene;
  102649. /**
  102650. * Creates a new instance of the component for the given scene
  102651. * @param scene Defines the scene to register the component in
  102652. */
  102653. constructor(scene: Scene);
  102654. /**
  102655. * Registers the component in a given scene
  102656. */
  102657. register(): void;
  102658. /**
  102659. * Rebuilds the elements related to this component in case of
  102660. * context lost for instance.
  102661. */
  102662. rebuild(): void;
  102663. /**
  102664. * Adds all the element from the container to the scene
  102665. * @param container the container holding the elements
  102666. */
  102667. addFromContainer(container: AbstractScene): void;
  102668. /**
  102669. * Removes all the elements in the container from the scene
  102670. * @param container contains the elements to remove
  102671. */
  102672. removeFromContainer(container: AbstractScene): void;
  102673. /**
  102674. * Serializes the component data to the specified json object
  102675. * @param serializationObject The object to serialize to
  102676. */
  102677. serialize(serializationObject: any): void;
  102678. /**
  102679. * Disposes the component and the associated ressources.
  102680. */
  102681. dispose(): void;
  102682. private _draw;
  102683. }
  102684. }
  102685. declare module BABYLON {
  102686. /**
  102687. * Defines the shadow generator component responsible to manage any shadow generators
  102688. * in a given scene.
  102689. */
  102690. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  102691. /**
  102692. * The component name helpfull to identify the component in the list of scene components.
  102693. */
  102694. readonly name: string;
  102695. /**
  102696. * The scene the component belongs to.
  102697. */
  102698. scene: Scene;
  102699. /**
  102700. * Creates a new instance of the component for the given scene
  102701. * @param scene Defines the scene to register the component in
  102702. */
  102703. constructor(scene: Scene);
  102704. /**
  102705. * Registers the component in a given scene
  102706. */
  102707. register(): void;
  102708. /**
  102709. * Rebuilds the elements related to this component in case of
  102710. * context lost for instance.
  102711. */
  102712. rebuild(): void;
  102713. /**
  102714. * Serializes the component data to the specified json object
  102715. * @param serializationObject The object to serialize to
  102716. */
  102717. serialize(serializationObject: any): void;
  102718. /**
  102719. * Adds all the element from the container to the scene
  102720. * @param container the container holding the elements
  102721. */
  102722. addFromContainer(container: AbstractScene): void;
  102723. /**
  102724. * Removes all the elements in the container from the scene
  102725. * @param container contains the elements to remove
  102726. */
  102727. removeFromContainer(container: AbstractScene): void;
  102728. /**
  102729. * Rebuilds the elements related to this component in case of
  102730. * context lost for instance.
  102731. */
  102732. dispose(): void;
  102733. private _gatherRenderTargets;
  102734. }
  102735. }
  102736. declare module BABYLON {
  102737. /**
  102738. * A directional light is defined by a direction (what a surprise!).
  102739. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102740. * 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.
  102741. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102742. */
  102743. export class DirectionalLight extends ShadowLight {
  102744. private _shadowFrustumSize;
  102745. /**
  102746. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102747. */
  102748. /**
  102749. * Specifies a fix frustum size for the shadow generation.
  102750. */
  102751. shadowFrustumSize: number;
  102752. private _shadowOrthoScale;
  102753. /**
  102754. * Gets the shadow projection scale against the optimal computed one.
  102755. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102756. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102757. */
  102758. /**
  102759. * Sets the shadow projection scale against the optimal computed one.
  102760. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102761. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102762. */
  102763. shadowOrthoScale: number;
  102764. /**
  102765. * Automatically compute the projection matrix to best fit (including all the casters)
  102766. * on each frame.
  102767. */
  102768. autoUpdateExtends: boolean;
  102769. private _orthoLeft;
  102770. private _orthoRight;
  102771. private _orthoTop;
  102772. private _orthoBottom;
  102773. /**
  102774. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102775. * The directional light is emitted from everywhere in the given direction.
  102776. * It can cast shadows.
  102777. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102778. * @param name The friendly name of the light
  102779. * @param direction The direction of the light
  102780. * @param scene The scene the light belongs to
  102781. */
  102782. constructor(name: string, direction: Vector3, scene: Scene);
  102783. /**
  102784. * Returns the string "DirectionalLight".
  102785. * @return The class name
  102786. */
  102787. getClassName(): string;
  102788. /**
  102789. * Returns the integer 1.
  102790. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102791. */
  102792. getTypeID(): number;
  102793. /**
  102794. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102795. * Returns the DirectionalLight Shadow projection matrix.
  102796. */
  102797. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102798. /**
  102799. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102800. * Returns the DirectionalLight Shadow projection matrix.
  102801. */
  102802. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102803. /**
  102804. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102805. * Returns the DirectionalLight Shadow projection matrix.
  102806. */
  102807. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102808. protected _buildUniformLayout(): void;
  102809. /**
  102810. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102811. * @param effect The effect to update
  102812. * @param lightIndex The index of the light in the effect to update
  102813. * @returns The directional light
  102814. */
  102815. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102816. /**
  102817. * Gets the minZ used for shadow according to both the scene and the light.
  102818. *
  102819. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102820. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102821. * @param activeCamera The camera we are returning the min for
  102822. * @returns the depth min z
  102823. */
  102824. getDepthMinZ(activeCamera: Camera): number;
  102825. /**
  102826. * Gets the maxZ used for shadow according to both the scene and the light.
  102827. *
  102828. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102829. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102830. * @param activeCamera The camera we are returning the max for
  102831. * @returns the depth max z
  102832. */
  102833. getDepthMaxZ(activeCamera: Camera): number;
  102834. /**
  102835. * Prepares the list of defines specific to the light type.
  102836. * @param defines the list of defines
  102837. * @param lightIndex defines the index of the light for the effect
  102838. */
  102839. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102840. }
  102841. }
  102842. declare module BABYLON {
  102843. /**
  102844. * A point light is a light defined by an unique point in world space.
  102845. * The light is emitted in every direction from this point.
  102846. * A good example of a point light is a standard light bulb.
  102847. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102848. */
  102849. export class PointLight extends ShadowLight {
  102850. private _shadowAngle;
  102851. /**
  102852. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102853. * This specifies what angle the shadow will use to be created.
  102854. *
  102855. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  102856. */
  102857. /**
  102858. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102859. * This specifies what angle the shadow will use to be created.
  102860. *
  102861. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  102862. */
  102863. shadowAngle: number;
  102864. /**
  102865. * Gets the direction if it has been set.
  102866. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102867. */
  102868. /**
  102869. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102870. */
  102871. direction: Vector3;
  102872. /**
  102873. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  102874. * A PointLight emits the light in every direction.
  102875. * It can cast shadows.
  102876. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  102877. * ```javascript
  102878. * var pointLight = new PointLight("pl", camera.position, scene);
  102879. * ```
  102880. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102881. * @param name The light friendly name
  102882. * @param position The position of the point light in the scene
  102883. * @param scene The scene the lights belongs to
  102884. */
  102885. constructor(name: string, position: Vector3, scene: Scene);
  102886. /**
  102887. * Returns the string "PointLight"
  102888. * @returns the class name
  102889. */
  102890. getClassName(): string;
  102891. /**
  102892. * Returns the integer 0.
  102893. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102894. */
  102895. getTypeID(): number;
  102896. /**
  102897. * Specifies wether or not the shadowmap should be a cube texture.
  102898. * @returns true if the shadowmap needs to be a cube texture.
  102899. */
  102900. needCube(): boolean;
  102901. /**
  102902. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  102903. * @param faceIndex The index of the face we are computed the direction to generate shadow
  102904. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  102905. */
  102906. getShadowDirection(faceIndex?: number): Vector3;
  102907. /**
  102908. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  102909. * - fov = PI / 2
  102910. * - aspect ratio : 1.0
  102911. * - z-near and far equal to the active camera minZ and maxZ.
  102912. * Returns the PointLight.
  102913. */
  102914. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102915. protected _buildUniformLayout(): void;
  102916. /**
  102917. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  102918. * @param effect The effect to update
  102919. * @param lightIndex The index of the light in the effect to update
  102920. * @returns The point light
  102921. */
  102922. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  102923. /**
  102924. * Prepares the list of defines specific to the light type.
  102925. * @param defines the list of defines
  102926. * @param lightIndex defines the index of the light for the effect
  102927. */
  102928. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102929. }
  102930. }
  102931. declare module BABYLON {
  102932. /**
  102933. * A spot light is defined by a position, a direction, an angle, and an exponent.
  102934. * These values define a cone of light starting from the position, emitting toward the direction.
  102935. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  102936. * and the exponent defines the speed of the decay of the light with distance (reach).
  102937. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102938. */
  102939. export class SpotLight extends ShadowLight {
  102940. private _angle;
  102941. private _innerAngle;
  102942. private _cosHalfAngle;
  102943. private _lightAngleScale;
  102944. private _lightAngleOffset;
  102945. /**
  102946. * Gets the cone angle of the spot light in Radians.
  102947. */
  102948. /**
  102949. * Sets the cone angle of the spot light in Radians.
  102950. */
  102951. angle: number;
  102952. /**
  102953. * Only used in gltf falloff mode, this defines the angle where
  102954. * the directional falloff will start before cutting at angle which could be seen
  102955. * as outer angle.
  102956. */
  102957. /**
  102958. * Only used in gltf falloff mode, this defines the angle where
  102959. * the directional falloff will start before cutting at angle which could be seen
  102960. * as outer angle.
  102961. */
  102962. innerAngle: number;
  102963. private _shadowAngleScale;
  102964. /**
  102965. * Allows scaling the angle of the light for shadow generation only.
  102966. */
  102967. /**
  102968. * Allows scaling the angle of the light for shadow generation only.
  102969. */
  102970. shadowAngleScale: number;
  102971. /**
  102972. * The light decay speed with the distance from the emission spot.
  102973. */
  102974. exponent: number;
  102975. private _projectionTextureMatrix;
  102976. /**
  102977. * Allows reading the projecton texture
  102978. */
  102979. readonly projectionTextureMatrix: Matrix;
  102980. protected _projectionTextureLightNear: number;
  102981. /**
  102982. * Gets the near clip of the Spotlight for texture projection.
  102983. */
  102984. /**
  102985. * Sets the near clip of the Spotlight for texture projection.
  102986. */
  102987. projectionTextureLightNear: number;
  102988. protected _projectionTextureLightFar: number;
  102989. /**
  102990. * Gets the far clip of the Spotlight for texture projection.
  102991. */
  102992. /**
  102993. * Sets the far clip of the Spotlight for texture projection.
  102994. */
  102995. projectionTextureLightFar: number;
  102996. protected _projectionTextureUpDirection: Vector3;
  102997. /**
  102998. * Gets the Up vector of the Spotlight for texture projection.
  102999. */
  103000. /**
  103001. * Sets the Up vector of the Spotlight for texture projection.
  103002. */
  103003. projectionTextureUpDirection: Vector3;
  103004. private _projectionTexture;
  103005. /**
  103006. * Gets the projection texture of the light.
  103007. */
  103008. /**
  103009. * Sets the projection texture of the light.
  103010. */
  103011. projectionTexture: Nullable<BaseTexture>;
  103012. private _projectionTextureViewLightDirty;
  103013. private _projectionTextureProjectionLightDirty;
  103014. private _projectionTextureDirty;
  103015. private _projectionTextureViewTargetVector;
  103016. private _projectionTextureViewLightMatrix;
  103017. private _projectionTextureProjectionLightMatrix;
  103018. private _projectionTextureScalingMatrix;
  103019. /**
  103020. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  103021. * It can cast shadows.
  103022. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103023. * @param name The light friendly name
  103024. * @param position The position of the spot light in the scene
  103025. * @param direction The direction of the light in the scene
  103026. * @param angle The cone angle of the light in Radians
  103027. * @param exponent The light decay speed with the distance from the emission spot
  103028. * @param scene The scene the lights belongs to
  103029. */
  103030. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  103031. /**
  103032. * Returns the string "SpotLight".
  103033. * @returns the class name
  103034. */
  103035. getClassName(): string;
  103036. /**
  103037. * Returns the integer 2.
  103038. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103039. */
  103040. getTypeID(): number;
  103041. /**
  103042. * Overrides the direction setter to recompute the projection texture view light Matrix.
  103043. */
  103044. protected _setDirection(value: Vector3): void;
  103045. /**
  103046. * Overrides the position setter to recompute the projection texture view light Matrix.
  103047. */
  103048. protected _setPosition(value: Vector3): void;
  103049. /**
  103050. * 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.
  103051. * Returns the SpotLight.
  103052. */
  103053. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103054. protected _computeProjectionTextureViewLightMatrix(): void;
  103055. protected _computeProjectionTextureProjectionLightMatrix(): void;
  103056. /**
  103057. * Main function for light texture projection matrix computing.
  103058. */
  103059. protected _computeProjectionTextureMatrix(): void;
  103060. protected _buildUniformLayout(): void;
  103061. private _computeAngleValues;
  103062. /**
  103063. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  103064. * @param effect The effect to update
  103065. * @param lightIndex The index of the light in the effect to update
  103066. * @returns The spot light
  103067. */
  103068. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  103069. /**
  103070. * Disposes the light and the associated resources.
  103071. */
  103072. dispose(): void;
  103073. /**
  103074. * Prepares the list of defines specific to the light type.
  103075. * @param defines the list of defines
  103076. * @param lightIndex defines the index of the light for the effect
  103077. */
  103078. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103079. }
  103080. }
  103081. declare module BABYLON {
  103082. /**
  103083. * Header information of HDR texture files.
  103084. */
  103085. export interface HDRInfo {
  103086. /**
  103087. * The height of the texture in pixels.
  103088. */
  103089. height: number;
  103090. /**
  103091. * The width of the texture in pixels.
  103092. */
  103093. width: number;
  103094. /**
  103095. * The index of the beginning of the data in the binary file.
  103096. */
  103097. dataPosition: number;
  103098. }
  103099. /**
  103100. * This groups tools to convert HDR texture to native colors array.
  103101. */
  103102. export class HDRTools {
  103103. private static Ldexp;
  103104. private static Rgbe2float;
  103105. private static readStringLine;
  103106. /**
  103107. * Reads header information from an RGBE texture stored in a native array.
  103108. * More information on this format are available here:
  103109. * https://en.wikipedia.org/wiki/RGBE_image_format
  103110. *
  103111. * @param uint8array The binary file stored in native array.
  103112. * @return The header information.
  103113. */
  103114. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  103115. /**
  103116. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  103117. * This RGBE texture needs to store the information as a panorama.
  103118. *
  103119. * More information on this format are available here:
  103120. * https://en.wikipedia.org/wiki/RGBE_image_format
  103121. *
  103122. * @param buffer The binary file stored in an array buffer.
  103123. * @param size The expected size of the extracted cubemap.
  103124. * @return The Cube Map information.
  103125. */
  103126. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  103127. /**
  103128. * Returns the pixels data extracted from an RGBE texture.
  103129. * This pixels will be stored left to right up to down in the R G B order in one array.
  103130. *
  103131. * More information on this format are available here:
  103132. * https://en.wikipedia.org/wiki/RGBE_image_format
  103133. *
  103134. * @param uint8array The binary file stored in an array buffer.
  103135. * @param hdrInfo The header information of the file.
  103136. * @return The pixels data in RGB right to left up to down order.
  103137. */
  103138. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  103139. private static RGBE_ReadPixels_RLE;
  103140. }
  103141. }
  103142. declare module BABYLON {
  103143. /**
  103144. * This represents a texture coming from an HDR input.
  103145. *
  103146. * The only supported format is currently panorama picture stored in RGBE format.
  103147. * Example of such files can be found on HDRLib: http://hdrlib.com/
  103148. */
  103149. export class HDRCubeTexture extends BaseTexture {
  103150. private static _facesMapping;
  103151. private _generateHarmonics;
  103152. private _noMipmap;
  103153. private _textureMatrix;
  103154. private _size;
  103155. private _onLoad;
  103156. private _onError;
  103157. /**
  103158. * The texture URL.
  103159. */
  103160. url: string;
  103161. /**
  103162. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  103163. */
  103164. coordinatesMode: number;
  103165. protected _isBlocking: boolean;
  103166. /**
  103167. * Sets wether or not the texture is blocking during loading.
  103168. */
  103169. /**
  103170. * Gets wether or not the texture is blocking during loading.
  103171. */
  103172. isBlocking: boolean;
  103173. protected _rotationY: number;
  103174. /**
  103175. * Sets texture matrix rotation angle around Y axis in radians.
  103176. */
  103177. /**
  103178. * Gets texture matrix rotation angle around Y axis radians.
  103179. */
  103180. rotationY: number;
  103181. /**
  103182. * Gets or sets the center of the bounding box associated with the cube texture
  103183. * It must define where the camera used to render the texture was set
  103184. */
  103185. boundingBoxPosition: Vector3;
  103186. private _boundingBoxSize;
  103187. /**
  103188. * Gets or sets the size of the bounding box associated with the cube texture
  103189. * When defined, the cubemap will switch to local mode
  103190. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  103191. * @example https://www.babylonjs-playground.com/#RNASML
  103192. */
  103193. boundingBoxSize: Vector3;
  103194. /**
  103195. * Instantiates an HDRTexture from the following parameters.
  103196. *
  103197. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  103198. * @param scene The scene the texture will be used in
  103199. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  103200. * @param noMipmap Forces to not generate the mipmap if true
  103201. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  103202. * @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)
  103203. * @param reserved Reserved flag for internal use.
  103204. */
  103205. 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>);
  103206. /**
  103207. * Get the current class name of the texture useful for serialization or dynamic coding.
  103208. * @returns "HDRCubeTexture"
  103209. */
  103210. getClassName(): string;
  103211. /**
  103212. * Occurs when the file is raw .hdr file.
  103213. */
  103214. private loadTexture;
  103215. clone(): HDRCubeTexture;
  103216. delayLoad(): void;
  103217. /**
  103218. * Get the texture reflection matrix used to rotate/transform the reflection.
  103219. * @returns the reflection matrix
  103220. */
  103221. getReflectionTextureMatrix(): Matrix;
  103222. /**
  103223. * Set the texture reflection matrix used to rotate/transform the reflection.
  103224. * @param value Define the reflection matrix to set
  103225. */
  103226. setReflectionTextureMatrix(value: Matrix): void;
  103227. /**
  103228. * Parses a JSON representation of an HDR Texture in order to create the texture
  103229. * @param parsedTexture Define the JSON representation
  103230. * @param scene Define the scene the texture should be created in
  103231. * @param rootUrl Define the root url in case we need to load relative dependencies
  103232. * @returns the newly created texture after parsing
  103233. */
  103234. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  103235. serialize(): any;
  103236. }
  103237. }
  103238. declare module BABYLON {
  103239. /**
  103240. * Class used to control physics engine
  103241. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  103242. */
  103243. export class PhysicsEngine implements IPhysicsEngine {
  103244. private _physicsPlugin;
  103245. /**
  103246. * Global value used to control the smallest number supported by the simulation
  103247. */
  103248. static Epsilon: number;
  103249. private _impostors;
  103250. private _joints;
  103251. /**
  103252. * Gets the gravity vector used by the simulation
  103253. */
  103254. gravity: Vector3;
  103255. /**
  103256. * Factory used to create the default physics plugin.
  103257. * @returns The default physics plugin
  103258. */
  103259. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  103260. /**
  103261. * Creates a new Physics Engine
  103262. * @param gravity defines the gravity vector used by the simulation
  103263. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  103264. */
  103265. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  103266. /**
  103267. * Sets the gravity vector used by the simulation
  103268. * @param gravity defines the gravity vector to use
  103269. */
  103270. setGravity(gravity: Vector3): void;
  103271. /**
  103272. * Set the time step of the physics engine.
  103273. * Default is 1/60.
  103274. * To slow it down, enter 1/600 for example.
  103275. * To speed it up, 1/30
  103276. * @param newTimeStep defines the new timestep to apply to this world.
  103277. */
  103278. setTimeStep(newTimeStep?: number): void;
  103279. /**
  103280. * Get the time step of the physics engine.
  103281. * @returns the current time step
  103282. */
  103283. getTimeStep(): number;
  103284. /**
  103285. * Release all resources
  103286. */
  103287. dispose(): void;
  103288. /**
  103289. * Gets the name of the current physics plugin
  103290. * @returns the name of the plugin
  103291. */
  103292. getPhysicsPluginName(): string;
  103293. /**
  103294. * Adding a new impostor for the impostor tracking.
  103295. * This will be done by the impostor itself.
  103296. * @param impostor the impostor to add
  103297. */
  103298. addImpostor(impostor: PhysicsImpostor): void;
  103299. /**
  103300. * Remove an impostor from the engine.
  103301. * This impostor and its mesh will not longer be updated by the physics engine.
  103302. * @param impostor the impostor to remove
  103303. */
  103304. removeImpostor(impostor: PhysicsImpostor): void;
  103305. /**
  103306. * Add a joint to the physics engine
  103307. * @param mainImpostor defines the main impostor to which the joint is added.
  103308. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  103309. * @param joint defines the joint that will connect both impostors.
  103310. */
  103311. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103312. /**
  103313. * Removes a joint from the simulation
  103314. * @param mainImpostor defines the impostor used with the joint
  103315. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  103316. * @param joint defines the joint to remove
  103317. */
  103318. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103319. /**
  103320. * Called by the scene. No need to call it.
  103321. * @param delta defines the timespam between frames
  103322. */
  103323. _step(delta: number): void;
  103324. /**
  103325. * Gets the current plugin used to run the simulation
  103326. * @returns current plugin
  103327. */
  103328. getPhysicsPlugin(): IPhysicsEnginePlugin;
  103329. /**
  103330. * Gets the list of physic impostors
  103331. * @returns an array of PhysicsImpostor
  103332. */
  103333. getImpostors(): Array<PhysicsImpostor>;
  103334. /**
  103335. * Gets the impostor for a physics enabled object
  103336. * @param object defines the object impersonated by the impostor
  103337. * @returns the PhysicsImpostor or null if not found
  103338. */
  103339. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  103340. /**
  103341. * Gets the impostor for a physics body object
  103342. * @param body defines physics body used by the impostor
  103343. * @returns the PhysicsImpostor or null if not found
  103344. */
  103345. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  103346. }
  103347. }
  103348. declare module BABYLON {
  103349. /** @hidden */
  103350. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  103351. private _useDeltaForWorldStep;
  103352. world: any;
  103353. name: string;
  103354. private _physicsMaterials;
  103355. private _fixedTimeStep;
  103356. BJSCANNON: any;
  103357. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  103358. setGravity(gravity: Vector3): void;
  103359. setTimeStep(timeStep: number): void;
  103360. getTimeStep(): number;
  103361. executeStep(delta: number): void;
  103362. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103363. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103364. generatePhysicsBody(impostor: PhysicsImpostor): void;
  103365. private _processChildMeshes;
  103366. removePhysicsBody(impostor: PhysicsImpostor): void;
  103367. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  103368. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  103369. private _addMaterial;
  103370. private _checkWithEpsilon;
  103371. private _createShape;
  103372. private _createHeightmap;
  103373. private _minus90X;
  103374. private _plus90X;
  103375. private _tmpPosition;
  103376. private _tmpDeltaPosition;
  103377. private _tmpUnityRotation;
  103378. private _updatePhysicsBodyTransformation;
  103379. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  103380. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  103381. isSupported(): boolean;
  103382. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103383. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103384. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103385. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103386. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  103387. getBodyMass(impostor: PhysicsImpostor): number;
  103388. getBodyFriction(impostor: PhysicsImpostor): number;
  103389. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  103390. getBodyRestitution(impostor: PhysicsImpostor): number;
  103391. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  103392. sleepBody(impostor: PhysicsImpostor): void;
  103393. wakeUpBody(impostor: PhysicsImpostor): void;
  103394. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  103395. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  103396. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  103397. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  103398. getRadius(impostor: PhysicsImpostor): number;
  103399. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  103400. dispose(): void;
  103401. private _extendNamespace;
  103402. }
  103403. }
  103404. declare module BABYLON {
  103405. /** @hidden */
  103406. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  103407. world: any;
  103408. name: string;
  103409. BJSOIMO: any;
  103410. constructor(iterations?: number, oimoInjection?: any);
  103411. setGravity(gravity: Vector3): void;
  103412. setTimeStep(timeStep: number): void;
  103413. getTimeStep(): number;
  103414. private _tmpImpostorsArray;
  103415. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  103416. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103417. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103418. generatePhysicsBody(impostor: PhysicsImpostor): void;
  103419. private _tmpPositionVector;
  103420. removePhysicsBody(impostor: PhysicsImpostor): void;
  103421. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  103422. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  103423. isSupported(): boolean;
  103424. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  103425. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  103426. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103427. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103428. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103429. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103430. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  103431. getBodyMass(impostor: PhysicsImpostor): number;
  103432. getBodyFriction(impostor: PhysicsImpostor): number;
  103433. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  103434. getBodyRestitution(impostor: PhysicsImpostor): number;
  103435. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  103436. sleepBody(impostor: PhysicsImpostor): void;
  103437. wakeUpBody(impostor: PhysicsImpostor): void;
  103438. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  103439. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  103440. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103441. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  103442. getRadius(impostor: PhysicsImpostor): number;
  103443. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  103444. dispose(): void;
  103445. }
  103446. }
  103447. declare module BABYLON {
  103448. interface AbstractScene {
  103449. /**
  103450. * The list of reflection probes added to the scene
  103451. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  103452. */
  103453. reflectionProbes: Array<ReflectionProbe>;
  103454. /**
  103455. * Removes the given reflection probe from this scene.
  103456. * @param toRemove The reflection probe to remove
  103457. * @returns The index of the removed reflection probe
  103458. */
  103459. removeReflectionProbe(toRemove: ReflectionProbe): number;
  103460. /**
  103461. * Adds the given reflection probe to this scene.
  103462. * @param newReflectionProbe The reflection probe to add
  103463. */
  103464. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  103465. }
  103466. /**
  103467. * Class used to generate realtime reflection / refraction cube textures
  103468. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  103469. */
  103470. export class ReflectionProbe {
  103471. /** defines the name of the probe */
  103472. name: string;
  103473. private _scene;
  103474. private _renderTargetTexture;
  103475. private _projectionMatrix;
  103476. private _viewMatrix;
  103477. private _target;
  103478. private _add;
  103479. private _attachedMesh;
  103480. private _invertYAxis;
  103481. /** Gets or sets probe position (center of the cube map) */
  103482. position: Vector3;
  103483. /**
  103484. * Creates a new reflection probe
  103485. * @param name defines the name of the probe
  103486. * @param size defines the texture resolution (for each face)
  103487. * @param scene defines the hosting scene
  103488. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  103489. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  103490. */
  103491. constructor(
  103492. /** defines the name of the probe */
  103493. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  103494. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  103495. samples: number;
  103496. /** Gets or sets the refresh rate to use (on every frame by default) */
  103497. refreshRate: number;
  103498. /**
  103499. * Gets the hosting scene
  103500. * @returns a Scene
  103501. */
  103502. getScene(): Scene;
  103503. /** Gets the internal CubeTexture used to render to */
  103504. readonly cubeTexture: RenderTargetTexture;
  103505. /** Gets the list of meshes to render */
  103506. readonly renderList: Nullable<AbstractMesh[]>;
  103507. /**
  103508. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  103509. * @param mesh defines the mesh to attach to
  103510. */
  103511. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  103512. /**
  103513. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  103514. * @param renderingGroupId The rendering group id corresponding to its index
  103515. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103516. */
  103517. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  103518. /**
  103519. * Clean all associated resources
  103520. */
  103521. dispose(): void;
  103522. /**
  103523. * Converts the reflection probe information to a readable string for debug purpose.
  103524. * @param fullDetails Supports for multiple levels of logging within scene loading
  103525. * @returns the human readable reflection probe info
  103526. */
  103527. toString(fullDetails?: boolean): string;
  103528. /**
  103529. * Get the class name of the relfection probe.
  103530. * @returns "ReflectionProbe"
  103531. */
  103532. getClassName(): string;
  103533. /**
  103534. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  103535. * @returns The JSON representation of the texture
  103536. */
  103537. serialize(): any;
  103538. /**
  103539. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  103540. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  103541. * @param scene Define the scene the parsed reflection probe should be instantiated in
  103542. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  103543. * @returns The parsed reflection probe if successful
  103544. */
  103545. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  103546. }
  103547. }
  103548. declare module BABYLON {
  103549. /** @hidden */
  103550. export var _BabylonLoaderRegistered: boolean;
  103551. }
  103552. declare module BABYLON {
  103553. /**
  103554. * The Physically based simple base material of BJS.
  103555. *
  103556. * This enables better naming and convention enforcements on top of the pbrMaterial.
  103557. * It is used as the base class for both the specGloss and metalRough conventions.
  103558. */
  103559. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  103560. /**
  103561. * Number of Simultaneous lights allowed on the material.
  103562. */
  103563. maxSimultaneousLights: number;
  103564. /**
  103565. * If sets to true, disables all the lights affecting the material.
  103566. */
  103567. disableLighting: boolean;
  103568. /**
  103569. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  103570. */
  103571. environmentTexture: BaseTexture;
  103572. /**
  103573. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103574. */
  103575. invertNormalMapX: boolean;
  103576. /**
  103577. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103578. */
  103579. invertNormalMapY: boolean;
  103580. /**
  103581. * Normal map used in the model.
  103582. */
  103583. normalTexture: BaseTexture;
  103584. /**
  103585. * Emissivie color used to self-illuminate the model.
  103586. */
  103587. emissiveColor: Color3;
  103588. /**
  103589. * Emissivie texture used to self-illuminate the model.
  103590. */
  103591. emissiveTexture: BaseTexture;
  103592. /**
  103593. * Occlusion Channel Strenght.
  103594. */
  103595. occlusionStrength: number;
  103596. /**
  103597. * Occlusion Texture of the material (adding extra occlusion effects).
  103598. */
  103599. occlusionTexture: BaseTexture;
  103600. /**
  103601. * Defines the alpha limits in alpha test mode.
  103602. */
  103603. alphaCutOff: number;
  103604. /**
  103605. * Gets the current double sided mode.
  103606. */
  103607. /**
  103608. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103609. */
  103610. doubleSided: boolean;
  103611. /**
  103612. * Stores the pre-calculated light information of a mesh in a texture.
  103613. */
  103614. lightmapTexture: BaseTexture;
  103615. /**
  103616. * If true, the light map contains occlusion information instead of lighting info.
  103617. */
  103618. useLightmapAsShadowmap: boolean;
  103619. /**
  103620. * Instantiates a new PBRMaterial instance.
  103621. *
  103622. * @param name The material name
  103623. * @param scene The scene the material will be use in.
  103624. */
  103625. constructor(name: string, scene: Scene);
  103626. getClassName(): string;
  103627. }
  103628. }
  103629. declare module BABYLON {
  103630. /**
  103631. * The PBR material of BJS following the metal roughness convention.
  103632. *
  103633. * This fits to the PBR convention in the GLTF definition:
  103634. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  103635. */
  103636. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  103637. /**
  103638. * The base color has two different interpretations depending on the value of metalness.
  103639. * When the material is a metal, the base color is the specific measured reflectance value
  103640. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  103641. * of the material.
  103642. */
  103643. baseColor: Color3;
  103644. /**
  103645. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  103646. * well as opacity information in the alpha channel.
  103647. */
  103648. baseTexture: BaseTexture;
  103649. /**
  103650. * Specifies the metallic scalar value of the material.
  103651. * Can also be used to scale the metalness values of the metallic texture.
  103652. */
  103653. metallic: number;
  103654. /**
  103655. * Specifies the roughness scalar value of the material.
  103656. * Can also be used to scale the roughness values of the metallic texture.
  103657. */
  103658. roughness: number;
  103659. /**
  103660. * Texture containing both the metallic value in the B channel and the
  103661. * roughness value in the G channel to keep better precision.
  103662. */
  103663. metallicRoughnessTexture: BaseTexture;
  103664. /**
  103665. * Instantiates a new PBRMetalRoughnessMaterial instance.
  103666. *
  103667. * @param name The material name
  103668. * @param scene The scene the material will be use in.
  103669. */
  103670. constructor(name: string, scene: Scene);
  103671. /**
  103672. * Return the currrent class name of the material.
  103673. */
  103674. getClassName(): string;
  103675. /**
  103676. * Makes a duplicate of the current material.
  103677. * @param name - name to use for the new material.
  103678. */
  103679. clone(name: string): PBRMetallicRoughnessMaterial;
  103680. /**
  103681. * Serialize the material to a parsable JSON object.
  103682. */
  103683. serialize(): any;
  103684. /**
  103685. * Parses a JSON object correponding to the serialize function.
  103686. */
  103687. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  103688. }
  103689. }
  103690. declare module BABYLON {
  103691. /**
  103692. * The PBR material of BJS following the specular glossiness convention.
  103693. *
  103694. * This fits to the PBR convention in the GLTF definition:
  103695. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  103696. */
  103697. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  103698. /**
  103699. * Specifies the diffuse color of the material.
  103700. */
  103701. diffuseColor: Color3;
  103702. /**
  103703. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  103704. * channel.
  103705. */
  103706. diffuseTexture: BaseTexture;
  103707. /**
  103708. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  103709. */
  103710. specularColor: Color3;
  103711. /**
  103712. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  103713. */
  103714. glossiness: number;
  103715. /**
  103716. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  103717. */
  103718. specularGlossinessTexture: BaseTexture;
  103719. /**
  103720. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  103721. *
  103722. * @param name The material name
  103723. * @param scene The scene the material will be use in.
  103724. */
  103725. constructor(name: string, scene: Scene);
  103726. /**
  103727. * Return the currrent class name of the material.
  103728. */
  103729. getClassName(): string;
  103730. /**
  103731. * Makes a duplicate of the current material.
  103732. * @param name - name to use for the new material.
  103733. */
  103734. clone(name: string): PBRSpecularGlossinessMaterial;
  103735. /**
  103736. * Serialize the material to a parsable JSON object.
  103737. */
  103738. serialize(): any;
  103739. /**
  103740. * Parses a JSON object correponding to the serialize function.
  103741. */
  103742. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  103743. }
  103744. }
  103745. declare module BABYLON {
  103746. /**
  103747. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  103748. * It can help converting any input color in a desired output one. This can then be used to create effects
  103749. * from sepia, black and white to sixties or futuristic rendering...
  103750. *
  103751. * The only supported format is currently 3dl.
  103752. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  103753. */
  103754. export class ColorGradingTexture extends BaseTexture {
  103755. /**
  103756. * The current texture matrix. (will always be identity in color grading texture)
  103757. */
  103758. private _textureMatrix;
  103759. /**
  103760. * The texture URL.
  103761. */
  103762. url: string;
  103763. /**
  103764. * Empty line regex stored for GC.
  103765. */
  103766. private static _noneEmptyLineRegex;
  103767. private _engine;
  103768. /**
  103769. * Instantiates a ColorGradingTexture from the following parameters.
  103770. *
  103771. * @param url The location of the color gradind data (currently only supporting 3dl)
  103772. * @param scene The scene the texture will be used in
  103773. */
  103774. constructor(url: string, scene: Scene);
  103775. /**
  103776. * Returns the texture matrix used in most of the material.
  103777. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  103778. */
  103779. getTextureMatrix(): Matrix;
  103780. /**
  103781. * Occurs when the file being loaded is a .3dl LUT file.
  103782. */
  103783. private load3dlTexture;
  103784. /**
  103785. * Starts the loading process of the texture.
  103786. */
  103787. private loadTexture;
  103788. /**
  103789. * Clones the color gradind texture.
  103790. */
  103791. clone(): ColorGradingTexture;
  103792. /**
  103793. * Called during delayed load for textures.
  103794. */
  103795. delayLoad(): void;
  103796. /**
  103797. * Parses a color grading texture serialized by Babylon.
  103798. * @param parsedTexture The texture information being parsedTexture
  103799. * @param scene The scene to load the texture in
  103800. * @param rootUrl The root url of the data assets to load
  103801. * @return A color gradind texture
  103802. */
  103803. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  103804. /**
  103805. * Serializes the LUT texture to json format.
  103806. */
  103807. serialize(): any;
  103808. }
  103809. }
  103810. declare module BABYLON {
  103811. /**
  103812. * Direct draw surface info
  103813. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  103814. */
  103815. export interface DDSInfo {
  103816. /**
  103817. * Width of the texture
  103818. */
  103819. width: number;
  103820. /**
  103821. * Width of the texture
  103822. */
  103823. height: number;
  103824. /**
  103825. * Number of Mipmaps for the texture
  103826. * @see https://en.wikipedia.org/wiki/Mipmap
  103827. */
  103828. mipmapCount: number;
  103829. /**
  103830. * If the textures format is a known fourCC format
  103831. * @see https://www.fourcc.org/
  103832. */
  103833. isFourCC: boolean;
  103834. /**
  103835. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  103836. */
  103837. isRGB: boolean;
  103838. /**
  103839. * If the texture is a lumincance format
  103840. */
  103841. isLuminance: boolean;
  103842. /**
  103843. * If this is a cube texture
  103844. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  103845. */
  103846. isCube: boolean;
  103847. /**
  103848. * If the texture is a compressed format eg. FOURCC_DXT1
  103849. */
  103850. isCompressed: boolean;
  103851. /**
  103852. * The dxgiFormat of the texture
  103853. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  103854. */
  103855. dxgiFormat: number;
  103856. /**
  103857. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  103858. */
  103859. textureType: number;
  103860. /**
  103861. * Sphericle polynomial created for the dds texture
  103862. */
  103863. sphericalPolynomial?: SphericalPolynomial;
  103864. }
  103865. /**
  103866. * Class used to provide DDS decompression tools
  103867. */
  103868. export class DDSTools {
  103869. /**
  103870. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  103871. */
  103872. static StoreLODInAlphaChannel: boolean;
  103873. /**
  103874. * Gets DDS information from an array buffer
  103875. * @param arrayBuffer defines the array buffer to read data from
  103876. * @returns the DDS information
  103877. */
  103878. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  103879. private static _FloatView;
  103880. private static _Int32View;
  103881. private static _ToHalfFloat;
  103882. private static _FromHalfFloat;
  103883. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  103884. private static _GetHalfFloatRGBAArrayBuffer;
  103885. private static _GetFloatRGBAArrayBuffer;
  103886. private static _GetFloatAsUIntRGBAArrayBuffer;
  103887. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  103888. private static _GetRGBAArrayBuffer;
  103889. private static _ExtractLongWordOrder;
  103890. private static _GetRGBArrayBuffer;
  103891. private static _GetLuminanceArrayBuffer;
  103892. /**
  103893. * Uploads DDS Levels to a Babylon Texture
  103894. * @hidden
  103895. */
  103896. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  103897. }
  103898. interface Engine {
  103899. /**
  103900. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  103901. * @param rootUrl defines the url where the file to load is located
  103902. * @param scene defines the current scene
  103903. * @param lodScale defines scale to apply to the mip map selection
  103904. * @param lodOffset defines offset to apply to the mip map selection
  103905. * @param onLoad defines an optional callback raised when the texture is loaded
  103906. * @param onError defines an optional callback raised if there is an issue to load the texture
  103907. * @param format defines the format of the data
  103908. * @param forcedExtension defines the extension to use to pick the right loader
  103909. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  103910. * @returns the cube texture as an InternalTexture
  103911. */
  103912. 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;
  103913. }
  103914. }
  103915. declare module BABYLON {
  103916. /**
  103917. * Implementation of the DDS Texture Loader.
  103918. * @hidden
  103919. */
  103920. export class _DDSTextureLoader implements IInternalTextureLoader {
  103921. /**
  103922. * Defines wether the loader supports cascade loading the different faces.
  103923. */
  103924. readonly supportCascades: boolean;
  103925. /**
  103926. * This returns if the loader support the current file information.
  103927. * @param extension defines the file extension of the file being loaded
  103928. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103929. * @param fallback defines the fallback internal texture if any
  103930. * @param isBase64 defines whether the texture is encoded as a base64
  103931. * @param isBuffer defines whether the texture data are stored as a buffer
  103932. * @returns true if the loader can load the specified file
  103933. */
  103934. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103935. /**
  103936. * Transform the url before loading if required.
  103937. * @param rootUrl the url of the texture
  103938. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103939. * @returns the transformed texture
  103940. */
  103941. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103942. /**
  103943. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103944. * @param rootUrl the url of the texture
  103945. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103946. * @returns the fallback texture
  103947. */
  103948. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103949. /**
  103950. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103951. * @param data contains the texture data
  103952. * @param texture defines the BabylonJS internal texture
  103953. * @param createPolynomials will be true if polynomials have been requested
  103954. * @param onLoad defines the callback to trigger once the texture is ready
  103955. * @param onError defines the callback to trigger in case of error
  103956. */
  103957. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103958. /**
  103959. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103960. * @param data contains the texture data
  103961. * @param texture defines the BabylonJS internal texture
  103962. * @param callback defines the method to call once ready to upload
  103963. */
  103964. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103965. }
  103966. }
  103967. declare module BABYLON {
  103968. /** @hidden */
  103969. export var rgbdEncodePixelShader: {
  103970. name: string;
  103971. shader: string;
  103972. };
  103973. }
  103974. declare module BABYLON {
  103975. /** @hidden */
  103976. export var rgbdDecodePixelShader: {
  103977. name: string;
  103978. shader: string;
  103979. };
  103980. }
  103981. declare module BABYLON {
  103982. /**
  103983. * Raw texture data and descriptor sufficient for WebGL texture upload
  103984. */
  103985. export interface EnvironmentTextureInfo {
  103986. /**
  103987. * Version of the environment map
  103988. */
  103989. version: number;
  103990. /**
  103991. * Width of image
  103992. */
  103993. width: number;
  103994. /**
  103995. * Irradiance information stored in the file.
  103996. */
  103997. irradiance: any;
  103998. /**
  103999. * Specular information stored in the file.
  104000. */
  104001. specular: any;
  104002. }
  104003. /**
  104004. * Sets of helpers addressing the serialization and deserialization of environment texture
  104005. * stored in a BabylonJS env file.
  104006. * Those files are usually stored as .env files.
  104007. */
  104008. export class EnvironmentTextureTools {
  104009. /**
  104010. * Magic number identifying the env file.
  104011. */
  104012. private static _MagicBytes;
  104013. /**
  104014. * Gets the environment info from an env file.
  104015. * @param data The array buffer containing the .env bytes.
  104016. * @returns the environment file info (the json header) if successfully parsed.
  104017. */
  104018. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  104019. /**
  104020. * Creates an environment texture from a loaded cube texture.
  104021. * @param texture defines the cube texture to convert in env file
  104022. * @return a promise containing the environment data if succesfull.
  104023. */
  104024. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  104025. /**
  104026. * Creates a JSON representation of the spherical data.
  104027. * @param texture defines the texture containing the polynomials
  104028. * @return the JSON representation of the spherical info
  104029. */
  104030. private static _CreateEnvTextureIrradiance;
  104031. /**
  104032. * Uploads the texture info contained in the env file to the GPU.
  104033. * @param texture defines the internal texture to upload to
  104034. * @param arrayBuffer defines the buffer cotaining the data to load
  104035. * @param info defines the texture info retrieved through the GetEnvInfo method
  104036. * @returns a promise
  104037. */
  104038. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  104039. /**
  104040. * Uploads the levels of image data to the GPU.
  104041. * @param texture defines the internal texture to upload to
  104042. * @param imageData defines the array buffer views of image data [mipmap][face]
  104043. * @returns a promise
  104044. */
  104045. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  104046. /**
  104047. * Uploads spherical polynomials information to the texture.
  104048. * @param texture defines the texture we are trying to upload the information to
  104049. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  104050. */
  104051. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  104052. /** @hidden */
  104053. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  104054. }
  104055. }
  104056. declare module BABYLON {
  104057. /**
  104058. * Implementation of the ENV Texture Loader.
  104059. * @hidden
  104060. */
  104061. export class _ENVTextureLoader implements IInternalTextureLoader {
  104062. /**
  104063. * Defines wether the loader supports cascade loading the different faces.
  104064. */
  104065. readonly supportCascades: boolean;
  104066. /**
  104067. * This returns if the loader support the current file information.
  104068. * @param extension defines the file extension of the file being loaded
  104069. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104070. * @param fallback defines the fallback internal texture if any
  104071. * @param isBase64 defines whether the texture is encoded as a base64
  104072. * @param isBuffer defines whether the texture data are stored as a buffer
  104073. * @returns true if the loader can load the specified file
  104074. */
  104075. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104076. /**
  104077. * Transform the url before loading if required.
  104078. * @param rootUrl the url of the texture
  104079. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104080. * @returns the transformed texture
  104081. */
  104082. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104083. /**
  104084. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104085. * @param rootUrl the url of the texture
  104086. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104087. * @returns the fallback texture
  104088. */
  104089. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104090. /**
  104091. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104092. * @param data contains the texture data
  104093. * @param texture defines the BabylonJS internal texture
  104094. * @param createPolynomials will be true if polynomials have been requested
  104095. * @param onLoad defines the callback to trigger once the texture is ready
  104096. * @param onError defines the callback to trigger in case of error
  104097. */
  104098. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104099. /**
  104100. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104101. * @param data contains the texture data
  104102. * @param texture defines the BabylonJS internal texture
  104103. * @param callback defines the method to call once ready to upload
  104104. */
  104105. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104106. }
  104107. }
  104108. declare module BABYLON {
  104109. /**
  104110. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  104111. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  104112. */
  104113. export class KhronosTextureContainer {
  104114. /** contents of the KTX container file */
  104115. arrayBuffer: any;
  104116. private static HEADER_LEN;
  104117. private static COMPRESSED_2D;
  104118. private static COMPRESSED_3D;
  104119. private static TEX_2D;
  104120. private static TEX_3D;
  104121. /**
  104122. * Gets the openGL type
  104123. */
  104124. glType: number;
  104125. /**
  104126. * Gets the openGL type size
  104127. */
  104128. glTypeSize: number;
  104129. /**
  104130. * Gets the openGL format
  104131. */
  104132. glFormat: number;
  104133. /**
  104134. * Gets the openGL internal format
  104135. */
  104136. glInternalFormat: number;
  104137. /**
  104138. * Gets the base internal format
  104139. */
  104140. glBaseInternalFormat: number;
  104141. /**
  104142. * Gets image width in pixel
  104143. */
  104144. pixelWidth: number;
  104145. /**
  104146. * Gets image height in pixel
  104147. */
  104148. pixelHeight: number;
  104149. /**
  104150. * Gets image depth in pixels
  104151. */
  104152. pixelDepth: number;
  104153. /**
  104154. * Gets the number of array elements
  104155. */
  104156. numberOfArrayElements: number;
  104157. /**
  104158. * Gets the number of faces
  104159. */
  104160. numberOfFaces: number;
  104161. /**
  104162. * Gets the number of mipmap levels
  104163. */
  104164. numberOfMipmapLevels: number;
  104165. /**
  104166. * Gets the bytes of key value data
  104167. */
  104168. bytesOfKeyValueData: number;
  104169. /**
  104170. * Gets the load type
  104171. */
  104172. loadType: number;
  104173. /**
  104174. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  104175. */
  104176. isInvalid: boolean;
  104177. /**
  104178. * Creates a new KhronosTextureContainer
  104179. * @param arrayBuffer contents of the KTX container file
  104180. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  104181. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  104182. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  104183. */
  104184. constructor(
  104185. /** contents of the KTX container file */
  104186. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  104187. /**
  104188. * Uploads KTX content to a Babylon Texture.
  104189. * It is assumed that the texture has already been created & is currently bound
  104190. * @hidden
  104191. */
  104192. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  104193. private _upload2DCompressedLevels;
  104194. }
  104195. }
  104196. declare module BABYLON {
  104197. /**
  104198. * Implementation of the KTX Texture Loader.
  104199. * @hidden
  104200. */
  104201. export class _KTXTextureLoader implements IInternalTextureLoader {
  104202. /**
  104203. * Defines wether the loader supports cascade loading the different faces.
  104204. */
  104205. readonly supportCascades: boolean;
  104206. /**
  104207. * This returns if the loader support the current file information.
  104208. * @param extension defines the file extension of the file being loaded
  104209. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104210. * @param fallback defines the fallback internal texture if any
  104211. * @param isBase64 defines whether the texture is encoded as a base64
  104212. * @param isBuffer defines whether the texture data are stored as a buffer
  104213. * @returns true if the loader can load the specified file
  104214. */
  104215. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104216. /**
  104217. * Transform the url before loading if required.
  104218. * @param rootUrl the url of the texture
  104219. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104220. * @returns the transformed texture
  104221. */
  104222. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104223. /**
  104224. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104225. * @param rootUrl the url of the texture
  104226. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104227. * @returns the fallback texture
  104228. */
  104229. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104230. /**
  104231. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104232. * @param data contains the texture data
  104233. * @param texture defines the BabylonJS internal texture
  104234. * @param createPolynomials will be true if polynomials have been requested
  104235. * @param onLoad defines the callback to trigger once the texture is ready
  104236. * @param onError defines the callback to trigger in case of error
  104237. */
  104238. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104239. /**
  104240. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104241. * @param data contains the texture data
  104242. * @param texture defines the BabylonJS internal texture
  104243. * @param callback defines the method to call once ready to upload
  104244. */
  104245. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  104246. }
  104247. }
  104248. declare module BABYLON {
  104249. /**
  104250. * Based on jsTGALoader - Javascript loader for TGA file
  104251. * By Vincent Thibault
  104252. * @see http://blog.robrowser.com/javascript-tga-loader.html
  104253. */
  104254. export class TGATools {
  104255. private static _TYPE_INDEXED;
  104256. private static _TYPE_RGB;
  104257. private static _TYPE_GREY;
  104258. private static _TYPE_RLE_INDEXED;
  104259. private static _TYPE_RLE_RGB;
  104260. private static _TYPE_RLE_GREY;
  104261. private static _ORIGIN_MASK;
  104262. private static _ORIGIN_SHIFT;
  104263. private static _ORIGIN_BL;
  104264. private static _ORIGIN_BR;
  104265. private static _ORIGIN_UL;
  104266. private static _ORIGIN_UR;
  104267. /**
  104268. * Gets the header of a TGA file
  104269. * @param data defines the TGA data
  104270. * @returns the header
  104271. */
  104272. static GetTGAHeader(data: Uint8Array): any;
  104273. /**
  104274. * Uploads TGA content to a Babylon Texture
  104275. * @hidden
  104276. */
  104277. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  104278. /** @hidden */
  104279. 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;
  104280. /** @hidden */
  104281. 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;
  104282. /** @hidden */
  104283. 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;
  104284. /** @hidden */
  104285. 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;
  104286. /** @hidden */
  104287. 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;
  104288. /** @hidden */
  104289. 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;
  104290. }
  104291. }
  104292. declare module BABYLON {
  104293. /**
  104294. * Implementation of the TGA Texture Loader.
  104295. * @hidden
  104296. */
  104297. export class _TGATextureLoader implements IInternalTextureLoader {
  104298. /**
  104299. * Defines wether the loader supports cascade loading the different faces.
  104300. */
  104301. readonly supportCascades: boolean;
  104302. /**
  104303. * This returns if the loader support the current file information.
  104304. * @param extension defines the file extension of the file being loaded
  104305. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104306. * @param fallback defines the fallback internal texture if any
  104307. * @param isBase64 defines whether the texture is encoded as a base64
  104308. * @param isBuffer defines whether the texture data are stored as a buffer
  104309. * @returns true if the loader can load the specified file
  104310. */
  104311. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104312. /**
  104313. * Transform the url before loading if required.
  104314. * @param rootUrl the url of the texture
  104315. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104316. * @returns the transformed texture
  104317. */
  104318. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104319. /**
  104320. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104321. * @param rootUrl the url of the texture
  104322. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104323. * @returns the fallback texture
  104324. */
  104325. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104326. /**
  104327. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104328. * @param data contains the texture data
  104329. * @param texture defines the BabylonJS internal texture
  104330. * @param createPolynomials will be true if polynomials have been requested
  104331. * @param onLoad defines the callback to trigger once the texture is ready
  104332. * @param onError defines the callback to trigger in case of error
  104333. */
  104334. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104335. /**
  104336. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104337. * @param data contains the texture data
  104338. * @param texture defines the BabylonJS internal texture
  104339. * @param callback defines the method to call once ready to upload
  104340. */
  104341. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104342. }
  104343. }
  104344. declare module BABYLON {
  104345. /**
  104346. * 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.
  104347. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104348. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104349. */
  104350. export class CustomProceduralTexture extends ProceduralTexture {
  104351. private _animate;
  104352. private _time;
  104353. private _config;
  104354. private _texturePath;
  104355. /**
  104356. * Instantiates a new Custom Procedural Texture.
  104357. * 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.
  104358. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104359. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104360. * @param name Define the name of the texture
  104361. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  104362. * @param size Define the size of the texture to create
  104363. * @param scene Define the scene the texture belongs to
  104364. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  104365. * @param generateMipMaps Define if the texture should creates mip maps or not
  104366. */
  104367. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104368. private _loadJson;
  104369. /**
  104370. * Is the texture ready to be used ? (rendered at least once)
  104371. * @returns true if ready, otherwise, false.
  104372. */
  104373. isReady(): boolean;
  104374. /**
  104375. * Render the texture to its associated render target.
  104376. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  104377. */
  104378. render(useCameraPostProcess?: boolean): void;
  104379. /**
  104380. * Update the list of dependant textures samplers in the shader.
  104381. */
  104382. updateTextures(): void;
  104383. /**
  104384. * Update the uniform values of the procedural texture in the shader.
  104385. */
  104386. updateShaderUniforms(): void;
  104387. /**
  104388. * Define if the texture animates or not.
  104389. */
  104390. animate: boolean;
  104391. }
  104392. }
  104393. declare module BABYLON {
  104394. /** @hidden */
  104395. export var noisePixelShader: {
  104396. name: string;
  104397. shader: string;
  104398. };
  104399. }
  104400. declare module BABYLON {
  104401. /**
  104402. * Class used to generate noise procedural textures
  104403. */
  104404. export class NoiseProceduralTexture extends ProceduralTexture {
  104405. private _time;
  104406. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  104407. brightness: number;
  104408. /** Defines the number of octaves to process */
  104409. octaves: number;
  104410. /** Defines the level of persistence (0.8 by default) */
  104411. persistence: number;
  104412. /** Gets or sets animation speed factor (default is 1) */
  104413. animationSpeedFactor: number;
  104414. /**
  104415. * Creates a new NoiseProceduralTexture
  104416. * @param name defines the name fo the texture
  104417. * @param size defines the size of the texture (default is 256)
  104418. * @param scene defines the hosting scene
  104419. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  104420. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  104421. */
  104422. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104423. private _updateShaderUniforms;
  104424. protected _getDefines(): string;
  104425. /** Generate the current state of the procedural texture */
  104426. render(useCameraPostProcess?: boolean): void;
  104427. /**
  104428. * Serializes this noise procedural texture
  104429. * @returns a serialized noise procedural texture object
  104430. */
  104431. serialize(): any;
  104432. /**
  104433. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  104434. * @param parsedTexture defines parsed texture data
  104435. * @param scene defines the current scene
  104436. * @param rootUrl defines the root URL containing noise procedural texture information
  104437. * @returns a parsed NoiseProceduralTexture
  104438. */
  104439. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  104440. }
  104441. }
  104442. declare module BABYLON {
  104443. /**
  104444. * Raw cube texture where the raw buffers are passed in
  104445. */
  104446. export class RawCubeTexture extends CubeTexture {
  104447. /**
  104448. * Creates a cube texture where the raw buffers are passed in.
  104449. * @param scene defines the scene the texture is attached to
  104450. * @param data defines the array of data to use to create each face
  104451. * @param size defines the size of the textures
  104452. * @param format defines the format of the data
  104453. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  104454. * @param generateMipMaps defines if the engine should generate the mip levels
  104455. * @param invertY defines if data must be stored with Y axis inverted
  104456. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104457. * @param compression defines the compression used (null by default)
  104458. */
  104459. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  104460. /**
  104461. * Updates the raw cube texture.
  104462. * @param data defines the data to store
  104463. * @param format defines the data format
  104464. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  104465. * @param invertY defines if data must be stored with Y axis inverted
  104466. * @param compression defines the compression used (null by default)
  104467. * @param level defines which level of the texture to update
  104468. */
  104469. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  104470. /**
  104471. * Updates a raw cube texture with RGBD encoded data.
  104472. * @param data defines the array of data [mipmap][face] to use to create each face
  104473. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  104474. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  104475. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  104476. * @returns a promsie that resolves when the operation is complete
  104477. */
  104478. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  104479. /**
  104480. * Clones the raw cube texture.
  104481. * @return a new cube texture
  104482. */
  104483. clone(): CubeTexture;
  104484. /** @hidden */
  104485. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  104486. }
  104487. }
  104488. declare module BABYLON {
  104489. /**
  104490. * Class used to store 3D textures containing user data
  104491. */
  104492. export class RawTexture3D extends Texture {
  104493. /** Gets or sets the texture format to use */
  104494. format: number;
  104495. private _engine;
  104496. /**
  104497. * Create a new RawTexture3D
  104498. * @param data defines the data of the texture
  104499. * @param width defines the width of the texture
  104500. * @param height defines the height of the texture
  104501. * @param depth defines the depth of the texture
  104502. * @param format defines the texture format to use
  104503. * @param scene defines the hosting scene
  104504. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  104505. * @param invertY defines if texture must be stored with Y axis inverted
  104506. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  104507. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  104508. */
  104509. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  104510. /** Gets or sets the texture format to use */
  104511. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  104512. /**
  104513. * Update the texture with new data
  104514. * @param data defines the data to store in the texture
  104515. */
  104516. update(data: ArrayBufferView): void;
  104517. }
  104518. }
  104519. declare module BABYLON {
  104520. /**
  104521. * Creates a refraction texture used by refraction channel of the standard material.
  104522. * It is like a mirror but to see through a material.
  104523. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  104524. */
  104525. export class RefractionTexture extends RenderTargetTexture {
  104526. /**
  104527. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  104528. * 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.
  104529. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  104530. */
  104531. refractionPlane: Plane;
  104532. /**
  104533. * Define how deep under the surface we should see.
  104534. */
  104535. depth: number;
  104536. /**
  104537. * Creates a refraction texture used by refraction channel of the standard material.
  104538. * It is like a mirror but to see through a material.
  104539. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  104540. * @param name Define the texture name
  104541. * @param size Define the size of the underlying texture
  104542. * @param scene Define the scene the refraction belongs to
  104543. * @param generateMipMaps Define if we need to generate mips level for the refraction
  104544. */
  104545. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  104546. /**
  104547. * Clone the refraction texture.
  104548. * @returns the cloned texture
  104549. */
  104550. clone(): RefractionTexture;
  104551. /**
  104552. * Serialize the texture to a JSON representation you could use in Parse later on
  104553. * @returns the serialized JSON representation
  104554. */
  104555. serialize(): any;
  104556. }
  104557. }
  104558. declare module BABYLON {
  104559. /**
  104560. * Configuration for Draco compression
  104561. */
  104562. export interface IDracoCompressionConfiguration {
  104563. /**
  104564. * Configuration for the decoder.
  104565. */
  104566. decoder?: {
  104567. /**
  104568. * The url to the WebAssembly module.
  104569. */
  104570. wasmUrl?: string;
  104571. /**
  104572. * The url to the WebAssembly binary.
  104573. */
  104574. wasmBinaryUrl?: string;
  104575. /**
  104576. * The url to the fallback JavaScript module.
  104577. */
  104578. fallbackUrl?: string;
  104579. };
  104580. }
  104581. /**
  104582. * Draco compression (https://google.github.io/draco/)
  104583. *
  104584. * This class wraps the Draco module.
  104585. *
  104586. * **Encoder**
  104587. *
  104588. * The encoder is not currently implemented.
  104589. *
  104590. * **Decoder**
  104591. *
  104592. * 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.
  104593. *
  104594. * To update the configuration, use the following code:
  104595. * ```javascript
  104596. * DracoCompression.Configuration = {
  104597. * decoder: {
  104598. * wasmUrl: "<url to the WebAssembly library>",
  104599. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  104600. * fallbackUrl: "<url to the fallback JavaScript library>",
  104601. * }
  104602. * };
  104603. * ```
  104604. *
  104605. * 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.
  104606. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  104607. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  104608. *
  104609. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  104610. * ```javascript
  104611. * var dracoCompression = new DracoCompression();
  104612. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  104613. * [VertexBuffer.PositionKind]: 0
  104614. * });
  104615. * ```
  104616. *
  104617. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  104618. */
  104619. export class DracoCompression implements IDisposable {
  104620. private static _DecoderModulePromise;
  104621. /**
  104622. * The configuration. Defaults to the following urls:
  104623. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  104624. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  104625. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  104626. */
  104627. static Configuration: IDracoCompressionConfiguration;
  104628. /**
  104629. * Returns true if the decoder is available.
  104630. */
  104631. static readonly DecoderAvailable: boolean;
  104632. /**
  104633. * Constructor
  104634. */
  104635. constructor();
  104636. /**
  104637. * Stop all async operations and release resources.
  104638. */
  104639. dispose(): void;
  104640. /**
  104641. * Decode Draco compressed mesh data to vertex data.
  104642. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  104643. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  104644. * @returns A promise that resolves with the decoded vertex data
  104645. */
  104646. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  104647. [kind: string]: number;
  104648. }): Promise<VertexData>;
  104649. private static _GetDecoderModule;
  104650. private static _LoadScriptAsync;
  104651. private static _LoadFileAsync;
  104652. }
  104653. }
  104654. declare module BABYLON {
  104655. /**
  104656. * Class for building Constructive Solid Geometry
  104657. */
  104658. export class CSG {
  104659. private polygons;
  104660. /**
  104661. * The world matrix
  104662. */
  104663. matrix: Matrix;
  104664. /**
  104665. * Stores the position
  104666. */
  104667. position: Vector3;
  104668. /**
  104669. * Stores the rotation
  104670. */
  104671. rotation: Vector3;
  104672. /**
  104673. * Stores the rotation quaternion
  104674. */
  104675. rotationQuaternion: Nullable<Quaternion>;
  104676. /**
  104677. * Stores the scaling vector
  104678. */
  104679. scaling: Vector3;
  104680. /**
  104681. * Convert the Mesh to CSG
  104682. * @param mesh The Mesh to convert to CSG
  104683. * @returns A new CSG from the Mesh
  104684. */
  104685. static FromMesh(mesh: Mesh): CSG;
  104686. /**
  104687. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  104688. * @param polygons Polygons used to construct a CSG solid
  104689. */
  104690. private static FromPolygons;
  104691. /**
  104692. * Clones, or makes a deep copy, of the CSG
  104693. * @returns A new CSG
  104694. */
  104695. clone(): CSG;
  104696. /**
  104697. * Unions this CSG with another CSG
  104698. * @param csg The CSG to union against this CSG
  104699. * @returns The unioned CSG
  104700. */
  104701. union(csg: CSG): CSG;
  104702. /**
  104703. * Unions this CSG with another CSG in place
  104704. * @param csg The CSG to union against this CSG
  104705. */
  104706. unionInPlace(csg: CSG): void;
  104707. /**
  104708. * Subtracts this CSG with another CSG
  104709. * @param csg The CSG to subtract against this CSG
  104710. * @returns A new CSG
  104711. */
  104712. subtract(csg: CSG): CSG;
  104713. /**
  104714. * Subtracts this CSG with another CSG in place
  104715. * @param csg The CSG to subtact against this CSG
  104716. */
  104717. subtractInPlace(csg: CSG): void;
  104718. /**
  104719. * Intersect this CSG with another CSG
  104720. * @param csg The CSG to intersect against this CSG
  104721. * @returns A new CSG
  104722. */
  104723. intersect(csg: CSG): CSG;
  104724. /**
  104725. * Intersects this CSG with another CSG in place
  104726. * @param csg The CSG to intersect against this CSG
  104727. */
  104728. intersectInPlace(csg: CSG): void;
  104729. /**
  104730. * Return a new CSG solid with solid and empty space switched. This solid is
  104731. * not modified.
  104732. * @returns A new CSG solid with solid and empty space switched
  104733. */
  104734. inverse(): CSG;
  104735. /**
  104736. * Inverses the CSG in place
  104737. */
  104738. inverseInPlace(): void;
  104739. /**
  104740. * This is used to keep meshes transformations so they can be restored
  104741. * when we build back a Babylon Mesh
  104742. * NB : All CSG operations are performed in world coordinates
  104743. * @param csg The CSG to copy the transform attributes from
  104744. * @returns This CSG
  104745. */
  104746. copyTransformAttributes(csg: CSG): CSG;
  104747. /**
  104748. * Build Raw mesh from CSG
  104749. * Coordinates here are in world space
  104750. * @param name The name of the mesh geometry
  104751. * @param scene The Scene
  104752. * @param keepSubMeshes Specifies if the submeshes should be kept
  104753. * @returns A new Mesh
  104754. */
  104755. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  104756. /**
  104757. * Build Mesh from CSG taking material and transforms into account
  104758. * @param name The name of the Mesh
  104759. * @param material The material of the Mesh
  104760. * @param scene The Scene
  104761. * @param keepSubMeshes Specifies if submeshes should be kept
  104762. * @returns The new Mesh
  104763. */
  104764. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  104765. }
  104766. }
  104767. declare module BABYLON {
  104768. /**
  104769. * Class used to create a trail following a mesh
  104770. */
  104771. export class TrailMesh extends Mesh {
  104772. private _generator;
  104773. private _autoStart;
  104774. private _running;
  104775. private _diameter;
  104776. private _length;
  104777. private _sectionPolygonPointsCount;
  104778. private _sectionVectors;
  104779. private _sectionNormalVectors;
  104780. private _beforeRenderObserver;
  104781. /**
  104782. * @constructor
  104783. * @param name The value used by scene.getMeshByName() to do a lookup.
  104784. * @param generator The mesh to generate a trail.
  104785. * @param scene The scene to add this mesh to.
  104786. * @param diameter Diameter of trailing mesh. Default is 1.
  104787. * @param length Length of trailing mesh. Default is 60.
  104788. * @param autoStart Automatically start trailing mesh. Default true.
  104789. */
  104790. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  104791. /**
  104792. * "TrailMesh"
  104793. * @returns "TrailMesh"
  104794. */
  104795. getClassName(): string;
  104796. private _createMesh;
  104797. /**
  104798. * Start trailing mesh.
  104799. */
  104800. start(): void;
  104801. /**
  104802. * Stop trailing mesh.
  104803. */
  104804. stop(): void;
  104805. /**
  104806. * Update trailing mesh geometry.
  104807. */
  104808. update(): void;
  104809. /**
  104810. * Returns a new TrailMesh object.
  104811. * @param name is a string, the name given to the new mesh
  104812. * @param newGenerator use new generator object for cloned trail mesh
  104813. * @returns a new mesh
  104814. */
  104815. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  104816. /**
  104817. * Serializes this trail mesh
  104818. * @param serializationObject object to write serialization to
  104819. */
  104820. serialize(serializationObject: any): void;
  104821. /**
  104822. * Parses a serialized trail mesh
  104823. * @param parsedMesh the serialized mesh
  104824. * @param scene the scene to create the trail mesh in
  104825. * @returns the created trail mesh
  104826. */
  104827. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  104828. }
  104829. }
  104830. declare module BABYLON {
  104831. /**
  104832. * Class containing static functions to help procedurally build meshes
  104833. */
  104834. export class RibbonBuilder {
  104835. /**
  104836. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104837. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  104838. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  104839. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  104840. * * 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
  104841. * * 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
  104842. * * 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
  104843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104845. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104846. * * 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
  104847. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  104848. * * 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
  104849. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  104850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104851. * @param name defines the name of the mesh
  104852. * @param options defines the options used to create the mesh
  104853. * @param scene defines the hosting scene
  104854. * @returns the ribbon mesh
  104855. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  104856. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104857. */
  104858. static CreateRibbon(name: string, options: {
  104859. pathArray: Vector3[][];
  104860. closeArray?: boolean;
  104861. closePath?: boolean;
  104862. offset?: number;
  104863. updatable?: boolean;
  104864. sideOrientation?: number;
  104865. frontUVs?: Vector4;
  104866. backUVs?: Vector4;
  104867. instance?: Mesh;
  104868. invertUV?: boolean;
  104869. uvs?: Vector2[];
  104870. colors?: Color4[];
  104871. }, scene?: Nullable<Scene>): Mesh;
  104872. }
  104873. }
  104874. declare module BABYLON {
  104875. /**
  104876. * Class containing static functions to help procedurally build meshes
  104877. */
  104878. export class TorusKnotBuilder {
  104879. /**
  104880. * Creates a torus knot mesh
  104881. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  104882. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  104883. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  104884. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  104885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104888. * @param name defines the name of the mesh
  104889. * @param options defines the options used to create the mesh
  104890. * @param scene defines the hosting scene
  104891. * @returns the torus knot mesh
  104892. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  104893. */
  104894. static CreateTorusKnot(name: string, options: {
  104895. radius?: number;
  104896. tube?: number;
  104897. radialSegments?: number;
  104898. tubularSegments?: number;
  104899. p?: number;
  104900. q?: number;
  104901. updatable?: boolean;
  104902. sideOrientation?: number;
  104903. frontUVs?: Vector4;
  104904. backUVs?: Vector4;
  104905. }, scene: any): Mesh;
  104906. }
  104907. }
  104908. declare module BABYLON {
  104909. /**
  104910. * Polygon
  104911. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  104912. */
  104913. export class Polygon {
  104914. /**
  104915. * Creates a rectangle
  104916. * @param xmin bottom X coord
  104917. * @param ymin bottom Y coord
  104918. * @param xmax top X coord
  104919. * @param ymax top Y coord
  104920. * @returns points that make the resulting rectation
  104921. */
  104922. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  104923. /**
  104924. * Creates a circle
  104925. * @param radius radius of circle
  104926. * @param cx scale in x
  104927. * @param cy scale in y
  104928. * @param numberOfSides number of sides that make up the circle
  104929. * @returns points that make the resulting circle
  104930. */
  104931. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  104932. /**
  104933. * Creates a polygon from input string
  104934. * @param input Input polygon data
  104935. * @returns the parsed points
  104936. */
  104937. static Parse(input: string): Vector2[];
  104938. /**
  104939. * Starts building a polygon from x and y coordinates
  104940. * @param x x coordinate
  104941. * @param y y coordinate
  104942. * @returns the started path2
  104943. */
  104944. static StartingAt(x: number, y: number): Path2;
  104945. }
  104946. /**
  104947. * Builds a polygon
  104948. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  104949. */
  104950. export class PolygonMeshBuilder {
  104951. private _points;
  104952. private _outlinepoints;
  104953. private _holes;
  104954. private _name;
  104955. private _scene;
  104956. private _epoints;
  104957. private _eholes;
  104958. private _addToepoint;
  104959. /**
  104960. * Babylon reference to the earcut plugin.
  104961. */
  104962. bjsEarcut: any;
  104963. /**
  104964. * Creates a PolygonMeshBuilder
  104965. * @param name name of the builder
  104966. * @param contours Path of the polygon
  104967. * @param scene scene to add to
  104968. * @param earcutInjection can be used to inject your own earcut reference
  104969. */
  104970. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  104971. /**
  104972. * Adds a whole within the polygon
  104973. * @param hole Array of points defining the hole
  104974. * @returns this
  104975. */
  104976. addHole(hole: Vector2[]): PolygonMeshBuilder;
  104977. /**
  104978. * Creates the polygon
  104979. * @param updatable If the mesh should be updatable
  104980. * @param depth The depth of the mesh created
  104981. * @returns the created mesh
  104982. */
  104983. build(updatable?: boolean, depth?: number): Mesh;
  104984. /**
  104985. * Adds a side to the polygon
  104986. * @param positions points that make the polygon
  104987. * @param normals normals of the polygon
  104988. * @param uvs uvs of the polygon
  104989. * @param indices indices of the polygon
  104990. * @param bounds bounds of the polygon
  104991. * @param points points of the polygon
  104992. * @param depth depth of the polygon
  104993. * @param flip flip of the polygon
  104994. */
  104995. private addSide;
  104996. }
  104997. }
  104998. declare module BABYLON {
  104999. /**
  105000. * Class containing static functions to help procedurally build meshes
  105001. */
  105002. export class PolygonBuilder {
  105003. /**
  105004. * Creates a polygon mesh
  105005. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105006. * * 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
  105007. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105009. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  105010. * * Remember you can only change the shape positions, not their number when updating a polygon
  105011. * @param name defines the name of the mesh
  105012. * @param options defines the options used to create the mesh
  105013. * @param scene defines the hosting scene
  105014. * @param earcutInjection can be used to inject your own earcut reference
  105015. * @returns the polygon mesh
  105016. */
  105017. static CreatePolygon(name: string, options: {
  105018. shape: Vector3[];
  105019. holes?: Vector3[][];
  105020. depth?: number;
  105021. faceUV?: Vector4[];
  105022. faceColors?: Color4[];
  105023. updatable?: boolean;
  105024. sideOrientation?: number;
  105025. frontUVs?: Vector4;
  105026. backUVs?: Vector4;
  105027. }, scene: Scene, earcutInjection?: any): Mesh;
  105028. /**
  105029. * Creates an extruded polygon mesh, with depth in the Y direction.
  105030. * * 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)
  105031. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105032. * @param name defines the name of the mesh
  105033. * @param options defines the options used to create the mesh
  105034. * @param scene defines the hosting scene
  105035. * @param earcutInjection can be used to inject your own earcut reference
  105036. * @returns the polygon mesh
  105037. */
  105038. static ExtrudePolygon(name: string, options: {
  105039. shape: Vector3[];
  105040. holes?: Vector3[][];
  105041. depth?: number;
  105042. faceUV?: Vector4[];
  105043. faceColors?: Color4[];
  105044. updatable?: boolean;
  105045. sideOrientation?: number;
  105046. frontUVs?: Vector4;
  105047. backUVs?: Vector4;
  105048. }, scene: Scene, earcutInjection?: any): Mesh;
  105049. }
  105050. }
  105051. declare module BABYLON {
  105052. /**
  105053. * Class containing static functions to help procedurally build meshes
  105054. */
  105055. export class ShapeBuilder {
  105056. /**
  105057. * 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.
  105058. * * 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.
  105059. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105060. * * 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.
  105061. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  105062. * * 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
  105063. * * 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
  105064. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  105065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105066. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105067. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  105068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105069. * @param name defines the name of the mesh
  105070. * @param options defines the options used to create the mesh
  105071. * @param scene defines the hosting scene
  105072. * @returns the extruded shape mesh
  105073. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105074. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105075. */
  105076. static ExtrudeShape(name: string, options: {
  105077. shape: Vector3[];
  105078. path: Vector3[];
  105079. scale?: number;
  105080. rotation?: number;
  105081. cap?: number;
  105082. updatable?: boolean;
  105083. sideOrientation?: number;
  105084. frontUVs?: Vector4;
  105085. backUVs?: Vector4;
  105086. instance?: Mesh;
  105087. invertUV?: boolean;
  105088. }, scene?: Nullable<Scene>): Mesh;
  105089. /**
  105090. * Creates an custom extruded shape mesh.
  105091. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  105092. * * 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.
  105093. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105094. * * 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
  105095. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  105096. * * 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
  105097. * * It must returns a float value that will be the scale value applied to the shape on each path point
  105098. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105099. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  105100. * * 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
  105101. * * 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
  105102. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  105103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105105. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105107. * @param name defines the name of the mesh
  105108. * @param options defines the options used to create the mesh
  105109. * @param scene defines the hosting scene
  105110. * @returns the custom extruded shape mesh
  105111. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  105112. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105113. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105114. */
  105115. static ExtrudeShapeCustom(name: string, options: {
  105116. shape: Vector3[];
  105117. path: Vector3[];
  105118. scaleFunction?: any;
  105119. rotationFunction?: any;
  105120. ribbonCloseArray?: boolean;
  105121. ribbonClosePath?: boolean;
  105122. cap?: number;
  105123. updatable?: boolean;
  105124. sideOrientation?: number;
  105125. frontUVs?: Vector4;
  105126. backUVs?: Vector4;
  105127. instance?: Mesh;
  105128. invertUV?: boolean;
  105129. }, scene: Scene): Mesh;
  105130. private static _ExtrudeShapeGeneric;
  105131. }
  105132. }
  105133. declare module BABYLON {
  105134. /**
  105135. * Class containing static functions to help procedurally build meshes
  105136. */
  105137. export class LatheBuilder {
  105138. /**
  105139. * Creates lathe mesh.
  105140. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  105141. * * 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
  105142. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  105143. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  105144. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  105145. * * 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
  105146. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  105147. * * 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
  105148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105150. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105152. * @param name defines the name of the mesh
  105153. * @param options defines the options used to create the mesh
  105154. * @param scene defines the hosting scene
  105155. * @returns the lathe mesh
  105156. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  105157. */
  105158. static CreateLathe(name: string, options: {
  105159. shape: Vector3[];
  105160. radius?: number;
  105161. tessellation?: number;
  105162. clip?: number;
  105163. arc?: number;
  105164. closed?: boolean;
  105165. updatable?: boolean;
  105166. sideOrientation?: number;
  105167. frontUVs?: Vector4;
  105168. backUVs?: Vector4;
  105169. cap?: number;
  105170. invertUV?: boolean;
  105171. }, scene: Scene): Mesh;
  105172. }
  105173. }
  105174. declare module BABYLON {
  105175. /**
  105176. * Class containing static functions to help procedurally build meshes
  105177. */
  105178. export class TubeBuilder {
  105179. /**
  105180. * Creates a tube mesh.
  105181. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105182. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  105183. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  105184. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  105185. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  105186. * * 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)
  105187. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  105188. * * 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
  105189. * * 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
  105190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105192. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105194. * @param name defines the name of the mesh
  105195. * @param options defines the options used to create the mesh
  105196. * @param scene defines the hosting scene
  105197. * @returns the tube mesh
  105198. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105199. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  105200. */
  105201. static CreateTube(name: string, options: {
  105202. path: Vector3[];
  105203. radius?: number;
  105204. tessellation?: number;
  105205. radiusFunction?: {
  105206. (i: number, distance: number): number;
  105207. };
  105208. cap?: number;
  105209. arc?: number;
  105210. updatable?: boolean;
  105211. sideOrientation?: number;
  105212. frontUVs?: Vector4;
  105213. backUVs?: Vector4;
  105214. instance?: Mesh;
  105215. invertUV?: boolean;
  105216. }, scene: Scene): Mesh;
  105217. }
  105218. }
  105219. declare module BABYLON {
  105220. /**
  105221. * Class containing static functions to help procedurally build meshes
  105222. */
  105223. export class IcoSphereBuilder {
  105224. /**
  105225. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105226. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105227. * * 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`)
  105228. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105229. * * 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
  105230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105233. * @param name defines the name of the mesh
  105234. * @param options defines the options used to create the mesh
  105235. * @param scene defines the hosting scene
  105236. * @returns the icosahedron mesh
  105237. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105238. */
  105239. static CreateIcoSphere(name: string, options: {
  105240. radius?: number;
  105241. radiusX?: number;
  105242. radiusY?: number;
  105243. radiusZ?: number;
  105244. flat?: boolean;
  105245. subdivisions?: number;
  105246. sideOrientation?: number;
  105247. frontUVs?: Vector4;
  105248. backUVs?: Vector4;
  105249. updatable?: boolean;
  105250. }, scene: Scene): Mesh;
  105251. }
  105252. }
  105253. declare module BABYLON {
  105254. /**
  105255. * Class containing static functions to help procedurally build meshes
  105256. */
  105257. export class DecalBuilder {
  105258. /**
  105259. * Creates a decal mesh.
  105260. * 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
  105261. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  105262. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  105263. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  105264. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  105265. * @param name defines the name of the mesh
  105266. * @param sourceMesh defines the mesh where the decal must be applied
  105267. * @param options defines the options used to create the mesh
  105268. * @param scene defines the hosting scene
  105269. * @returns the decal mesh
  105270. * @see https://doc.babylonjs.com/how_to/decals
  105271. */
  105272. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  105273. position?: Vector3;
  105274. normal?: Vector3;
  105275. size?: Vector3;
  105276. angle?: number;
  105277. }): Mesh;
  105278. }
  105279. }
  105280. declare module BABYLON {
  105281. /**
  105282. * Class containing static functions to help procedurally build meshes
  105283. */
  105284. export class MeshBuilder {
  105285. /**
  105286. * Creates a box mesh
  105287. * * The parameter `size` sets the size (float) of each box side (default 1)
  105288. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  105289. * * 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)
  105290. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105292. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105294. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  105295. * @param name defines the name of the mesh
  105296. * @param options defines the options used to create the mesh
  105297. * @param scene defines the hosting scene
  105298. * @returns the box mesh
  105299. */
  105300. static CreateBox(name: string, options: {
  105301. size?: number;
  105302. width?: number;
  105303. height?: number;
  105304. depth?: number;
  105305. faceUV?: Vector4[];
  105306. faceColors?: Color4[];
  105307. sideOrientation?: number;
  105308. frontUVs?: Vector4;
  105309. backUVs?: Vector4;
  105310. updatable?: boolean;
  105311. }, scene?: Nullable<Scene>): Mesh;
  105312. /**
  105313. * Creates a sphere mesh
  105314. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  105315. * * 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`)
  105316. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  105317. * * 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
  105318. * * 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)
  105319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105322. * @param name defines the name of the mesh
  105323. * @param options defines the options used to create the mesh
  105324. * @param scene defines the hosting scene
  105325. * @returns the sphere mesh
  105326. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  105327. */
  105328. static CreateSphere(name: string, options: {
  105329. segments?: number;
  105330. diameter?: number;
  105331. diameterX?: number;
  105332. diameterY?: number;
  105333. diameterZ?: number;
  105334. arc?: number;
  105335. slice?: number;
  105336. sideOrientation?: number;
  105337. frontUVs?: Vector4;
  105338. backUVs?: Vector4;
  105339. updatable?: boolean;
  105340. }, scene: any): Mesh;
  105341. /**
  105342. * Creates a plane polygonal mesh. By default, this is a disc
  105343. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  105344. * * 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
  105345. * * 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
  105346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105349. * @param name defines the name of the mesh
  105350. * @param options defines the options used to create the mesh
  105351. * @param scene defines the hosting scene
  105352. * @returns the plane polygonal mesh
  105353. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  105354. */
  105355. static CreateDisc(name: string, options: {
  105356. radius?: number;
  105357. tessellation?: number;
  105358. arc?: number;
  105359. updatable?: boolean;
  105360. sideOrientation?: number;
  105361. frontUVs?: Vector4;
  105362. backUVs?: Vector4;
  105363. }, scene?: Nullable<Scene>): Mesh;
  105364. /**
  105365. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105366. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105367. * * 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`)
  105368. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105369. * * 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
  105370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105373. * @param name defines the name of the mesh
  105374. * @param options defines the options used to create the mesh
  105375. * @param scene defines the hosting scene
  105376. * @returns the icosahedron mesh
  105377. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105378. */
  105379. static CreateIcoSphere(name: string, options: {
  105380. radius?: number;
  105381. radiusX?: number;
  105382. radiusY?: number;
  105383. radiusZ?: number;
  105384. flat?: boolean;
  105385. subdivisions?: number;
  105386. sideOrientation?: number;
  105387. frontUVs?: Vector4;
  105388. backUVs?: Vector4;
  105389. updatable?: boolean;
  105390. }, scene: Scene): Mesh;
  105391. /**
  105392. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105393. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105394. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105395. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105396. * * 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
  105397. * * 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
  105398. * * 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
  105399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105401. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105402. * * 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
  105403. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105404. * * 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
  105405. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105407. * @param name defines the name of the mesh
  105408. * @param options defines the options used to create the mesh
  105409. * @param scene defines the hosting scene
  105410. * @returns the ribbon mesh
  105411. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105412. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105413. */
  105414. static CreateRibbon(name: string, options: {
  105415. pathArray: Vector3[][];
  105416. closeArray?: boolean;
  105417. closePath?: boolean;
  105418. offset?: number;
  105419. updatable?: boolean;
  105420. sideOrientation?: number;
  105421. frontUVs?: Vector4;
  105422. backUVs?: Vector4;
  105423. instance?: Mesh;
  105424. invertUV?: boolean;
  105425. uvs?: Vector2[];
  105426. colors?: Color4[];
  105427. }, scene?: Nullable<Scene>): Mesh;
  105428. /**
  105429. * Creates a cylinder or a cone mesh
  105430. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  105431. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  105432. * * 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.
  105433. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  105434. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  105435. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  105436. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  105437. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  105438. * * 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).
  105439. * * 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
  105440. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  105441. * * 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
  105442. * * 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.
  105443. * * If `enclose` is false, a ring surface is one element.
  105444. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  105445. * * 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
  105446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105449. * @param name defines the name of the mesh
  105450. * @param options defines the options used to create the mesh
  105451. * @param scene defines the hosting scene
  105452. * @returns the cylinder mesh
  105453. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  105454. */
  105455. static CreateCylinder(name: string, options: {
  105456. height?: number;
  105457. diameterTop?: number;
  105458. diameterBottom?: number;
  105459. diameter?: number;
  105460. tessellation?: number;
  105461. subdivisions?: number;
  105462. arc?: number;
  105463. faceColors?: Color4[];
  105464. faceUV?: Vector4[];
  105465. updatable?: boolean;
  105466. hasRings?: boolean;
  105467. enclose?: boolean;
  105468. sideOrientation?: number;
  105469. frontUVs?: Vector4;
  105470. backUVs?: Vector4;
  105471. }, scene: any): Mesh;
  105472. /**
  105473. * Creates a torus mesh
  105474. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  105475. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  105476. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  105477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105478. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105480. * @param name defines the name of the mesh
  105481. * @param options defines the options used to create the mesh
  105482. * @param scene defines the hosting scene
  105483. * @returns the torus mesh
  105484. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  105485. */
  105486. static CreateTorus(name: string, options: {
  105487. diameter?: number;
  105488. thickness?: number;
  105489. tessellation?: number;
  105490. updatable?: boolean;
  105491. sideOrientation?: number;
  105492. frontUVs?: Vector4;
  105493. backUVs?: Vector4;
  105494. }, scene: any): Mesh;
  105495. /**
  105496. * Creates a torus knot mesh
  105497. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  105498. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  105499. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  105500. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  105501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105504. * @param name defines the name of the mesh
  105505. * @param options defines the options used to create the mesh
  105506. * @param scene defines the hosting scene
  105507. * @returns the torus knot mesh
  105508. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  105509. */
  105510. static CreateTorusKnot(name: string, options: {
  105511. radius?: number;
  105512. tube?: number;
  105513. radialSegments?: number;
  105514. tubularSegments?: number;
  105515. p?: number;
  105516. q?: number;
  105517. updatable?: boolean;
  105518. sideOrientation?: number;
  105519. frontUVs?: Vector4;
  105520. backUVs?: Vector4;
  105521. }, scene: any): Mesh;
  105522. /**
  105523. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  105524. * * 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
  105525. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  105526. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  105527. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  105528. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  105529. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  105530. * * 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
  105531. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  105532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105533. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  105534. * @param name defines the name of the new line system
  105535. * @param options defines the options used to create the line system
  105536. * @param scene defines the hosting scene
  105537. * @returns a new line system mesh
  105538. */
  105539. static CreateLineSystem(name: string, options: {
  105540. lines: Vector3[][];
  105541. updatable?: boolean;
  105542. instance?: Nullable<LinesMesh>;
  105543. colors?: Nullable<Color4[][]>;
  105544. useVertexAlpha?: boolean;
  105545. }, scene: Nullable<Scene>): LinesMesh;
  105546. /**
  105547. * Creates a line mesh
  105548. * 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
  105549. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  105550. * * The parameter `points` is an array successive Vector3
  105551. * * 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
  105552. * * The optional parameter `colors` is an array of successive Color4, one per line point
  105553. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  105554. * * When updating an instance, remember that only point positions can change, not the number of points
  105555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  105557. * @param name defines the name of the new line system
  105558. * @param options defines the options used to create the line system
  105559. * @param scene defines the hosting scene
  105560. * @returns a new line mesh
  105561. */
  105562. static CreateLines(name: string, options: {
  105563. points: Vector3[];
  105564. updatable?: boolean;
  105565. instance?: Nullable<LinesMesh>;
  105566. colors?: Color4[];
  105567. useVertexAlpha?: boolean;
  105568. }, scene?: Nullable<Scene>): LinesMesh;
  105569. /**
  105570. * Creates a dashed line mesh
  105571. * * 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
  105572. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  105573. * * The parameter `points` is an array successive Vector3
  105574. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  105575. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  105576. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  105577. * * 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
  105578. * * When updating an instance, remember that only point positions can change, not the number of points
  105579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105580. * @param name defines the name of the mesh
  105581. * @param options defines the options used to create the mesh
  105582. * @param scene defines the hosting scene
  105583. * @returns the dashed line mesh
  105584. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  105585. */
  105586. static CreateDashedLines(name: string, options: {
  105587. points: Vector3[];
  105588. dashSize?: number;
  105589. gapSize?: number;
  105590. dashNb?: number;
  105591. updatable?: boolean;
  105592. instance?: LinesMesh;
  105593. }, scene?: Nullable<Scene>): LinesMesh;
  105594. /**
  105595. * 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.
  105596. * * 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.
  105597. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105598. * * 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.
  105599. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  105600. * * 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
  105601. * * 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
  105602. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  105603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105604. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105605. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  105606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105607. * @param name defines the name of the mesh
  105608. * @param options defines the options used to create the mesh
  105609. * @param scene defines the hosting scene
  105610. * @returns the extruded shape mesh
  105611. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105612. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105613. */
  105614. static ExtrudeShape(name: string, options: {
  105615. shape: Vector3[];
  105616. path: Vector3[];
  105617. scale?: number;
  105618. rotation?: number;
  105619. cap?: number;
  105620. updatable?: boolean;
  105621. sideOrientation?: number;
  105622. frontUVs?: Vector4;
  105623. backUVs?: Vector4;
  105624. instance?: Mesh;
  105625. invertUV?: boolean;
  105626. }, scene?: Nullable<Scene>): Mesh;
  105627. /**
  105628. * Creates an custom extruded shape mesh.
  105629. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  105630. * * 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.
  105631. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105632. * * 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
  105633. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  105634. * * 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
  105635. * * It must returns a float value that will be the scale value applied to the shape on each path point
  105636. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105637. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  105638. * * 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
  105639. * * 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
  105640. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  105641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105642. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105643. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105645. * @param name defines the name of the mesh
  105646. * @param options defines the options used to create the mesh
  105647. * @param scene defines the hosting scene
  105648. * @returns the custom extruded shape mesh
  105649. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  105650. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105651. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105652. */
  105653. static ExtrudeShapeCustom(name: string, options: {
  105654. shape: Vector3[];
  105655. path: Vector3[];
  105656. scaleFunction?: any;
  105657. rotationFunction?: any;
  105658. ribbonCloseArray?: boolean;
  105659. ribbonClosePath?: boolean;
  105660. cap?: number;
  105661. updatable?: boolean;
  105662. sideOrientation?: number;
  105663. frontUVs?: Vector4;
  105664. backUVs?: Vector4;
  105665. instance?: Mesh;
  105666. invertUV?: boolean;
  105667. }, scene: Scene): Mesh;
  105668. /**
  105669. * Creates lathe mesh.
  105670. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  105671. * * 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
  105672. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  105673. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  105674. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  105675. * * 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
  105676. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  105677. * * 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
  105678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105679. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105680. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105682. * @param name defines the name of the mesh
  105683. * @param options defines the options used to create the mesh
  105684. * @param scene defines the hosting scene
  105685. * @returns the lathe mesh
  105686. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  105687. */
  105688. static CreateLathe(name: string, options: {
  105689. shape: Vector3[];
  105690. radius?: number;
  105691. tessellation?: number;
  105692. clip?: number;
  105693. arc?: number;
  105694. closed?: boolean;
  105695. updatable?: boolean;
  105696. sideOrientation?: number;
  105697. frontUVs?: Vector4;
  105698. backUVs?: Vector4;
  105699. cap?: number;
  105700. invertUV?: boolean;
  105701. }, scene: Scene): Mesh;
  105702. /**
  105703. * Creates a plane mesh
  105704. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  105705. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  105706. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  105707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105710. * @param name defines the name of the mesh
  105711. * @param options defines the options used to create the mesh
  105712. * @param scene defines the hosting scene
  105713. * @returns the plane mesh
  105714. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  105715. */
  105716. static CreatePlane(name: string, options: {
  105717. size?: number;
  105718. width?: number;
  105719. height?: number;
  105720. sideOrientation?: number;
  105721. frontUVs?: Vector4;
  105722. backUVs?: Vector4;
  105723. updatable?: boolean;
  105724. sourcePlane?: Plane;
  105725. }, scene: Scene): Mesh;
  105726. /**
  105727. * Creates a ground mesh
  105728. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  105729. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  105730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105731. * @param name defines the name of the mesh
  105732. * @param options defines the options used to create the mesh
  105733. * @param scene defines the hosting scene
  105734. * @returns the ground mesh
  105735. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  105736. */
  105737. static CreateGround(name: string, options: {
  105738. width?: number;
  105739. height?: number;
  105740. subdivisions?: number;
  105741. subdivisionsX?: number;
  105742. subdivisionsY?: number;
  105743. updatable?: boolean;
  105744. }, scene: any): Mesh;
  105745. /**
  105746. * Creates a tiled ground mesh
  105747. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  105748. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  105749. * * 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
  105750. * * 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
  105751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105752. * @param name defines the name of the mesh
  105753. * @param options defines the options used to create the mesh
  105754. * @param scene defines the hosting scene
  105755. * @returns the tiled ground mesh
  105756. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  105757. */
  105758. static CreateTiledGround(name: string, options: {
  105759. xmin: number;
  105760. zmin: number;
  105761. xmax: number;
  105762. zmax: number;
  105763. subdivisions?: {
  105764. w: number;
  105765. h: number;
  105766. };
  105767. precision?: {
  105768. w: number;
  105769. h: number;
  105770. };
  105771. updatable?: boolean;
  105772. }, scene: Scene): Mesh;
  105773. /**
  105774. * Creates a ground mesh from a height map
  105775. * * The parameter `url` sets the URL of the height map image resource.
  105776. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  105777. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  105778. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  105779. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  105780. * * 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.
  105781. * * 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).
  105782. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105784. * @param name defines the name of the mesh
  105785. * @param url defines the url to the height map
  105786. * @param options defines the options used to create the mesh
  105787. * @param scene defines the hosting scene
  105788. * @returns the ground mesh
  105789. * @see https://doc.babylonjs.com/babylon101/height_map
  105790. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  105791. */
  105792. static CreateGroundFromHeightMap(name: string, url: string, options: {
  105793. width?: number;
  105794. height?: number;
  105795. subdivisions?: number;
  105796. minHeight?: number;
  105797. maxHeight?: number;
  105798. colorFilter?: Color3;
  105799. alphaFilter?: number;
  105800. updatable?: boolean;
  105801. onReady?: (mesh: GroundMesh) => void;
  105802. }, scene: Scene): GroundMesh;
  105803. /**
  105804. * Creates a polygon mesh
  105805. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105806. * * 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
  105807. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  105810. * * Remember you can only change the shape positions, not their number when updating a polygon
  105811. * @param name defines the name of the mesh
  105812. * @param options defines the options used to create the mesh
  105813. * @param scene defines the hosting scene
  105814. * @param earcutInjection can be used to inject your own earcut reference
  105815. * @returns the polygon mesh
  105816. */
  105817. static CreatePolygon(name: string, options: {
  105818. shape: Vector3[];
  105819. holes?: Vector3[][];
  105820. depth?: number;
  105821. faceUV?: Vector4[];
  105822. faceColors?: Color4[];
  105823. updatable?: boolean;
  105824. sideOrientation?: number;
  105825. frontUVs?: Vector4;
  105826. backUVs?: Vector4;
  105827. }, scene: Scene, earcutInjection?: any): Mesh;
  105828. /**
  105829. * Creates an extruded polygon mesh, with depth in the Y direction.
  105830. * * 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)
  105831. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105832. * @param name defines the name of the mesh
  105833. * @param options defines the options used to create the mesh
  105834. * @param scene defines the hosting scene
  105835. * @param earcutInjection can be used to inject your own earcut reference
  105836. * @returns the polygon mesh
  105837. */
  105838. static ExtrudePolygon(name: string, options: {
  105839. shape: Vector3[];
  105840. holes?: Vector3[][];
  105841. depth?: number;
  105842. faceUV?: Vector4[];
  105843. faceColors?: Color4[];
  105844. updatable?: boolean;
  105845. sideOrientation?: number;
  105846. frontUVs?: Vector4;
  105847. backUVs?: Vector4;
  105848. }, scene: Scene, earcutInjection?: any): Mesh;
  105849. /**
  105850. * Creates a tube mesh.
  105851. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105852. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  105853. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  105854. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  105855. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  105856. * * 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)
  105857. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  105858. * * 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
  105859. * * 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
  105860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105862. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105864. * @param name defines the name of the mesh
  105865. * @param options defines the options used to create the mesh
  105866. * @param scene defines the hosting scene
  105867. * @returns the tube mesh
  105868. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105869. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  105870. */
  105871. static CreateTube(name: string, options: {
  105872. path: Vector3[];
  105873. radius?: number;
  105874. tessellation?: number;
  105875. radiusFunction?: {
  105876. (i: number, distance: number): number;
  105877. };
  105878. cap?: number;
  105879. arc?: number;
  105880. updatable?: boolean;
  105881. sideOrientation?: number;
  105882. frontUVs?: Vector4;
  105883. backUVs?: Vector4;
  105884. instance?: Mesh;
  105885. invertUV?: boolean;
  105886. }, scene: Scene): Mesh;
  105887. /**
  105888. * Creates a polyhedron mesh
  105889. * * 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
  105890. * * The parameter `size` (positive float, default 1) sets the polygon size
  105891. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105892. * * 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`
  105893. * * 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
  105894. * * 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)`)
  105895. * * 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
  105896. * * 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
  105897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105898. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105900. * @param name defines the name of the mesh
  105901. * @param options defines the options used to create the mesh
  105902. * @param scene defines the hosting scene
  105903. * @returns the polyhedron mesh
  105904. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  105905. */
  105906. static CreatePolyhedron(name: string, options: {
  105907. type?: number;
  105908. size?: number;
  105909. sizeX?: number;
  105910. sizeY?: number;
  105911. sizeZ?: number;
  105912. custom?: any;
  105913. faceUV?: Vector4[];
  105914. faceColors?: Color4[];
  105915. flat?: boolean;
  105916. updatable?: boolean;
  105917. sideOrientation?: number;
  105918. frontUVs?: Vector4;
  105919. backUVs?: Vector4;
  105920. }, scene: Scene): Mesh;
  105921. /**
  105922. * Creates a decal mesh.
  105923. * 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
  105924. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  105925. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  105926. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  105927. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  105928. * @param name defines the name of the mesh
  105929. * @param sourceMesh defines the mesh where the decal must be applied
  105930. * @param options defines the options used to create the mesh
  105931. * @param scene defines the hosting scene
  105932. * @returns the decal mesh
  105933. * @see https://doc.babylonjs.com/how_to/decals
  105934. */
  105935. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  105936. position?: Vector3;
  105937. normal?: Vector3;
  105938. size?: Vector3;
  105939. angle?: number;
  105940. }): Mesh;
  105941. }
  105942. }
  105943. declare module BABYLON {
  105944. /**
  105945. * A simplifier interface for future simplification implementations
  105946. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  105947. */
  105948. export interface ISimplifier {
  105949. /**
  105950. * Simplification of a given mesh according to the given settings.
  105951. * Since this requires computation, it is assumed that the function runs async.
  105952. * @param settings The settings of the simplification, including quality and distance
  105953. * @param successCallback A callback that will be called after the mesh was simplified.
  105954. * @param errorCallback in case of an error, this callback will be called. optional.
  105955. */
  105956. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  105957. }
  105958. /**
  105959. * Expected simplification settings.
  105960. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  105961. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  105962. */
  105963. export interface ISimplificationSettings {
  105964. /**
  105965. * Gets or sets the expected quality
  105966. */
  105967. quality: number;
  105968. /**
  105969. * Gets or sets the distance when this optimized version should be used
  105970. */
  105971. distance: number;
  105972. /**
  105973. * Gets an already optimized mesh
  105974. */
  105975. optimizeMesh?: boolean;
  105976. }
  105977. /**
  105978. * Class used to specify simplification options
  105979. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  105980. */
  105981. export class SimplificationSettings implements ISimplificationSettings {
  105982. /** expected quality */
  105983. quality: number;
  105984. /** distance when this optimized version should be used */
  105985. distance: number;
  105986. /** already optimized mesh */
  105987. optimizeMesh?: boolean | undefined;
  105988. /**
  105989. * Creates a SimplificationSettings
  105990. * @param quality expected quality
  105991. * @param distance distance when this optimized version should be used
  105992. * @param optimizeMesh already optimized mesh
  105993. */
  105994. constructor(
  105995. /** expected quality */
  105996. quality: number,
  105997. /** distance when this optimized version should be used */
  105998. distance: number,
  105999. /** already optimized mesh */
  106000. optimizeMesh?: boolean | undefined);
  106001. }
  106002. /**
  106003. * Interface used to define a simplification task
  106004. */
  106005. export interface ISimplificationTask {
  106006. /**
  106007. * Array of settings
  106008. */
  106009. settings: Array<ISimplificationSettings>;
  106010. /**
  106011. * Simplification type
  106012. */
  106013. simplificationType: SimplificationType;
  106014. /**
  106015. * Mesh to simplify
  106016. */
  106017. mesh: Mesh;
  106018. /**
  106019. * Callback called on success
  106020. */
  106021. successCallback?: () => void;
  106022. /**
  106023. * Defines if parallel processing can be used
  106024. */
  106025. parallelProcessing: boolean;
  106026. }
  106027. /**
  106028. * Queue used to order the simplification tasks
  106029. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106030. */
  106031. export class SimplificationQueue {
  106032. private _simplificationArray;
  106033. /**
  106034. * Gets a boolean indicating that the process is still running
  106035. */
  106036. running: boolean;
  106037. /**
  106038. * Creates a new queue
  106039. */
  106040. constructor();
  106041. /**
  106042. * Adds a new simplification task
  106043. * @param task defines a task to add
  106044. */
  106045. addTask(task: ISimplificationTask): void;
  106046. /**
  106047. * Execute next task
  106048. */
  106049. executeNext(): void;
  106050. /**
  106051. * Execute a simplification task
  106052. * @param task defines the task to run
  106053. */
  106054. runSimplification(task: ISimplificationTask): void;
  106055. private getSimplifier;
  106056. }
  106057. /**
  106058. * The implemented types of simplification
  106059. * At the moment only Quadratic Error Decimation is implemented
  106060. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106061. */
  106062. export enum SimplificationType {
  106063. /** Quadratic error decimation */
  106064. QUADRATIC = 0
  106065. }
  106066. }
  106067. declare module BABYLON {
  106068. interface Scene {
  106069. /** @hidden (Backing field) */
  106070. _simplificationQueue: SimplificationQueue;
  106071. /**
  106072. * Gets or sets the simplification queue attached to the scene
  106073. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106074. */
  106075. simplificationQueue: SimplificationQueue;
  106076. }
  106077. interface Mesh {
  106078. /**
  106079. * Simplify the mesh according to the given array of settings.
  106080. * Function will return immediately and will simplify async
  106081. * @param settings a collection of simplification settings
  106082. * @param parallelProcessing should all levels calculate parallel or one after the other
  106083. * @param simplificationType the type of simplification to run
  106084. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  106085. * @returns the current mesh
  106086. */
  106087. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  106088. }
  106089. /**
  106090. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  106091. * created in a scene
  106092. */
  106093. export class SimplicationQueueSceneComponent implements ISceneComponent {
  106094. /**
  106095. * The component name helpfull to identify the component in the list of scene components.
  106096. */
  106097. readonly name: string;
  106098. /**
  106099. * The scene the component belongs to.
  106100. */
  106101. scene: Scene;
  106102. /**
  106103. * Creates a new instance of the component for the given scene
  106104. * @param scene Defines the scene to register the component in
  106105. */
  106106. constructor(scene: Scene);
  106107. /**
  106108. * Registers the component in a given scene
  106109. */
  106110. register(): void;
  106111. /**
  106112. * Rebuilds the elements related to this component in case of
  106113. * context lost for instance.
  106114. */
  106115. rebuild(): void;
  106116. /**
  106117. * Disposes the component and the associated ressources
  106118. */
  106119. dispose(): void;
  106120. private _beforeCameraUpdate;
  106121. }
  106122. }
  106123. declare module BABYLON {
  106124. /**
  106125. * Class used to enable access to IndexedDB
  106126. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106127. */
  106128. export class Database implements IOfflineProvider {
  106129. private _callbackManifestChecked;
  106130. private _currentSceneUrl;
  106131. private _db;
  106132. private _enableSceneOffline;
  106133. private _enableTexturesOffline;
  106134. private _manifestVersionFound;
  106135. private _mustUpdateRessources;
  106136. private _hasReachedQuota;
  106137. private _isSupported;
  106138. private _idbFactory;
  106139. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  106140. private static IsUASupportingBlobStorage;
  106141. /**
  106142. * Gets a boolean indicating if Database storate is enabled (off by default)
  106143. */
  106144. static IDBStorageEnabled: boolean;
  106145. /**
  106146. * Gets a boolean indicating if scene must be saved in the database
  106147. */
  106148. readonly enableSceneOffline: boolean;
  106149. /**
  106150. * Gets a boolean indicating if textures must be saved in the database
  106151. */
  106152. readonly enableTexturesOffline: boolean;
  106153. /**
  106154. * Creates a new Database
  106155. * @param urlToScene defines the url to load the scene
  106156. * @param callbackManifestChecked defines the callback to use when manifest is checked
  106157. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  106158. */
  106159. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  106160. private static _ParseURL;
  106161. private static _ReturnFullUrlLocation;
  106162. private _checkManifestFile;
  106163. /**
  106164. * Open the database and make it available
  106165. * @param successCallback defines the callback to call on success
  106166. * @param errorCallback defines the callback to call on error
  106167. */
  106168. open(successCallback: () => void, errorCallback: () => void): void;
  106169. /**
  106170. * Loads an image from the database
  106171. * @param url defines the url to load from
  106172. * @param image defines the target DOM image
  106173. */
  106174. loadImage(url: string, image: HTMLImageElement): void;
  106175. private _loadImageFromDBAsync;
  106176. private _saveImageIntoDBAsync;
  106177. private _checkVersionFromDB;
  106178. private _loadVersionFromDBAsync;
  106179. private _saveVersionIntoDBAsync;
  106180. /**
  106181. * Loads a file from database
  106182. * @param url defines the URL to load from
  106183. * @param sceneLoaded defines a callback to call on success
  106184. * @param progressCallBack defines a callback to call when progress changed
  106185. * @param errorCallback defines a callback to call on error
  106186. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  106187. */
  106188. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  106189. private _loadFileAsync;
  106190. private _saveFileAsync;
  106191. /**
  106192. * Validates if xhr data is correct
  106193. * @param xhr defines the request to validate
  106194. * @param dataType defines the expected data type
  106195. * @returns true if data is correct
  106196. */
  106197. private static _ValidateXHRData;
  106198. }
  106199. }
  106200. declare module BABYLON {
  106201. /** @hidden */
  106202. export var gpuUpdateParticlesPixelShader: {
  106203. name: string;
  106204. shader: string;
  106205. };
  106206. }
  106207. declare module BABYLON {
  106208. /** @hidden */
  106209. export var gpuUpdateParticlesVertexShader: {
  106210. name: string;
  106211. shader: string;
  106212. };
  106213. }
  106214. declare module BABYLON {
  106215. /** @hidden */
  106216. export var clipPlaneFragmentDeclaration2: {
  106217. name: string;
  106218. shader: string;
  106219. };
  106220. }
  106221. declare module BABYLON {
  106222. /** @hidden */
  106223. export var gpuRenderParticlesPixelShader: {
  106224. name: string;
  106225. shader: string;
  106226. };
  106227. }
  106228. declare module BABYLON {
  106229. /** @hidden */
  106230. export var clipPlaneVertexDeclaration2: {
  106231. name: string;
  106232. shader: string;
  106233. };
  106234. }
  106235. declare module BABYLON {
  106236. /** @hidden */
  106237. export var gpuRenderParticlesVertexShader: {
  106238. name: string;
  106239. shader: string;
  106240. };
  106241. }
  106242. declare module BABYLON {
  106243. /**
  106244. * This represents a GPU particle system in Babylon
  106245. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  106246. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  106247. */
  106248. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  106249. /**
  106250. * The layer mask we are rendering the particles through.
  106251. */
  106252. layerMask: number;
  106253. private _capacity;
  106254. private _activeCount;
  106255. private _currentActiveCount;
  106256. private _accumulatedCount;
  106257. private _renderEffect;
  106258. private _updateEffect;
  106259. private _buffer0;
  106260. private _buffer1;
  106261. private _spriteBuffer;
  106262. private _updateVAO;
  106263. private _renderVAO;
  106264. private _targetIndex;
  106265. private _sourceBuffer;
  106266. private _targetBuffer;
  106267. private _engine;
  106268. private _currentRenderId;
  106269. private _started;
  106270. private _stopped;
  106271. private _timeDelta;
  106272. private _randomTexture;
  106273. private _randomTexture2;
  106274. private _attributesStrideSize;
  106275. private _updateEffectOptions;
  106276. private _randomTextureSize;
  106277. private _actualFrame;
  106278. private readonly _rawTextureWidth;
  106279. /**
  106280. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  106281. */
  106282. static readonly IsSupported: boolean;
  106283. /**
  106284. * An event triggered when the system is disposed.
  106285. */
  106286. onDisposeObservable: Observable<GPUParticleSystem>;
  106287. /**
  106288. * Gets the maximum number of particles active at the same time.
  106289. * @returns The max number of active particles.
  106290. */
  106291. getCapacity(): number;
  106292. /**
  106293. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  106294. * to override the particles.
  106295. */
  106296. forceDepthWrite: boolean;
  106297. /**
  106298. * Gets or set the number of active particles
  106299. */
  106300. activeParticleCount: number;
  106301. private _preWarmDone;
  106302. /**
  106303. * Is this system ready to be used/rendered
  106304. * @return true if the system is ready
  106305. */
  106306. isReady(): boolean;
  106307. /**
  106308. * Gets if the system has been started. (Note: this will still be true after stop is called)
  106309. * @returns True if it has been started, otherwise false.
  106310. */
  106311. isStarted(): boolean;
  106312. /**
  106313. * Starts the particle system and begins to emit
  106314. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  106315. */
  106316. start(delay?: number): void;
  106317. /**
  106318. * Stops the particle system.
  106319. */
  106320. stop(): void;
  106321. /**
  106322. * Remove all active particles
  106323. */
  106324. reset(): void;
  106325. /**
  106326. * Returns the string "GPUParticleSystem"
  106327. * @returns a string containing the class name
  106328. */
  106329. getClassName(): string;
  106330. private _colorGradientsTexture;
  106331. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  106332. /**
  106333. * Adds a new color gradient
  106334. * @param gradient defines the gradient to use (between 0 and 1)
  106335. * @param color1 defines the color to affect to the specified gradient
  106336. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  106337. * @returns the current particle system
  106338. */
  106339. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  106340. /**
  106341. * Remove a specific color gradient
  106342. * @param gradient defines the gradient to remove
  106343. * @returns the current particle system
  106344. */
  106345. removeColorGradient(gradient: number): GPUParticleSystem;
  106346. private _angularSpeedGradientsTexture;
  106347. private _sizeGradientsTexture;
  106348. private _velocityGradientsTexture;
  106349. private _limitVelocityGradientsTexture;
  106350. private _dragGradientsTexture;
  106351. private _addFactorGradient;
  106352. /**
  106353. * Adds a new size gradient
  106354. * @param gradient defines the gradient to use (between 0 and 1)
  106355. * @param factor defines the size factor to affect to the specified gradient
  106356. * @returns the current particle system
  106357. */
  106358. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  106359. /**
  106360. * Remove a specific size gradient
  106361. * @param gradient defines the gradient to remove
  106362. * @returns the current particle system
  106363. */
  106364. removeSizeGradient(gradient: number): GPUParticleSystem;
  106365. /**
  106366. * Adds a new angular speed gradient
  106367. * @param gradient defines the gradient to use (between 0 and 1)
  106368. * @param factor defines the angular speed to affect to the specified gradient
  106369. * @returns the current particle system
  106370. */
  106371. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  106372. /**
  106373. * Remove a specific angular speed gradient
  106374. * @param gradient defines the gradient to remove
  106375. * @returns the current particle system
  106376. */
  106377. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  106378. /**
  106379. * Adds a new velocity gradient
  106380. * @param gradient defines the gradient to use (between 0 and 1)
  106381. * @param factor defines the velocity to affect to the specified gradient
  106382. * @returns the current particle system
  106383. */
  106384. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106385. /**
  106386. * Remove a specific velocity gradient
  106387. * @param gradient defines the gradient to remove
  106388. * @returns the current particle system
  106389. */
  106390. removeVelocityGradient(gradient: number): GPUParticleSystem;
  106391. /**
  106392. * Adds a new limit velocity gradient
  106393. * @param gradient defines the gradient to use (between 0 and 1)
  106394. * @param factor defines the limit velocity value to affect to the specified gradient
  106395. * @returns the current particle system
  106396. */
  106397. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106398. /**
  106399. * Remove a specific limit velocity gradient
  106400. * @param gradient defines the gradient to remove
  106401. * @returns the current particle system
  106402. */
  106403. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  106404. /**
  106405. * Adds a new drag gradient
  106406. * @param gradient defines the gradient to use (between 0 and 1)
  106407. * @param factor defines the drag value to affect to the specified gradient
  106408. * @returns the current particle system
  106409. */
  106410. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  106411. /**
  106412. * Remove a specific drag gradient
  106413. * @param gradient defines the gradient to remove
  106414. * @returns the current particle system
  106415. */
  106416. removeDragGradient(gradient: number): GPUParticleSystem;
  106417. /**
  106418. * Not supported by GPUParticleSystem
  106419. * @param gradient defines the gradient to use (between 0 and 1)
  106420. * @param factor defines the emit rate value to affect to the specified gradient
  106421. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106422. * @returns the current particle system
  106423. */
  106424. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106425. /**
  106426. * Not supported by GPUParticleSystem
  106427. * @param gradient defines the gradient to remove
  106428. * @returns the current particle system
  106429. */
  106430. removeEmitRateGradient(gradient: number): IParticleSystem;
  106431. /**
  106432. * Not supported by GPUParticleSystem
  106433. * @param gradient defines the gradient to use (between 0 and 1)
  106434. * @param factor defines the start size value to affect to the specified gradient
  106435. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106436. * @returns the current particle system
  106437. */
  106438. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106439. /**
  106440. * Not supported by GPUParticleSystem
  106441. * @param gradient defines the gradient to remove
  106442. * @returns the current particle system
  106443. */
  106444. removeStartSizeGradient(gradient: number): IParticleSystem;
  106445. /**
  106446. * Not supported by GPUParticleSystem
  106447. * @param gradient defines the gradient to use (between 0 and 1)
  106448. * @param min defines the color remap minimal range
  106449. * @param max defines the color remap maximal range
  106450. * @returns the current particle system
  106451. */
  106452. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  106453. /**
  106454. * Not supported by GPUParticleSystem
  106455. * @param gradient defines the gradient to remove
  106456. * @returns the current particle system
  106457. */
  106458. removeColorRemapGradient(): IParticleSystem;
  106459. /**
  106460. * Not supported by GPUParticleSystem
  106461. * @param gradient defines the gradient to use (between 0 and 1)
  106462. * @param min defines the alpha remap minimal range
  106463. * @param max defines the alpha remap maximal range
  106464. * @returns the current particle system
  106465. */
  106466. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  106467. /**
  106468. * Not supported by GPUParticleSystem
  106469. * @param gradient defines the gradient to remove
  106470. * @returns the current particle system
  106471. */
  106472. removeAlphaRemapGradient(): IParticleSystem;
  106473. /**
  106474. * Not supported by GPUParticleSystem
  106475. * @param gradient defines the gradient to use (between 0 and 1)
  106476. * @param color defines the color to affect to the specified gradient
  106477. * @returns the current particle system
  106478. */
  106479. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  106480. /**
  106481. * Not supported by GPUParticleSystem
  106482. * @param gradient defines the gradient to remove
  106483. * @returns the current particle system
  106484. */
  106485. removeRampGradient(): IParticleSystem;
  106486. /**
  106487. * Not supported by GPUParticleSystem
  106488. * @returns the list of ramp gradients
  106489. */
  106490. getRampGradients(): Nullable<Array<Color3Gradient>>;
  106491. /**
  106492. * Not supported by GPUParticleSystem
  106493. * Gets or sets a boolean indicating that ramp gradients must be used
  106494. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  106495. */
  106496. useRampGradients: boolean;
  106497. /**
  106498. * Not supported by GPUParticleSystem
  106499. * @param gradient defines the gradient to use (between 0 and 1)
  106500. * @param factor defines the life time factor to affect to the specified gradient
  106501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106502. * @returns the current particle system
  106503. */
  106504. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106505. /**
  106506. * Not supported by GPUParticleSystem
  106507. * @param gradient defines the gradient to remove
  106508. * @returns the current particle system
  106509. */
  106510. removeLifeTimeGradient(gradient: number): IParticleSystem;
  106511. /**
  106512. * Instantiates a GPU particle system.
  106513. * 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.
  106514. * @param name The name of the particle system
  106515. * @param options The options used to create the system
  106516. * @param scene The scene the particle system belongs to
  106517. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  106518. */
  106519. constructor(name: string, options: Partial<{
  106520. capacity: number;
  106521. randomTextureSize: number;
  106522. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  106523. protected _reset(): void;
  106524. private _createUpdateVAO;
  106525. private _createRenderVAO;
  106526. private _initialize;
  106527. /** @hidden */
  106528. _recreateUpdateEffect(): void;
  106529. /** @hidden */
  106530. _recreateRenderEffect(): void;
  106531. /**
  106532. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  106533. * @param preWarm defines if we are in the pre-warmimg phase
  106534. */
  106535. animate(preWarm?: boolean): void;
  106536. private _createFactorGradientTexture;
  106537. private _createSizeGradientTexture;
  106538. private _createAngularSpeedGradientTexture;
  106539. private _createVelocityGradientTexture;
  106540. private _createLimitVelocityGradientTexture;
  106541. private _createDragGradientTexture;
  106542. private _createColorGradientTexture;
  106543. /**
  106544. * Renders the particle system in its current state
  106545. * @param preWarm defines if the system should only update the particles but not render them
  106546. * @returns the current number of particles
  106547. */
  106548. render(preWarm?: boolean): number;
  106549. /**
  106550. * Rebuilds the particle system
  106551. */
  106552. rebuild(): void;
  106553. private _releaseBuffers;
  106554. private _releaseVAOs;
  106555. /**
  106556. * Disposes the particle system and free the associated resources
  106557. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  106558. */
  106559. dispose(disposeTexture?: boolean): void;
  106560. /**
  106561. * Clones the particle system.
  106562. * @param name The name of the cloned object
  106563. * @param newEmitter The new emitter to use
  106564. * @returns the cloned particle system
  106565. */
  106566. clone(name: string, newEmitter: any): GPUParticleSystem;
  106567. /**
  106568. * Serializes the particle system to a JSON object.
  106569. * @returns the JSON object
  106570. */
  106571. serialize(): any;
  106572. /**
  106573. * Parses a JSON object to create a GPU particle system.
  106574. * @param parsedParticleSystem The JSON object to parse
  106575. * @param scene The scene to create the particle system in
  106576. * @param rootUrl The root url to use to load external dependencies like texture
  106577. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  106578. * @returns the parsed GPU particle system
  106579. */
  106580. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  106581. }
  106582. }
  106583. declare module BABYLON {
  106584. /**
  106585. * Represents a set of particle systems working together to create a specific effect
  106586. */
  106587. export class ParticleSystemSet implements IDisposable {
  106588. private _emitterCreationOptions;
  106589. private _emitterNode;
  106590. /**
  106591. * Gets the particle system list
  106592. */
  106593. systems: IParticleSystem[];
  106594. /**
  106595. * Gets the emitter node used with this set
  106596. */
  106597. readonly emitterNode: Nullable<TransformNode>;
  106598. /**
  106599. * Creates a new emitter mesh as a sphere
  106600. * @param options defines the options used to create the sphere
  106601. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  106602. * @param scene defines the hosting scene
  106603. */
  106604. setEmitterAsSphere(options: {
  106605. diameter: number;
  106606. segments: number;
  106607. color: Color3;
  106608. }, renderingGroupId: number, scene: Scene): void;
  106609. /**
  106610. * Starts all particle systems of the set
  106611. * @param emitter defines an optional mesh to use as emitter for the particle systems
  106612. */
  106613. start(emitter?: AbstractMesh): void;
  106614. /**
  106615. * Release all associated resources
  106616. */
  106617. dispose(): void;
  106618. /**
  106619. * Serialize the set into a JSON compatible object
  106620. * @returns a JSON compatible representation of the set
  106621. */
  106622. serialize(): any;
  106623. /**
  106624. * Parse a new ParticleSystemSet from a serialized source
  106625. * @param data defines a JSON compatible representation of the set
  106626. * @param scene defines the hosting scene
  106627. * @param gpu defines if we want GPU particles or CPU particles
  106628. * @returns a new ParticleSystemSet
  106629. */
  106630. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  106631. }
  106632. }
  106633. declare module BABYLON {
  106634. /**
  106635. * This class is made for on one-liner static method to help creating particle system set.
  106636. */
  106637. export class ParticleHelper {
  106638. /**
  106639. * Gets or sets base Assets URL
  106640. */
  106641. static BaseAssetsUrl: string;
  106642. /**
  106643. * Create a default particle system that you can tweak
  106644. * @param emitter defines the emitter to use
  106645. * @param capacity defines the system capacity (default is 500 particles)
  106646. * @param scene defines the hosting scene
  106647. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  106648. * @returns the new Particle system
  106649. */
  106650. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  106651. /**
  106652. * This is the main static method (one-liner) of this helper to create different particle systems
  106653. * @param type This string represents the type to the particle system to create
  106654. * @param scene The scene where the particle system should live
  106655. * @param gpu If the system will use gpu
  106656. * @returns the ParticleSystemSet created
  106657. */
  106658. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  106659. /**
  106660. * Static function used to export a particle system to a ParticleSystemSet variable.
  106661. * Please note that the emitter shape is not exported
  106662. * @param systems defines the particle systems to export
  106663. * @returns the created particle system set
  106664. */
  106665. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  106666. }
  106667. }
  106668. declare module BABYLON {
  106669. interface Engine {
  106670. /**
  106671. * Create an effect to use with particle systems.
  106672. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  106673. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  106674. * @param uniformsNames defines a list of attribute names
  106675. * @param samplers defines an array of string used to represent textures
  106676. * @param defines defines the string containing the defines to use to compile the shaders
  106677. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  106678. * @param onCompiled defines a function to call when the effect creation is successful
  106679. * @param onError defines a function to call when the effect creation has failed
  106680. * @returns the new Effect
  106681. */
  106682. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  106683. }
  106684. interface Mesh {
  106685. /**
  106686. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  106687. * @returns an array of IParticleSystem
  106688. */
  106689. getEmittedParticleSystems(): IParticleSystem[];
  106690. /**
  106691. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  106692. * @returns an array of IParticleSystem
  106693. */
  106694. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  106695. }
  106696. /**
  106697. * @hidden
  106698. */
  106699. export var _IDoNeedToBeInTheBuild: number;
  106700. }
  106701. declare module BABYLON {
  106702. interface Scene {
  106703. /** @hidden (Backing field) */
  106704. _physicsEngine: Nullable<IPhysicsEngine>;
  106705. /**
  106706. * Gets the current physics engine
  106707. * @returns a IPhysicsEngine or null if none attached
  106708. */
  106709. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  106710. /**
  106711. * Enables physics to the current scene
  106712. * @param gravity defines the scene's gravity for the physics engine
  106713. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  106714. * @return a boolean indicating if the physics engine was initialized
  106715. */
  106716. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  106717. /**
  106718. * Disables and disposes the physics engine associated with the scene
  106719. */
  106720. disablePhysicsEngine(): void;
  106721. /**
  106722. * Gets a boolean indicating if there is an active physics engine
  106723. * @returns a boolean indicating if there is an active physics engine
  106724. */
  106725. isPhysicsEnabled(): boolean;
  106726. /**
  106727. * Deletes a physics compound impostor
  106728. * @param compound defines the compound to delete
  106729. */
  106730. deleteCompoundImpostor(compound: any): void;
  106731. /**
  106732. * An event triggered when physic simulation is about to be run
  106733. */
  106734. onBeforePhysicsObservable: Observable<Scene>;
  106735. /**
  106736. * An event triggered when physic simulation has been done
  106737. */
  106738. onAfterPhysicsObservable: Observable<Scene>;
  106739. }
  106740. interface AbstractMesh {
  106741. /** @hidden */
  106742. _physicsImpostor: Nullable<PhysicsImpostor>;
  106743. /**
  106744. * Gets or sets impostor used for physic simulation
  106745. * @see http://doc.babylonjs.com/features/physics_engine
  106746. */
  106747. physicsImpostor: Nullable<PhysicsImpostor>;
  106748. /**
  106749. * Gets the current physics impostor
  106750. * @see http://doc.babylonjs.com/features/physics_engine
  106751. * @returns a physics impostor or null
  106752. */
  106753. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  106754. /** Apply a physic impulse to the mesh
  106755. * @param force defines the force to apply
  106756. * @param contactPoint defines where to apply the force
  106757. * @returns the current mesh
  106758. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  106759. */
  106760. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  106761. /**
  106762. * Creates a physic joint between two meshes
  106763. * @param otherMesh defines the other mesh to use
  106764. * @param pivot1 defines the pivot to use on this mesh
  106765. * @param pivot2 defines the pivot to use on the other mesh
  106766. * @param options defines additional options (can be plugin dependent)
  106767. * @returns the current mesh
  106768. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  106769. */
  106770. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  106771. /** @hidden */
  106772. _disposePhysicsObserver: Nullable<Observer<Node>>;
  106773. }
  106774. /**
  106775. * Defines the physics engine scene component responsible to manage a physics engine
  106776. */
  106777. export class PhysicsEngineSceneComponent implements ISceneComponent {
  106778. /**
  106779. * The component name helpful to identify the component in the list of scene components.
  106780. */
  106781. readonly name: string;
  106782. /**
  106783. * The scene the component belongs to.
  106784. */
  106785. scene: Scene;
  106786. /**
  106787. * Creates a new instance of the component for the given scene
  106788. * @param scene Defines the scene to register the component in
  106789. */
  106790. constructor(scene: Scene);
  106791. /**
  106792. * Registers the component in a given scene
  106793. */
  106794. register(): void;
  106795. /**
  106796. * Rebuilds the elements related to this component in case of
  106797. * context lost for instance.
  106798. */
  106799. rebuild(): void;
  106800. /**
  106801. * Disposes the component and the associated ressources
  106802. */
  106803. dispose(): void;
  106804. }
  106805. }
  106806. declare module BABYLON {
  106807. /**
  106808. * A helper for physics simulations
  106809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106810. */
  106811. export class PhysicsHelper {
  106812. private _scene;
  106813. private _physicsEngine;
  106814. /**
  106815. * Initializes the Physics helper
  106816. * @param scene Babylon.js scene
  106817. */
  106818. constructor(scene: Scene);
  106819. /**
  106820. * Applies a radial explosion impulse
  106821. * @param origin the origin of the explosion
  106822. * @param radius the explosion radius
  106823. * @param strength the explosion strength
  106824. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106825. * @returns A physics radial explosion event, or null
  106826. */
  106827. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  106828. /**
  106829. * Applies a radial explosion force
  106830. * @param origin the origin of the explosion
  106831. * @param radius the explosion radius
  106832. * @param strength the explosion strength
  106833. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106834. * @returns A physics radial explosion event, or null
  106835. */
  106836. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  106837. /**
  106838. * Creates a gravitational field
  106839. * @param origin the origin of the explosion
  106840. * @param radius the explosion radius
  106841. * @param strength the explosion strength
  106842. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106843. * @returns A physics gravitational field event, or null
  106844. */
  106845. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  106846. /**
  106847. * Creates a physics updraft event
  106848. * @param origin the origin of the updraft
  106849. * @param radius the radius of the updraft
  106850. * @param strength the strength of the updraft
  106851. * @param height the height of the updraft
  106852. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  106853. * @returns A physics updraft event, or null
  106854. */
  106855. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  106856. /**
  106857. * Creates a physics vortex event
  106858. * @param origin the of the vortex
  106859. * @param radius the radius of the vortex
  106860. * @param strength the strength of the vortex
  106861. * @param height the height of the vortex
  106862. * @returns a Physics vortex event, or null
  106863. * A physics vortex event or null
  106864. */
  106865. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  106866. }
  106867. /**
  106868. * Represents a physics radial explosion event
  106869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106870. */
  106871. export class PhysicsRadialExplosionEvent {
  106872. private _scene;
  106873. private _sphere;
  106874. private _sphereOptions;
  106875. private _rays;
  106876. private _dataFetched;
  106877. /**
  106878. * Initializes a radial explosioin event
  106879. * @param scene BabylonJS scene
  106880. */
  106881. constructor(scene: Scene);
  106882. /**
  106883. * Returns the data related to the radial explosion event (sphere & rays).
  106884. * @returns The radial explosion event data
  106885. */
  106886. getData(): PhysicsRadialExplosionEventData;
  106887. /**
  106888. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  106889. * @param impostor A physics imposter
  106890. * @param origin the origin of the explosion
  106891. * @param radius the explosion radius
  106892. * @param strength the explosion strength
  106893. * @param falloff possible options: Constant & Linear
  106894. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  106895. */
  106896. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  106897. /**
  106898. * Disposes the sphere.
  106899. * @param force Specifies if the sphere should be disposed by force
  106900. */
  106901. dispose(force?: boolean): void;
  106902. /*** Helpers ***/
  106903. private _prepareSphere;
  106904. private _intersectsWithSphere;
  106905. }
  106906. /**
  106907. * Represents a gravitational field event
  106908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106909. */
  106910. export class PhysicsGravitationalFieldEvent {
  106911. private _physicsHelper;
  106912. private _scene;
  106913. private _origin;
  106914. private _radius;
  106915. private _strength;
  106916. private _falloff;
  106917. private _tickCallback;
  106918. private _sphere;
  106919. private _dataFetched;
  106920. /**
  106921. * Initializes the physics gravitational field event
  106922. * @param physicsHelper A physics helper
  106923. * @param scene BabylonJS scene
  106924. * @param origin The origin position of the gravitational field event
  106925. * @param radius The radius of the gravitational field event
  106926. * @param strength The strength of the gravitational field event
  106927. * @param falloff The falloff for the gravitational field event
  106928. */
  106929. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  106930. /**
  106931. * Returns the data related to the gravitational field event (sphere).
  106932. * @returns A gravitational field event
  106933. */
  106934. getData(): PhysicsGravitationalFieldEventData;
  106935. /**
  106936. * Enables the gravitational field.
  106937. */
  106938. enable(): void;
  106939. /**
  106940. * Disables the gravitational field.
  106941. */
  106942. disable(): void;
  106943. /**
  106944. * Disposes the sphere.
  106945. * @param force The force to dispose from the gravitational field event
  106946. */
  106947. dispose(force?: boolean): void;
  106948. private _tick;
  106949. }
  106950. /**
  106951. * Represents a physics updraft event
  106952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106953. */
  106954. export class PhysicsUpdraftEvent {
  106955. private _scene;
  106956. private _origin;
  106957. private _radius;
  106958. private _strength;
  106959. private _height;
  106960. private _updraftMode;
  106961. private _physicsEngine;
  106962. private _originTop;
  106963. private _originDirection;
  106964. private _tickCallback;
  106965. private _cylinder;
  106966. private _cylinderPosition;
  106967. private _dataFetched;
  106968. /**
  106969. * Initializes the physics updraft event
  106970. * @param _scene BabylonJS scene
  106971. * @param _origin The origin position of the updraft
  106972. * @param _radius The radius of the updraft
  106973. * @param _strength The strength of the updraft
  106974. * @param _height The height of the updraft
  106975. * @param _updraftMode The mode of the updraft
  106976. */
  106977. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  106978. /**
  106979. * Returns the data related to the updraft event (cylinder).
  106980. * @returns A physics updraft event
  106981. */
  106982. getData(): PhysicsUpdraftEventData;
  106983. /**
  106984. * Enables the updraft.
  106985. */
  106986. enable(): void;
  106987. /**
  106988. * Disables the cortex.
  106989. */
  106990. disable(): void;
  106991. /**
  106992. * Disposes the sphere.
  106993. * @param force Specifies if the updraft should be disposed by force
  106994. */
  106995. dispose(force?: boolean): void;
  106996. private getImpostorForceAndContactPoint;
  106997. private _tick;
  106998. /*** Helpers ***/
  106999. private _prepareCylinder;
  107000. private _intersectsWithCylinder;
  107001. }
  107002. /**
  107003. * Represents a physics vortex event
  107004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107005. */
  107006. export class PhysicsVortexEvent {
  107007. private _scene;
  107008. private _origin;
  107009. private _radius;
  107010. private _strength;
  107011. private _height;
  107012. private _physicsEngine;
  107013. private _originTop;
  107014. private _centripetalForceThreshold;
  107015. private _updraftMultiplier;
  107016. private _tickCallback;
  107017. private _cylinder;
  107018. private _cylinderPosition;
  107019. private _dataFetched;
  107020. /**
  107021. * Initializes the physics vortex event
  107022. * @param _scene The BabylonJS scene
  107023. * @param _origin The origin position of the vortex
  107024. * @param _radius The radius of the vortex
  107025. * @param _strength The strength of the vortex
  107026. * @param _height The height of the vortex
  107027. */
  107028. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  107029. /**
  107030. * Returns the data related to the vortex event (cylinder).
  107031. * @returns The physics vortex event data
  107032. */
  107033. getData(): PhysicsVortexEventData;
  107034. /**
  107035. * Enables the vortex.
  107036. */
  107037. enable(): void;
  107038. /**
  107039. * Disables the cortex.
  107040. */
  107041. disable(): void;
  107042. /**
  107043. * Disposes the sphere.
  107044. * @param force
  107045. */
  107046. dispose(force?: boolean): void;
  107047. private getImpostorForceAndContactPoint;
  107048. private _tick;
  107049. /*** Helpers ***/
  107050. private _prepareCylinder;
  107051. private _intersectsWithCylinder;
  107052. }
  107053. /**
  107054. * The strenght of the force in correspondence to the distance of the affected object
  107055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107056. */
  107057. export enum PhysicsRadialImpulseFalloff {
  107058. /** Defines that impulse is constant in strength across it's whole radius */
  107059. Constant = 0,
  107060. /** DEfines that impulse gets weaker if it's further from the origin */
  107061. Linear = 1
  107062. }
  107063. /**
  107064. * The strength of the force in correspondence to the distance of the affected object
  107065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107066. */
  107067. export enum PhysicsUpdraftMode {
  107068. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  107069. Center = 0,
  107070. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  107071. Perpendicular = 1
  107072. }
  107073. /**
  107074. * Interface for a physics force and contact point
  107075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107076. */
  107077. export interface PhysicsForceAndContactPoint {
  107078. /**
  107079. * The force applied at the contact point
  107080. */
  107081. force: Vector3;
  107082. /**
  107083. * The contact point
  107084. */
  107085. contactPoint: Vector3;
  107086. }
  107087. /**
  107088. * Interface for radial explosion event data
  107089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107090. */
  107091. export interface PhysicsRadialExplosionEventData {
  107092. /**
  107093. * A sphere used for the radial explosion event
  107094. */
  107095. sphere: Mesh;
  107096. /**
  107097. * An array of rays for the radial explosion event
  107098. */
  107099. rays: Array<Ray>;
  107100. }
  107101. /**
  107102. * Interface for gravitational field event data
  107103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107104. */
  107105. export interface PhysicsGravitationalFieldEventData {
  107106. /**
  107107. * A sphere mesh used for the gravitational field event
  107108. */
  107109. sphere: Mesh;
  107110. }
  107111. /**
  107112. * Interface for updraft event data
  107113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107114. */
  107115. export interface PhysicsUpdraftEventData {
  107116. /**
  107117. * A cylinder used for the updraft event
  107118. */
  107119. cylinder: Mesh;
  107120. }
  107121. /**
  107122. * Interface for vortex event data
  107123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107124. */
  107125. export interface PhysicsVortexEventData {
  107126. /**
  107127. * A cylinder used for the vortex event
  107128. */
  107129. cylinder: Mesh;
  107130. }
  107131. }
  107132. declare module BABYLON {
  107133. /**
  107134. * AmmoJS Physics plugin
  107135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107136. * @see https://github.com/kripken/ammo.js/
  107137. */
  107138. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107139. private _useDeltaForWorldStep;
  107140. /**
  107141. * Reference to the Ammo library
  107142. */
  107143. bjsAMMO: any;
  107144. /**
  107145. * Created ammoJS world which physics bodies are added to
  107146. */
  107147. world: any;
  107148. /**
  107149. * Name of the plugin
  107150. */
  107151. name: string;
  107152. private _timeStep;
  107153. private _fixedTimeStep;
  107154. private _maxSteps;
  107155. private _tmpQuaternion;
  107156. private _tmpAmmoTransform;
  107157. private _tmpAmmoQuaternion;
  107158. private _tmpAmmoConcreteContactResultCallback;
  107159. private _collisionConfiguration;
  107160. private _dispatcher;
  107161. private _overlappingPairCache;
  107162. private _solver;
  107163. private _tmpAmmoVectorA;
  107164. private _tmpAmmoVectorB;
  107165. private _tmpAmmoVectorC;
  107166. private _tmpContactCallbackResult;
  107167. private static readonly DISABLE_COLLISION_FLAG;
  107168. private static readonly KINEMATIC_FLAG;
  107169. private static readonly DISABLE_DEACTIVATION_FLAG;
  107170. /**
  107171. * Initializes the ammoJS plugin
  107172. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107173. * @param ammoInjection can be used to inject your own ammo reference
  107174. */
  107175. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107176. /**
  107177. * Sets the gravity of the physics world (m/(s^2))
  107178. * @param gravity Gravity to set
  107179. */
  107180. setGravity(gravity: Vector3): void;
  107181. /**
  107182. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107183. * @param timeStep timestep to use in seconds
  107184. */
  107185. setTimeStep(timeStep: number): void;
  107186. /**
  107187. * 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)
  107188. * @param fixedTimeStep fixedTimeStep to use in seconds
  107189. */
  107190. setFixedTimeStep(fixedTimeStep: number): void;
  107191. /**
  107192. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107193. * @param maxSteps the maximum number of steps by the physics engine per frame
  107194. */
  107195. setMaxSteps(maxSteps: number): void;
  107196. /**
  107197. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107198. * @returns the current timestep in seconds
  107199. */
  107200. getTimeStep(): number;
  107201. private _isImpostorInContact;
  107202. private _isImpostorPairInContact;
  107203. private _stepSimulation;
  107204. /**
  107205. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107206. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107207. * After the step the babylon meshes are set to the position of the physics imposters
  107208. * @param delta amount of time to step forward
  107209. * @param impostors array of imposters to update before/after the step
  107210. */
  107211. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107212. private _tmpVector;
  107213. private _tmpMatrix;
  107214. /**
  107215. * Applies an implulse on the imposter
  107216. * @param impostor imposter to apply impulse
  107217. * @param force amount of force to be applied to the imposter
  107218. * @param contactPoint the location to apply the impulse on the imposter
  107219. */
  107220. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107221. /**
  107222. * Applies a force on the imposter
  107223. * @param impostor imposter to apply force
  107224. * @param force amount of force to be applied to the imposter
  107225. * @param contactPoint the location to apply the force on the imposter
  107226. */
  107227. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107228. /**
  107229. * Creates a physics body using the plugin
  107230. * @param impostor the imposter to create the physics body on
  107231. */
  107232. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107233. /**
  107234. * Removes the physics body from the imposter and disposes of the body's memory
  107235. * @param impostor imposter to remove the physics body from
  107236. */
  107237. removePhysicsBody(impostor: PhysicsImpostor): void;
  107238. /**
  107239. * Generates a joint
  107240. * @param impostorJoint the imposter joint to create the joint with
  107241. */
  107242. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107243. /**
  107244. * Removes a joint
  107245. * @param impostorJoint the imposter joint to remove the joint from
  107246. */
  107247. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107248. private _addMeshVerts;
  107249. private _createShape;
  107250. /**
  107251. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107252. * @param impostor imposter containing the physics body and babylon object
  107253. */
  107254. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107255. /**
  107256. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107257. * @param impostor imposter containing the physics body and babylon object
  107258. * @param newPosition new position
  107259. * @param newRotation new rotation
  107260. */
  107261. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107262. /**
  107263. * If this plugin is supported
  107264. * @returns true if its supported
  107265. */
  107266. isSupported(): boolean;
  107267. /**
  107268. * Sets the linear velocity of the physics body
  107269. * @param impostor imposter to set the velocity on
  107270. * @param velocity velocity to set
  107271. */
  107272. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107273. /**
  107274. * Sets the angular velocity of the physics body
  107275. * @param impostor imposter to set the velocity on
  107276. * @param velocity velocity to set
  107277. */
  107278. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107279. /**
  107280. * gets the linear velocity
  107281. * @param impostor imposter to get linear velocity from
  107282. * @returns linear velocity
  107283. */
  107284. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107285. /**
  107286. * gets the angular velocity
  107287. * @param impostor imposter to get angular velocity from
  107288. * @returns angular velocity
  107289. */
  107290. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107291. /**
  107292. * Sets the mass of physics body
  107293. * @param impostor imposter to set the mass on
  107294. * @param mass mass to set
  107295. */
  107296. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107297. /**
  107298. * Gets the mass of the physics body
  107299. * @param impostor imposter to get the mass from
  107300. * @returns mass
  107301. */
  107302. getBodyMass(impostor: PhysicsImpostor): number;
  107303. /**
  107304. * Gets friction of the impostor
  107305. * @param impostor impostor to get friction from
  107306. * @returns friction value
  107307. */
  107308. getBodyFriction(impostor: PhysicsImpostor): number;
  107309. /**
  107310. * Sets friction of the impostor
  107311. * @param impostor impostor to set friction on
  107312. * @param friction friction value
  107313. */
  107314. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107315. /**
  107316. * Gets restitution of the impostor
  107317. * @param impostor impostor to get restitution from
  107318. * @returns restitution value
  107319. */
  107320. getBodyRestitution(impostor: PhysicsImpostor): number;
  107321. /**
  107322. * Sets resitution of the impostor
  107323. * @param impostor impostor to set resitution on
  107324. * @param restitution resitution value
  107325. */
  107326. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107327. /**
  107328. * Sleeps the physics body and stops it from being active
  107329. * @param impostor impostor to sleep
  107330. */
  107331. sleepBody(impostor: PhysicsImpostor): void;
  107332. /**
  107333. * Activates the physics body
  107334. * @param impostor impostor to activate
  107335. */
  107336. wakeUpBody(impostor: PhysicsImpostor): void;
  107337. /**
  107338. * Updates the distance parameters of the joint
  107339. * @param joint joint to update
  107340. * @param maxDistance maximum distance of the joint
  107341. * @param minDistance minimum distance of the joint
  107342. */
  107343. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107344. /**
  107345. * Sets a motor on the joint
  107346. * @param joint joint to set motor on
  107347. * @param speed speed of the motor
  107348. * @param maxForce maximum force of the motor
  107349. * @param motorIndex index of the motor
  107350. */
  107351. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107352. /**
  107353. * Sets the motors limit
  107354. * @param joint joint to set limit on
  107355. * @param upperLimit upper limit
  107356. * @param lowerLimit lower limit
  107357. */
  107358. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107359. /**
  107360. * Syncs the position and rotation of a mesh with the impostor
  107361. * @param mesh mesh to sync
  107362. * @param impostor impostor to update the mesh with
  107363. */
  107364. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107365. /**
  107366. * Gets the radius of the impostor
  107367. * @param impostor impostor to get radius from
  107368. * @returns the radius
  107369. */
  107370. getRadius(impostor: PhysicsImpostor): number;
  107371. /**
  107372. * Gets the box size of the impostor
  107373. * @param impostor impostor to get box size from
  107374. * @param result the resulting box size
  107375. */
  107376. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107377. /**
  107378. * Disposes of the impostor
  107379. */
  107380. dispose(): void;
  107381. }
  107382. }
  107383. declare module BABYLON {
  107384. /** @hidden */
  107385. export var blackAndWhitePixelShader: {
  107386. name: string;
  107387. shader: string;
  107388. };
  107389. }
  107390. declare module BABYLON {
  107391. /**
  107392. * Post process used to render in black and white
  107393. */
  107394. export class BlackAndWhitePostProcess extends PostProcess {
  107395. /**
  107396. * Linear about to convert he result to black and white (default: 1)
  107397. */
  107398. degree: number;
  107399. /**
  107400. * Creates a black and white post process
  107401. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  107402. * @param name The name of the effect.
  107403. * @param options The required width/height ratio to downsize to before computing the render pass.
  107404. * @param camera The camera to apply the render pass to.
  107405. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107406. * @param engine The engine which the post process will be applied. (default: current engine)
  107407. * @param reusable If the post process can be reused on the same frame. (default: false)
  107408. */
  107409. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107410. }
  107411. }
  107412. declare module BABYLON {
  107413. /**
  107414. * This represents a set of one or more post processes in Babylon.
  107415. * A post process can be used to apply a shader to a texture after it is rendered.
  107416. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107417. */
  107418. export class PostProcessRenderEffect {
  107419. private _postProcesses;
  107420. private _getPostProcesses;
  107421. private _singleInstance;
  107422. private _cameras;
  107423. private _indicesForCamera;
  107424. /**
  107425. * Name of the effect
  107426. * @hidden
  107427. */
  107428. _name: string;
  107429. /**
  107430. * Instantiates a post process render effect.
  107431. * A post process can be used to apply a shader to a texture after it is rendered.
  107432. * @param engine The engine the effect is tied to
  107433. * @param name The name of the effect
  107434. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  107435. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  107436. */
  107437. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  107438. /**
  107439. * Checks if all the post processes in the effect are supported.
  107440. */
  107441. readonly isSupported: boolean;
  107442. /**
  107443. * Updates the current state of the effect
  107444. * @hidden
  107445. */
  107446. _update(): void;
  107447. /**
  107448. * Attaches the effect on cameras
  107449. * @param cameras The camera to attach to.
  107450. * @hidden
  107451. */
  107452. _attachCameras(cameras: Camera): void;
  107453. /**
  107454. * Attaches the effect on cameras
  107455. * @param cameras The camera to attach to.
  107456. * @hidden
  107457. */
  107458. _attachCameras(cameras: Camera[]): void;
  107459. /**
  107460. * Detatches the effect on cameras
  107461. * @param cameras The camera to detatch from.
  107462. * @hidden
  107463. */
  107464. _detachCameras(cameras: Camera): void;
  107465. /**
  107466. * Detatches the effect on cameras
  107467. * @param cameras The camera to detatch from.
  107468. * @hidden
  107469. */
  107470. _detachCameras(cameras: Camera[]): void;
  107471. /**
  107472. * Enables the effect on given cameras
  107473. * @param cameras The camera to enable.
  107474. * @hidden
  107475. */
  107476. _enable(cameras: Camera): void;
  107477. /**
  107478. * Enables the effect on given cameras
  107479. * @param cameras The camera to enable.
  107480. * @hidden
  107481. */
  107482. _enable(cameras: Nullable<Camera[]>): void;
  107483. /**
  107484. * Disables the effect on the given cameras
  107485. * @param cameras The camera to disable.
  107486. * @hidden
  107487. */
  107488. _disable(cameras: Camera): void;
  107489. /**
  107490. * Disables the effect on the given cameras
  107491. * @param cameras The camera to disable.
  107492. * @hidden
  107493. */
  107494. _disable(cameras: Nullable<Camera[]>): void;
  107495. /**
  107496. * Gets a list of the post processes contained in the effect.
  107497. * @param camera The camera to get the post processes on.
  107498. * @returns The list of the post processes in the effect.
  107499. */
  107500. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  107501. }
  107502. }
  107503. declare module BABYLON {
  107504. /** @hidden */
  107505. export var extractHighlightsPixelShader: {
  107506. name: string;
  107507. shader: string;
  107508. };
  107509. }
  107510. declare module BABYLON {
  107511. /**
  107512. * 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.
  107513. */
  107514. export class ExtractHighlightsPostProcess extends PostProcess {
  107515. /**
  107516. * The luminance threshold, pixels below this value will be set to black.
  107517. */
  107518. threshold: number;
  107519. /** @hidden */
  107520. _exposure: number;
  107521. /**
  107522. * Post process which has the input texture to be used when performing highlight extraction
  107523. * @hidden
  107524. */
  107525. _inputPostProcess: Nullable<PostProcess>;
  107526. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107527. }
  107528. }
  107529. declare module BABYLON {
  107530. /** @hidden */
  107531. export var bloomMergePixelShader: {
  107532. name: string;
  107533. shader: string;
  107534. };
  107535. }
  107536. declare module BABYLON {
  107537. /**
  107538. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  107539. */
  107540. export class BloomMergePostProcess extends PostProcess {
  107541. /** Weight of the bloom to be added to the original input. */
  107542. weight: number;
  107543. /**
  107544. * Creates a new instance of @see BloomMergePostProcess
  107545. * @param name The name of the effect.
  107546. * @param originalFromInput Post process which's input will be used for the merge.
  107547. * @param blurred Blurred highlights post process which's output will be used.
  107548. * @param weight Weight of the bloom to be added to the original input.
  107549. * @param options The required width/height ratio to downsize to before computing the render pass.
  107550. * @param camera The camera to apply the render pass to.
  107551. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107552. * @param engine The engine which the post process will be applied. (default: current engine)
  107553. * @param reusable If the post process can be reused on the same frame. (default: false)
  107554. * @param textureType Type of textures used when performing the post process. (default: 0)
  107555. * @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)
  107556. */
  107557. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  107558. /** Weight of the bloom to be added to the original input. */
  107559. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107560. }
  107561. }
  107562. declare module BABYLON {
  107563. /**
  107564. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  107565. */
  107566. export class BloomEffect extends PostProcessRenderEffect {
  107567. private bloomScale;
  107568. /**
  107569. * @hidden Internal
  107570. */
  107571. _effects: Array<PostProcess>;
  107572. /**
  107573. * @hidden Internal
  107574. */
  107575. _downscale: ExtractHighlightsPostProcess;
  107576. private _blurX;
  107577. private _blurY;
  107578. private _merge;
  107579. /**
  107580. * The luminance threshold to find bright areas of the image to bloom.
  107581. */
  107582. threshold: number;
  107583. /**
  107584. * The strength of the bloom.
  107585. */
  107586. weight: number;
  107587. /**
  107588. * Specifies the size of the bloom blur kernel, relative to the final output size
  107589. */
  107590. kernel: number;
  107591. /**
  107592. * Creates a new instance of @see BloomEffect
  107593. * @param scene The scene the effect belongs to.
  107594. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  107595. * @param bloomKernel The size of the kernel to be used when applying the blur.
  107596. * @param bloomWeight The the strength of bloom.
  107597. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  107598. * @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)
  107599. */
  107600. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  107601. /**
  107602. * Disposes each of the internal effects for a given camera.
  107603. * @param camera The camera to dispose the effect on.
  107604. */
  107605. disposeEffects(camera: Camera): void;
  107606. /**
  107607. * @hidden Internal
  107608. */
  107609. _updateEffects(): void;
  107610. /**
  107611. * Internal
  107612. * @returns if all the contained post processes are ready.
  107613. * @hidden
  107614. */
  107615. _isReady(): boolean;
  107616. }
  107617. }
  107618. declare module BABYLON {
  107619. /** @hidden */
  107620. export var chromaticAberrationPixelShader: {
  107621. name: string;
  107622. shader: string;
  107623. };
  107624. }
  107625. declare module BABYLON {
  107626. /**
  107627. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  107628. */
  107629. export class ChromaticAberrationPostProcess extends PostProcess {
  107630. /**
  107631. * The amount of seperation of rgb channels (default: 30)
  107632. */
  107633. aberrationAmount: number;
  107634. /**
  107635. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  107636. */
  107637. radialIntensity: number;
  107638. /**
  107639. * 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))
  107640. */
  107641. direction: Vector2;
  107642. /**
  107643. * 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))
  107644. */
  107645. centerPosition: Vector2;
  107646. /**
  107647. * Creates a new instance ChromaticAberrationPostProcess
  107648. * @param name The name of the effect.
  107649. * @param screenWidth The width of the screen to apply the effect on.
  107650. * @param screenHeight The height of the screen to apply the effect on.
  107651. * @param options The required width/height ratio to downsize to before computing the render pass.
  107652. * @param camera The camera to apply the render pass to.
  107653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107654. * @param engine The engine which the post process will be applied. (default: current engine)
  107655. * @param reusable If the post process can be reused on the same frame. (default: false)
  107656. * @param textureType Type of textures used when performing the post process. (default: 0)
  107657. * @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)
  107658. */
  107659. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107660. }
  107661. }
  107662. declare module BABYLON {
  107663. /** @hidden */
  107664. export var circleOfConfusionPixelShader: {
  107665. name: string;
  107666. shader: string;
  107667. };
  107668. }
  107669. declare module BABYLON {
  107670. /**
  107671. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  107672. */
  107673. export class CircleOfConfusionPostProcess extends PostProcess {
  107674. /**
  107675. * 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.
  107676. */
  107677. lensSize: number;
  107678. /**
  107679. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  107680. */
  107681. fStop: number;
  107682. /**
  107683. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  107684. */
  107685. focusDistance: number;
  107686. /**
  107687. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  107688. */
  107689. focalLength: number;
  107690. private _depthTexture;
  107691. /**
  107692. * Creates a new instance CircleOfConfusionPostProcess
  107693. * @param name The name of the effect.
  107694. * @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.
  107695. * @param options The required width/height ratio to downsize to before computing the render pass.
  107696. * @param camera The camera to apply the render pass to.
  107697. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107698. * @param engine The engine which the post process will be applied. (default: current engine)
  107699. * @param reusable If the post process can be reused on the same frame. (default: false)
  107700. * @param textureType Type of textures used when performing the post process. (default: 0)
  107701. * @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)
  107702. */
  107703. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107704. /**
  107705. * 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.
  107706. */
  107707. depthTexture: RenderTargetTexture;
  107708. }
  107709. }
  107710. declare module BABYLON {
  107711. /** @hidden */
  107712. export var colorCorrectionPixelShader: {
  107713. name: string;
  107714. shader: string;
  107715. };
  107716. }
  107717. declare module BABYLON {
  107718. /**
  107719. *
  107720. * This post-process allows the modification of rendered colors by using
  107721. * a 'look-up table' (LUT). This effect is also called Color Grading.
  107722. *
  107723. * The object needs to be provided an url to a texture containing the color
  107724. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  107725. * Use an image editing software to tweak the LUT to match your needs.
  107726. *
  107727. * For an example of a color LUT, see here:
  107728. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  107729. * For explanations on color grading, see here:
  107730. * @see http://udn.epicgames.com/Three/ColorGrading.html
  107731. *
  107732. */
  107733. export class ColorCorrectionPostProcess extends PostProcess {
  107734. private _colorTableTexture;
  107735. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107736. }
  107737. }
  107738. declare module BABYLON {
  107739. /** @hidden */
  107740. export var convolutionPixelShader: {
  107741. name: string;
  107742. shader: string;
  107743. };
  107744. }
  107745. declare module BABYLON {
  107746. /**
  107747. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  107748. * input texture to perform effects such as edge detection or sharpening
  107749. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  107750. */
  107751. export class ConvolutionPostProcess extends PostProcess {
  107752. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  107753. kernel: number[];
  107754. /**
  107755. * Creates a new instance ConvolutionPostProcess
  107756. * @param name The name of the effect.
  107757. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  107758. * @param options The required width/height ratio to downsize to before computing the render pass.
  107759. * @param camera The camera to apply the render pass to.
  107760. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107761. * @param engine The engine which the post process will be applied. (default: current engine)
  107762. * @param reusable If the post process can be reused on the same frame. (default: false)
  107763. * @param textureType Type of textures used when performing the post process. (default: 0)
  107764. */
  107765. constructor(name: string,
  107766. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  107767. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  107768. /**
  107769. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107770. */
  107771. static EdgeDetect0Kernel: number[];
  107772. /**
  107773. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107774. */
  107775. static EdgeDetect1Kernel: number[];
  107776. /**
  107777. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107778. */
  107779. static EdgeDetect2Kernel: number[];
  107780. /**
  107781. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107782. */
  107783. static SharpenKernel: number[];
  107784. /**
  107785. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107786. */
  107787. static EmbossKernel: number[];
  107788. /**
  107789. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107790. */
  107791. static GaussianKernel: number[];
  107792. }
  107793. }
  107794. declare module BABYLON {
  107795. /**
  107796. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  107797. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  107798. * based on samples that have a large difference in distance than the center pixel.
  107799. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  107800. */
  107801. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  107802. direction: Vector2;
  107803. /**
  107804. * Creates a new instance CircleOfConfusionPostProcess
  107805. * @param name The name of the effect.
  107806. * @param scene The scene the effect belongs to.
  107807. * @param direction The direction the blur should be applied.
  107808. * @param kernel The size of the kernel used to blur.
  107809. * @param options The required width/height ratio to downsize to before computing the render pass.
  107810. * @param camera The camera to apply the render pass to.
  107811. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  107812. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  107813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107814. * @param engine The engine which the post process will be applied. (default: current engine)
  107815. * @param reusable If the post process can be reused on the same frame. (default: false)
  107816. * @param textureType Type of textures used when performing the post process. (default: 0)
  107817. * @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)
  107818. */
  107819. 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);
  107820. }
  107821. }
  107822. declare module BABYLON {
  107823. /** @hidden */
  107824. export var depthOfFieldMergePixelShader: {
  107825. name: string;
  107826. shader: string;
  107827. };
  107828. }
  107829. declare module BABYLON {
  107830. /**
  107831. * Options to be set when merging outputs from the default pipeline.
  107832. */
  107833. export class DepthOfFieldMergePostProcessOptions {
  107834. /**
  107835. * The original image to merge on top of
  107836. */
  107837. originalFromInput: PostProcess;
  107838. /**
  107839. * Parameters to perform the merge of the depth of field effect
  107840. */
  107841. depthOfField?: {
  107842. circleOfConfusion: PostProcess;
  107843. blurSteps: Array<PostProcess>;
  107844. };
  107845. /**
  107846. * Parameters to perform the merge of bloom effect
  107847. */
  107848. bloom?: {
  107849. blurred: PostProcess;
  107850. weight: number;
  107851. };
  107852. }
  107853. /**
  107854. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  107855. */
  107856. export class DepthOfFieldMergePostProcess extends PostProcess {
  107857. private blurSteps;
  107858. /**
  107859. * Creates a new instance of DepthOfFieldMergePostProcess
  107860. * @param name The name of the effect.
  107861. * @param originalFromInput Post process which's input will be used for the merge.
  107862. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  107863. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  107864. * @param options The required width/height ratio to downsize to before computing the render pass.
  107865. * @param camera The camera to apply the render pass to.
  107866. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107867. * @param engine The engine which the post process will be applied. (default: current engine)
  107868. * @param reusable If the post process can be reused on the same frame. (default: false)
  107869. * @param textureType Type of textures used when performing the post process. (default: 0)
  107870. * @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)
  107871. */
  107872. 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);
  107873. /**
  107874. * Updates the effect with the current post process compile time values and recompiles the shader.
  107875. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  107876. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  107877. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  107878. * @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
  107879. * @param onCompiled Called when the shader has been compiled.
  107880. * @param onError Called if there is an error when compiling a shader.
  107881. */
  107882. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  107883. }
  107884. }
  107885. declare module BABYLON {
  107886. /**
  107887. * Specifies the level of max blur that should be applied when using the depth of field effect
  107888. */
  107889. export enum DepthOfFieldEffectBlurLevel {
  107890. /**
  107891. * Subtle blur
  107892. */
  107893. Low = 0,
  107894. /**
  107895. * Medium blur
  107896. */
  107897. Medium = 1,
  107898. /**
  107899. * Large blur
  107900. */
  107901. High = 2
  107902. }
  107903. /**
  107904. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  107905. */
  107906. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  107907. private _circleOfConfusion;
  107908. /**
  107909. * @hidden Internal, blurs from high to low
  107910. */
  107911. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  107912. private _depthOfFieldBlurY;
  107913. private _dofMerge;
  107914. /**
  107915. * @hidden Internal post processes in depth of field effect
  107916. */
  107917. _effects: Array<PostProcess>;
  107918. /**
  107919. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  107920. */
  107921. focalLength: number;
  107922. /**
  107923. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  107924. */
  107925. fStop: number;
  107926. /**
  107927. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  107928. */
  107929. focusDistance: number;
  107930. /**
  107931. * 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.
  107932. */
  107933. lensSize: number;
  107934. /**
  107935. * Creates a new instance DepthOfFieldEffect
  107936. * @param scene The scene the effect belongs to.
  107937. * @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.
  107938. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  107939. * @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)
  107940. */
  107941. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  107942. /**
  107943. * 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.
  107944. */
  107945. depthTexture: RenderTargetTexture;
  107946. /**
  107947. * Disposes each of the internal effects for a given camera.
  107948. * @param camera The camera to dispose the effect on.
  107949. */
  107950. disposeEffects(camera: Camera): void;
  107951. /**
  107952. * @hidden Internal
  107953. */
  107954. _updateEffects(): void;
  107955. /**
  107956. * Internal
  107957. * @returns if all the contained post processes are ready.
  107958. * @hidden
  107959. */
  107960. _isReady(): boolean;
  107961. }
  107962. }
  107963. declare module BABYLON {
  107964. /** @hidden */
  107965. export var displayPassPixelShader: {
  107966. name: string;
  107967. shader: string;
  107968. };
  107969. }
  107970. declare module BABYLON {
  107971. /**
  107972. * DisplayPassPostProcess which produces an output the same as it's input
  107973. */
  107974. export class DisplayPassPostProcess extends PostProcess {
  107975. /**
  107976. * Creates the DisplayPassPostProcess
  107977. * @param name The name of the effect.
  107978. * @param options The required width/height ratio to downsize to before computing the render pass.
  107979. * @param camera The camera to apply the render pass to.
  107980. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107981. * @param engine The engine which the post process will be applied. (default: current engine)
  107982. * @param reusable If the post process can be reused on the same frame. (default: false)
  107983. */
  107984. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107985. }
  107986. }
  107987. declare module BABYLON {
  107988. /** @hidden */
  107989. export var filterPixelShader: {
  107990. name: string;
  107991. shader: string;
  107992. };
  107993. }
  107994. declare module BABYLON {
  107995. /**
  107996. * Applies a kernel filter to the image
  107997. */
  107998. export class FilterPostProcess extends PostProcess {
  107999. /** The matrix to be applied to the image */
  108000. kernelMatrix: Matrix;
  108001. /**
  108002. *
  108003. * @param name The name of the effect.
  108004. * @param kernelMatrix The matrix to be applied to the image
  108005. * @param options The required width/height ratio to downsize to before computing the render pass.
  108006. * @param camera The camera to apply the render pass to.
  108007. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108008. * @param engine The engine which the post process will be applied. (default: current engine)
  108009. * @param reusable If the post process can be reused on the same frame. (default: false)
  108010. */
  108011. constructor(name: string,
  108012. /** The matrix to be applied to the image */
  108013. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108014. }
  108015. }
  108016. declare module BABYLON {
  108017. /** @hidden */
  108018. export var fxaaPixelShader: {
  108019. name: string;
  108020. shader: string;
  108021. };
  108022. }
  108023. declare module BABYLON {
  108024. /** @hidden */
  108025. export var fxaaVertexShader: {
  108026. name: string;
  108027. shader: string;
  108028. };
  108029. }
  108030. declare module BABYLON {
  108031. /**
  108032. * Fxaa post process
  108033. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  108034. */
  108035. export class FxaaPostProcess extends PostProcess {
  108036. /** @hidden */
  108037. texelWidth: number;
  108038. /** @hidden */
  108039. texelHeight: number;
  108040. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108041. private _getDefines;
  108042. }
  108043. }
  108044. declare module BABYLON {
  108045. /** @hidden */
  108046. export var grainPixelShader: {
  108047. name: string;
  108048. shader: string;
  108049. };
  108050. }
  108051. declare module BABYLON {
  108052. /**
  108053. * The GrainPostProcess adds noise to the image at mid luminance levels
  108054. */
  108055. export class GrainPostProcess extends PostProcess {
  108056. /**
  108057. * The intensity of the grain added (default: 30)
  108058. */
  108059. intensity: number;
  108060. /**
  108061. * If the grain should be randomized on every frame
  108062. */
  108063. animated: boolean;
  108064. /**
  108065. * Creates a new instance of @see GrainPostProcess
  108066. * @param name The name of the effect.
  108067. * @param options The required width/height ratio to downsize to before computing the render pass.
  108068. * @param camera The camera to apply the render pass to.
  108069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108070. * @param engine The engine which the post process will be applied. (default: current engine)
  108071. * @param reusable If the post process can be reused on the same frame. (default: false)
  108072. * @param textureType Type of textures used when performing the post process. (default: 0)
  108073. * @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)
  108074. */
  108075. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108076. }
  108077. }
  108078. declare module BABYLON {
  108079. /** @hidden */
  108080. export var highlightsPixelShader: {
  108081. name: string;
  108082. shader: string;
  108083. };
  108084. }
  108085. declare module BABYLON {
  108086. /**
  108087. * Extracts highlights from the image
  108088. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108089. */
  108090. export class HighlightsPostProcess extends PostProcess {
  108091. /**
  108092. * Extracts highlights from the image
  108093. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108094. * @param name The name of the effect.
  108095. * @param options The required width/height ratio to downsize to before computing the render pass.
  108096. * @param camera The camera to apply the render pass to.
  108097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108098. * @param engine The engine which the post process will be applied. (default: current engine)
  108099. * @param reusable If the post process can be reused on the same frame. (default: false)
  108100. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  108101. */
  108102. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108103. }
  108104. }
  108105. declare module BABYLON {
  108106. /** @hidden */
  108107. export var mrtFragmentDeclaration: {
  108108. name: string;
  108109. shader: string;
  108110. };
  108111. }
  108112. declare module BABYLON {
  108113. /** @hidden */
  108114. export var geometryPixelShader: {
  108115. name: string;
  108116. shader: string;
  108117. };
  108118. }
  108119. declare module BABYLON {
  108120. /** @hidden */
  108121. export var geometryVertexShader: {
  108122. name: string;
  108123. shader: string;
  108124. };
  108125. }
  108126. declare module BABYLON {
  108127. /**
  108128. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  108129. */
  108130. export class GeometryBufferRenderer {
  108131. /**
  108132. * Constant used to retrieve the position texture index in the G-Buffer textures array
  108133. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  108134. */
  108135. static readonly POSITION_TEXTURE_TYPE: number;
  108136. /**
  108137. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  108138. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  108139. */
  108140. static readonly VELOCITY_TEXTURE_TYPE: number;
  108141. /**
  108142. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108143. * in order to compute objects velocities when enableVelocity is set to "true"
  108144. * @hidden
  108145. */
  108146. _previousTransformationMatrices: {
  108147. [index: number]: Matrix;
  108148. };
  108149. private _scene;
  108150. private _multiRenderTarget;
  108151. private _ratio;
  108152. private _enablePosition;
  108153. private _enableVelocity;
  108154. private _positionIndex;
  108155. private _velocityIndex;
  108156. protected _effect: Effect;
  108157. protected _cachedDefines: string;
  108158. /**
  108159. * Set the render list (meshes to be rendered) used in the G buffer.
  108160. */
  108161. renderList: Mesh[];
  108162. /**
  108163. * Gets wether or not G buffer are supported by the running hardware.
  108164. * This requires draw buffer supports
  108165. */
  108166. readonly isSupported: boolean;
  108167. /**
  108168. * Returns the index of the given texture type in the G-Buffer textures array
  108169. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108170. * @returns the index of the given texture type in the G-Buffer textures array
  108171. */
  108172. getTextureIndex(textureType: number): number;
  108173. /**
  108174. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108175. */
  108176. /**
  108177. * Sets whether or not objects positions are enabled for the G buffer.
  108178. */
  108179. enablePosition: boolean;
  108180. /**
  108181. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108182. */
  108183. /**
  108184. * Sets wether or not objects velocities are enabled for the G buffer.
  108185. */
  108186. enableVelocity: boolean;
  108187. /**
  108188. * Gets the scene associated with the buffer.
  108189. */
  108190. readonly scene: Scene;
  108191. /**
  108192. * Gets the ratio used by the buffer during its creation.
  108193. * How big is the buffer related to the main canvas.
  108194. */
  108195. readonly ratio: number;
  108196. /** @hidden */
  108197. static _SceneComponentInitialization: (scene: Scene) => void;
  108198. /**
  108199. * Creates a new G Buffer for the scene
  108200. * @param scene The scene the buffer belongs to
  108201. * @param ratio How big is the buffer related to the main canvas.
  108202. */
  108203. constructor(scene: Scene, ratio?: number);
  108204. /**
  108205. * Checks wether everything is ready to render a submesh to the G buffer.
  108206. * @param subMesh the submesh to check readiness for
  108207. * @param useInstances is the mesh drawn using instance or not
  108208. * @returns true if ready otherwise false
  108209. */
  108210. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108211. /**
  108212. * Gets the current underlying G Buffer.
  108213. * @returns the buffer
  108214. */
  108215. getGBuffer(): MultiRenderTarget;
  108216. /**
  108217. * Gets the number of samples used to render the buffer (anti aliasing).
  108218. */
  108219. /**
  108220. * Sets the number of samples used to render the buffer (anti aliasing).
  108221. */
  108222. samples: number;
  108223. /**
  108224. * Disposes the renderer and frees up associated resources.
  108225. */
  108226. dispose(): void;
  108227. protected _createRenderTargets(): void;
  108228. }
  108229. }
  108230. declare module BABYLON {
  108231. /** @hidden */
  108232. export var motionBlurPixelShader: {
  108233. name: string;
  108234. shader: string;
  108235. };
  108236. }
  108237. declare module BABYLON {
  108238. /**
  108239. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  108240. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  108241. * As an example, all you have to do is to create the post-process:
  108242. * var mb = new BABYLON.MotionBlurPostProcess(
  108243. * 'mb', // The name of the effect.
  108244. * scene, // The scene containing the objects to blur according to their velocity.
  108245. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  108246. * camera // The camera to apply the render pass to.
  108247. * );
  108248. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  108249. */
  108250. export class MotionBlurPostProcess extends PostProcess {
  108251. /**
  108252. * Defines how much the image is blurred by the movement. Default value is equal to 1
  108253. */
  108254. motionStrength: number;
  108255. /**
  108256. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  108257. */
  108258. /**
  108259. * Sets the number of iterations to be used for motion blur quality
  108260. */
  108261. motionBlurSamples: number;
  108262. private _motionBlurSamples;
  108263. private _geometryBufferRenderer;
  108264. /**
  108265. * Creates a new instance MotionBlurPostProcess
  108266. * @param name The name of the effect.
  108267. * @param scene The scene containing the objects to blur according to their velocity.
  108268. * @param options The required width/height ratio to downsize to before computing the render pass.
  108269. * @param camera The camera to apply the render pass to.
  108270. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108271. * @param engine The engine which the post process will be applied. (default: current engine)
  108272. * @param reusable If the post process can be reused on the same frame. (default: false)
  108273. * @param textureType Type of textures used when performing the post process. (default: 0)
  108274. * @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)
  108275. */
  108276. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108277. /**
  108278. * Disposes the post process.
  108279. * @param camera The camera to dispose the post process on.
  108280. */
  108281. dispose(camera?: Camera): void;
  108282. }
  108283. }
  108284. declare module BABYLON {
  108285. /** @hidden */
  108286. export var refractionPixelShader: {
  108287. name: string;
  108288. shader: string;
  108289. };
  108290. }
  108291. declare module BABYLON {
  108292. /**
  108293. * Post process which applies a refractin texture
  108294. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108295. */
  108296. export class RefractionPostProcess extends PostProcess {
  108297. /** the base color of the refraction (used to taint the rendering) */
  108298. color: Color3;
  108299. /** simulated refraction depth */
  108300. depth: number;
  108301. /** the coefficient of the base color (0 to remove base color tainting) */
  108302. colorLevel: number;
  108303. private _refTexture;
  108304. private _ownRefractionTexture;
  108305. /**
  108306. * Gets or sets the refraction texture
  108307. * Please note that you are responsible for disposing the texture if you set it manually
  108308. */
  108309. refractionTexture: Texture;
  108310. /**
  108311. * Initializes the RefractionPostProcess
  108312. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108313. * @param name The name of the effect.
  108314. * @param refractionTextureUrl Url of the refraction texture to use
  108315. * @param color the base color of the refraction (used to taint the rendering)
  108316. * @param depth simulated refraction depth
  108317. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  108318. * @param camera The camera to apply the render pass to.
  108319. * @param options The required width/height ratio to downsize to before computing the render pass.
  108320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108321. * @param engine The engine which the post process will be applied. (default: current engine)
  108322. * @param reusable If the post process can be reused on the same frame. (default: false)
  108323. */
  108324. constructor(name: string, refractionTextureUrl: string,
  108325. /** the base color of the refraction (used to taint the rendering) */
  108326. color: Color3,
  108327. /** simulated refraction depth */
  108328. depth: number,
  108329. /** the coefficient of the base color (0 to remove base color tainting) */
  108330. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108331. /**
  108332. * Disposes of the post process
  108333. * @param camera Camera to dispose post process on
  108334. */
  108335. dispose(camera: Camera): void;
  108336. }
  108337. }
  108338. declare module BABYLON {
  108339. /** @hidden */
  108340. export var sharpenPixelShader: {
  108341. name: string;
  108342. shader: string;
  108343. };
  108344. }
  108345. declare module BABYLON {
  108346. /**
  108347. * The SharpenPostProcess applies a sharpen kernel to every pixel
  108348. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  108349. */
  108350. export class SharpenPostProcess extends PostProcess {
  108351. /**
  108352. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  108353. */
  108354. colorAmount: number;
  108355. /**
  108356. * How much sharpness should be applied (default: 0.3)
  108357. */
  108358. edgeAmount: number;
  108359. /**
  108360. * Creates a new instance ConvolutionPostProcess
  108361. * @param name The name of the effect.
  108362. * @param options The required width/height ratio to downsize to before computing the render pass.
  108363. * @param camera The camera to apply the render pass to.
  108364. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108365. * @param engine The engine which the post process will be applied. (default: current engine)
  108366. * @param reusable If the post process can be reused on the same frame. (default: false)
  108367. * @param textureType Type of textures used when performing the post process. (default: 0)
  108368. * @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)
  108369. */
  108370. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108371. }
  108372. }
  108373. declare module BABYLON {
  108374. /**
  108375. * PostProcessRenderPipeline
  108376. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108377. */
  108378. export class PostProcessRenderPipeline {
  108379. private engine;
  108380. private _renderEffects;
  108381. private _renderEffectsForIsolatedPass;
  108382. /**
  108383. * @hidden
  108384. */
  108385. protected _cameras: Camera[];
  108386. /** @hidden */
  108387. _name: string;
  108388. /**
  108389. * Gets pipeline name
  108390. */
  108391. readonly name: string;
  108392. /**
  108393. * Initializes a PostProcessRenderPipeline
  108394. * @param engine engine to add the pipeline to
  108395. * @param name name of the pipeline
  108396. */
  108397. constructor(engine: Engine, name: string);
  108398. /**
  108399. * Gets the class name
  108400. * @returns "PostProcessRenderPipeline"
  108401. */
  108402. getClassName(): string;
  108403. /**
  108404. * If all the render effects in the pipeline are supported
  108405. */
  108406. readonly isSupported: boolean;
  108407. /**
  108408. * Adds an effect to the pipeline
  108409. * @param renderEffect the effect to add
  108410. */
  108411. addEffect(renderEffect: PostProcessRenderEffect): void;
  108412. /** @hidden */
  108413. _rebuild(): void;
  108414. /** @hidden */
  108415. _enableEffect(renderEffectName: string, cameras: Camera): void;
  108416. /** @hidden */
  108417. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  108418. /** @hidden */
  108419. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  108420. /** @hidden */
  108421. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  108422. /** @hidden */
  108423. _attachCameras(cameras: Camera, unique: boolean): void;
  108424. /** @hidden */
  108425. _attachCameras(cameras: Camera[], unique: boolean): void;
  108426. /** @hidden */
  108427. _detachCameras(cameras: Camera): void;
  108428. /** @hidden */
  108429. _detachCameras(cameras: Nullable<Camera[]>): void;
  108430. /** @hidden */
  108431. _update(): void;
  108432. /** @hidden */
  108433. _reset(): void;
  108434. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  108435. /**
  108436. * Disposes of the pipeline
  108437. */
  108438. dispose(): void;
  108439. }
  108440. }
  108441. declare module BABYLON {
  108442. /**
  108443. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  108444. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  108445. */
  108446. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  108447. private _scene;
  108448. private _camerasToBeAttached;
  108449. /**
  108450. * ID of the sharpen post process,
  108451. */
  108452. private readonly SharpenPostProcessId;
  108453. /**
  108454. * @ignore
  108455. * ID of the image processing post process;
  108456. */
  108457. readonly ImageProcessingPostProcessId: string;
  108458. /**
  108459. * @ignore
  108460. * ID of the Fast Approximate Anti-Aliasing post process;
  108461. */
  108462. readonly FxaaPostProcessId: string;
  108463. /**
  108464. * ID of the chromatic aberration post process,
  108465. */
  108466. private readonly ChromaticAberrationPostProcessId;
  108467. /**
  108468. * ID of the grain post process
  108469. */
  108470. private readonly GrainPostProcessId;
  108471. /**
  108472. * Sharpen post process which will apply a sharpen convolution to enhance edges
  108473. */
  108474. sharpen: SharpenPostProcess;
  108475. private _sharpenEffect;
  108476. private bloom;
  108477. /**
  108478. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  108479. */
  108480. depthOfField: DepthOfFieldEffect;
  108481. /**
  108482. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  108483. */
  108484. fxaa: FxaaPostProcess;
  108485. /**
  108486. * Image post processing pass used to perform operations such as tone mapping or color grading.
  108487. */
  108488. imageProcessing: ImageProcessingPostProcess;
  108489. /**
  108490. * Chromatic aberration post process which will shift rgb colors in the image
  108491. */
  108492. chromaticAberration: ChromaticAberrationPostProcess;
  108493. private _chromaticAberrationEffect;
  108494. /**
  108495. * Grain post process which add noise to the image
  108496. */
  108497. grain: GrainPostProcess;
  108498. private _grainEffect;
  108499. /**
  108500. * Glow post process which adds a glow to emissive areas of the image
  108501. */
  108502. private _glowLayer;
  108503. /**
  108504. * Animations which can be used to tweak settings over a period of time
  108505. */
  108506. animations: Animation[];
  108507. private _imageProcessingConfigurationObserver;
  108508. private _sharpenEnabled;
  108509. private _bloomEnabled;
  108510. private _depthOfFieldEnabled;
  108511. private _depthOfFieldBlurLevel;
  108512. private _fxaaEnabled;
  108513. private _imageProcessingEnabled;
  108514. private _defaultPipelineTextureType;
  108515. private _bloomScale;
  108516. private _chromaticAberrationEnabled;
  108517. private _grainEnabled;
  108518. private _buildAllowed;
  108519. /**
  108520. * Gets active scene
  108521. */
  108522. readonly scene: Scene;
  108523. /**
  108524. * Enable or disable the sharpen process from the pipeline
  108525. */
  108526. sharpenEnabled: boolean;
  108527. private _resizeObserver;
  108528. private _hardwareScaleLevel;
  108529. private _bloomKernel;
  108530. /**
  108531. * Specifies the size of the bloom blur kernel, relative to the final output size
  108532. */
  108533. bloomKernel: number;
  108534. /**
  108535. * Specifies the weight of the bloom in the final rendering
  108536. */
  108537. private _bloomWeight;
  108538. /**
  108539. * Specifies the luma threshold for the area that will be blurred by the bloom
  108540. */
  108541. private _bloomThreshold;
  108542. private _hdr;
  108543. /**
  108544. * The strength of the bloom.
  108545. */
  108546. bloomWeight: number;
  108547. /**
  108548. * The strength of the bloom.
  108549. */
  108550. bloomThreshold: number;
  108551. /**
  108552. * The scale of the bloom, lower value will provide better performance.
  108553. */
  108554. bloomScale: number;
  108555. /**
  108556. * Enable or disable the bloom from the pipeline
  108557. */
  108558. bloomEnabled: boolean;
  108559. private _rebuildBloom;
  108560. /**
  108561. * If the depth of field is enabled.
  108562. */
  108563. depthOfFieldEnabled: boolean;
  108564. /**
  108565. * Blur level of the depth of field effect. (Higher blur will effect performance)
  108566. */
  108567. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  108568. /**
  108569. * If the anti aliasing is enabled.
  108570. */
  108571. fxaaEnabled: boolean;
  108572. private _samples;
  108573. /**
  108574. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  108575. */
  108576. samples: number;
  108577. /**
  108578. * If image processing is enabled.
  108579. */
  108580. imageProcessingEnabled: boolean;
  108581. /**
  108582. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  108583. */
  108584. glowLayerEnabled: boolean;
  108585. /**
  108586. * Enable or disable the chromaticAberration process from the pipeline
  108587. */
  108588. chromaticAberrationEnabled: boolean;
  108589. /**
  108590. * Enable or disable the grain process from the pipeline
  108591. */
  108592. grainEnabled: boolean;
  108593. /**
  108594. * @constructor
  108595. * @param name - The rendering pipeline name (default: "")
  108596. * @param hdr - If high dynamic range textures should be used (default: true)
  108597. * @param scene - The scene linked to this pipeline (default: the last created scene)
  108598. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  108599. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  108600. */
  108601. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  108602. /**
  108603. * Get the class name
  108604. * @returns "DefaultRenderingPipeline"
  108605. */
  108606. getClassName(): string;
  108607. /**
  108608. * Force the compilation of the entire pipeline.
  108609. */
  108610. prepare(): void;
  108611. private _hasCleared;
  108612. private _prevPostProcess;
  108613. private _prevPrevPostProcess;
  108614. private _setAutoClearAndTextureSharing;
  108615. private _depthOfFieldSceneObserver;
  108616. private _buildPipeline;
  108617. private _disposePostProcesses;
  108618. /**
  108619. * Adds a camera to the pipeline
  108620. * @param camera the camera to be added
  108621. */
  108622. addCamera(camera: Camera): void;
  108623. /**
  108624. * Removes a camera from the pipeline
  108625. * @param camera the camera to remove
  108626. */
  108627. removeCamera(camera: Camera): void;
  108628. /**
  108629. * Dispose of the pipeline and stop all post processes
  108630. */
  108631. dispose(): void;
  108632. /**
  108633. * Serialize the rendering pipeline (Used when exporting)
  108634. * @returns the serialized object
  108635. */
  108636. serialize(): any;
  108637. /**
  108638. * Parse the serialized pipeline
  108639. * @param source Source pipeline.
  108640. * @param scene The scene to load the pipeline to.
  108641. * @param rootUrl The URL of the serialized pipeline.
  108642. * @returns An instantiated pipeline from the serialized object.
  108643. */
  108644. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  108645. }
  108646. }
  108647. declare module BABYLON {
  108648. /** @hidden */
  108649. export var lensHighlightsPixelShader: {
  108650. name: string;
  108651. shader: string;
  108652. };
  108653. }
  108654. declare module BABYLON {
  108655. /** @hidden */
  108656. export var depthOfFieldPixelShader: {
  108657. name: string;
  108658. shader: string;
  108659. };
  108660. }
  108661. declare module BABYLON {
  108662. /**
  108663. * BABYLON.JS Chromatic Aberration GLSL Shader
  108664. * Author: Olivier Guyot
  108665. * Separates very slightly R, G and B colors on the edges of the screen
  108666. * Inspired by Francois Tarlier & Martins Upitis
  108667. */
  108668. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  108669. /**
  108670. * @ignore
  108671. * The chromatic aberration PostProcess id in the pipeline
  108672. */
  108673. LensChromaticAberrationEffect: string;
  108674. /**
  108675. * @ignore
  108676. * The highlights enhancing PostProcess id in the pipeline
  108677. */
  108678. HighlightsEnhancingEffect: string;
  108679. /**
  108680. * @ignore
  108681. * The depth-of-field PostProcess id in the pipeline
  108682. */
  108683. LensDepthOfFieldEffect: string;
  108684. private _scene;
  108685. private _depthTexture;
  108686. private _grainTexture;
  108687. private _chromaticAberrationPostProcess;
  108688. private _highlightsPostProcess;
  108689. private _depthOfFieldPostProcess;
  108690. private _edgeBlur;
  108691. private _grainAmount;
  108692. private _chromaticAberration;
  108693. private _distortion;
  108694. private _highlightsGain;
  108695. private _highlightsThreshold;
  108696. private _dofDistance;
  108697. private _dofAperture;
  108698. private _dofDarken;
  108699. private _dofPentagon;
  108700. private _blurNoise;
  108701. /**
  108702. * @constructor
  108703. *
  108704. * Effect parameters are as follow:
  108705. * {
  108706. * chromatic_aberration: number; // from 0 to x (1 for realism)
  108707. * edge_blur: number; // from 0 to x (1 for realism)
  108708. * distortion: number; // from 0 to x (1 for realism)
  108709. * grain_amount: number; // from 0 to 1
  108710. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  108711. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  108712. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  108713. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  108714. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  108715. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  108716. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  108717. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  108718. * }
  108719. * Note: if an effect parameter is unset, effect is disabled
  108720. *
  108721. * @param name The rendering pipeline name
  108722. * @param parameters - An object containing all parameters (see above)
  108723. * @param scene The scene linked to this pipeline
  108724. * @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)
  108725. * @param cameras The array of cameras that the rendering pipeline will be attached to
  108726. */
  108727. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  108728. /**
  108729. * Sets the amount of blur at the edges
  108730. * @param amount blur amount
  108731. */
  108732. setEdgeBlur(amount: number): void;
  108733. /**
  108734. * Sets edge blur to 0
  108735. */
  108736. disableEdgeBlur(): void;
  108737. /**
  108738. * Sets the amout of grain
  108739. * @param amount Amount of grain
  108740. */
  108741. setGrainAmount(amount: number): void;
  108742. /**
  108743. * Set grain amount to 0
  108744. */
  108745. disableGrain(): void;
  108746. /**
  108747. * Sets the chromatic aberration amount
  108748. * @param amount amount of chromatic aberration
  108749. */
  108750. setChromaticAberration(amount: number): void;
  108751. /**
  108752. * Sets chromatic aberration amount to 0
  108753. */
  108754. disableChromaticAberration(): void;
  108755. /**
  108756. * Sets the EdgeDistortion amount
  108757. * @param amount amount of EdgeDistortion
  108758. */
  108759. setEdgeDistortion(amount: number): void;
  108760. /**
  108761. * Sets edge distortion to 0
  108762. */
  108763. disableEdgeDistortion(): void;
  108764. /**
  108765. * Sets the FocusDistance amount
  108766. * @param amount amount of FocusDistance
  108767. */
  108768. setFocusDistance(amount: number): void;
  108769. /**
  108770. * Disables depth of field
  108771. */
  108772. disableDepthOfField(): void;
  108773. /**
  108774. * Sets the Aperture amount
  108775. * @param amount amount of Aperture
  108776. */
  108777. setAperture(amount: number): void;
  108778. /**
  108779. * Sets the DarkenOutOfFocus amount
  108780. * @param amount amount of DarkenOutOfFocus
  108781. */
  108782. setDarkenOutOfFocus(amount: number): void;
  108783. /**
  108784. * Creates a pentagon bokeh effect
  108785. */
  108786. enablePentagonBokeh(): void;
  108787. /**
  108788. * Disables the pentagon bokeh effect
  108789. */
  108790. disablePentagonBokeh(): void;
  108791. /**
  108792. * Enables noise blur
  108793. */
  108794. enableNoiseBlur(): void;
  108795. /**
  108796. * Disables noise blur
  108797. */
  108798. disableNoiseBlur(): void;
  108799. /**
  108800. * Sets the HighlightsGain amount
  108801. * @param amount amount of HighlightsGain
  108802. */
  108803. setHighlightsGain(amount: number): void;
  108804. /**
  108805. * Sets the HighlightsThreshold amount
  108806. * @param amount amount of HighlightsThreshold
  108807. */
  108808. setHighlightsThreshold(amount: number): void;
  108809. /**
  108810. * Disables highlights
  108811. */
  108812. disableHighlights(): void;
  108813. /**
  108814. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  108815. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  108816. */
  108817. dispose(disableDepthRender?: boolean): void;
  108818. private _createChromaticAberrationPostProcess;
  108819. private _createHighlightsPostProcess;
  108820. private _createDepthOfFieldPostProcess;
  108821. private _createGrainTexture;
  108822. }
  108823. }
  108824. declare module BABYLON {
  108825. /** @hidden */
  108826. export var ssao2PixelShader: {
  108827. name: string;
  108828. shader: string;
  108829. };
  108830. }
  108831. declare module BABYLON {
  108832. /** @hidden */
  108833. export var ssaoCombinePixelShader: {
  108834. name: string;
  108835. shader: string;
  108836. };
  108837. }
  108838. declare module BABYLON {
  108839. /**
  108840. * Render pipeline to produce ssao effect
  108841. */
  108842. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  108843. /**
  108844. * @ignore
  108845. * The PassPostProcess id in the pipeline that contains the original scene color
  108846. */
  108847. SSAOOriginalSceneColorEffect: string;
  108848. /**
  108849. * @ignore
  108850. * The SSAO PostProcess id in the pipeline
  108851. */
  108852. SSAORenderEffect: string;
  108853. /**
  108854. * @ignore
  108855. * The horizontal blur PostProcess id in the pipeline
  108856. */
  108857. SSAOBlurHRenderEffect: string;
  108858. /**
  108859. * @ignore
  108860. * The vertical blur PostProcess id in the pipeline
  108861. */
  108862. SSAOBlurVRenderEffect: string;
  108863. /**
  108864. * @ignore
  108865. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  108866. */
  108867. SSAOCombineRenderEffect: string;
  108868. /**
  108869. * The output strength of the SSAO post-process. Default value is 1.0.
  108870. */
  108871. totalStrength: number;
  108872. /**
  108873. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  108874. */
  108875. maxZ: number;
  108876. /**
  108877. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  108878. */
  108879. minZAspect: number;
  108880. private _samples;
  108881. /**
  108882. * Number of samples used for the SSAO calculations. Default value is 8
  108883. */
  108884. samples: number;
  108885. private _textureSamples;
  108886. /**
  108887. * Number of samples to use for antialiasing
  108888. */
  108889. textureSamples: number;
  108890. /**
  108891. * Ratio object used for SSAO ratio and blur ratio
  108892. */
  108893. private _ratio;
  108894. /**
  108895. * Dynamically generated sphere sampler.
  108896. */
  108897. private _sampleSphere;
  108898. /**
  108899. * Blur filter offsets
  108900. */
  108901. private _samplerOffsets;
  108902. private _expensiveBlur;
  108903. /**
  108904. * If bilateral blur should be used
  108905. */
  108906. expensiveBlur: boolean;
  108907. /**
  108908. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  108909. */
  108910. radius: number;
  108911. /**
  108912. * The base color of the SSAO post-process
  108913. * The final result is "base + ssao" between [0, 1]
  108914. */
  108915. base: number;
  108916. /**
  108917. * Support test.
  108918. */
  108919. static readonly IsSupported: boolean;
  108920. private _scene;
  108921. private _depthTexture;
  108922. private _normalTexture;
  108923. private _randomTexture;
  108924. private _originalColorPostProcess;
  108925. private _ssaoPostProcess;
  108926. private _blurHPostProcess;
  108927. private _blurVPostProcess;
  108928. private _ssaoCombinePostProcess;
  108929. private _firstUpdate;
  108930. /**
  108931. * Gets active scene
  108932. */
  108933. readonly scene: Scene;
  108934. /**
  108935. * @constructor
  108936. * @param name The rendering pipeline name
  108937. * @param scene The scene linked to this pipeline
  108938. * @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 }
  108939. * @param cameras The array of cameras that the rendering pipeline will be attached to
  108940. */
  108941. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  108942. /**
  108943. * Get the class name
  108944. * @returns "SSAO2RenderingPipeline"
  108945. */
  108946. getClassName(): string;
  108947. /**
  108948. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  108949. */
  108950. dispose(disableGeometryBufferRenderer?: boolean): void;
  108951. private _createBlurPostProcess;
  108952. /** @hidden */
  108953. _rebuild(): void;
  108954. private _bits;
  108955. private _radicalInverse_VdC;
  108956. private _hammersley;
  108957. private _hemisphereSample_uniform;
  108958. private _generateHemisphere;
  108959. private _createSSAOPostProcess;
  108960. private _createSSAOCombinePostProcess;
  108961. private _createRandomTexture;
  108962. /**
  108963. * Serialize the rendering pipeline (Used when exporting)
  108964. * @returns the serialized object
  108965. */
  108966. serialize(): any;
  108967. /**
  108968. * Parse the serialized pipeline
  108969. * @param source Source pipeline.
  108970. * @param scene The scene to load the pipeline to.
  108971. * @param rootUrl The URL of the serialized pipeline.
  108972. * @returns An instantiated pipeline from the serialized object.
  108973. */
  108974. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  108975. }
  108976. }
  108977. declare module BABYLON {
  108978. /** @hidden */
  108979. export var ssaoPixelShader: {
  108980. name: string;
  108981. shader: string;
  108982. };
  108983. }
  108984. declare module BABYLON {
  108985. /**
  108986. * Render pipeline to produce ssao effect
  108987. */
  108988. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  108989. /**
  108990. * @ignore
  108991. * The PassPostProcess id in the pipeline that contains the original scene color
  108992. */
  108993. SSAOOriginalSceneColorEffect: string;
  108994. /**
  108995. * @ignore
  108996. * The SSAO PostProcess id in the pipeline
  108997. */
  108998. SSAORenderEffect: string;
  108999. /**
  109000. * @ignore
  109001. * The horizontal blur PostProcess id in the pipeline
  109002. */
  109003. SSAOBlurHRenderEffect: string;
  109004. /**
  109005. * @ignore
  109006. * The vertical blur PostProcess id in the pipeline
  109007. */
  109008. SSAOBlurVRenderEffect: string;
  109009. /**
  109010. * @ignore
  109011. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109012. */
  109013. SSAOCombineRenderEffect: string;
  109014. /**
  109015. * The output strength of the SSAO post-process. Default value is 1.0.
  109016. */
  109017. totalStrength: number;
  109018. /**
  109019. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  109020. */
  109021. radius: number;
  109022. /**
  109023. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  109024. * Must not be equal to fallOff and superior to fallOff.
  109025. * Default value is 0.0075
  109026. */
  109027. area: number;
  109028. /**
  109029. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  109030. * Must not be equal to area and inferior to area.
  109031. * Default value is 0.000001
  109032. */
  109033. fallOff: number;
  109034. /**
  109035. * The base color of the SSAO post-process
  109036. * The final result is "base + ssao" between [0, 1]
  109037. */
  109038. base: number;
  109039. private _scene;
  109040. private _depthTexture;
  109041. private _randomTexture;
  109042. private _originalColorPostProcess;
  109043. private _ssaoPostProcess;
  109044. private _blurHPostProcess;
  109045. private _blurVPostProcess;
  109046. private _ssaoCombinePostProcess;
  109047. private _firstUpdate;
  109048. /**
  109049. * Gets active scene
  109050. */
  109051. readonly scene: Scene;
  109052. /**
  109053. * @constructor
  109054. * @param name - The rendering pipeline name
  109055. * @param scene - The scene linked to this pipeline
  109056. * @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 }
  109057. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  109058. */
  109059. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109060. /**
  109061. * Get the class name
  109062. * @returns "SSAORenderingPipeline"
  109063. */
  109064. getClassName(): string;
  109065. /**
  109066. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109067. */
  109068. dispose(disableDepthRender?: boolean): void;
  109069. private _createBlurPostProcess;
  109070. /** @hidden */
  109071. _rebuild(): void;
  109072. private _createSSAOPostProcess;
  109073. private _createSSAOCombinePostProcess;
  109074. private _createRandomTexture;
  109075. }
  109076. }
  109077. declare module BABYLON {
  109078. /** @hidden */
  109079. export var standardPixelShader: {
  109080. name: string;
  109081. shader: string;
  109082. };
  109083. }
  109084. declare module BABYLON {
  109085. /**
  109086. * Standard rendering pipeline
  109087. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  109088. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  109089. */
  109090. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109091. /**
  109092. * Public members
  109093. */
  109094. /**
  109095. * Post-process which contains the original scene color before the pipeline applies all the effects
  109096. */
  109097. originalPostProcess: Nullable<PostProcess>;
  109098. /**
  109099. * Post-process used to down scale an image x4
  109100. */
  109101. downSampleX4PostProcess: Nullable<PostProcess>;
  109102. /**
  109103. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  109104. */
  109105. brightPassPostProcess: Nullable<PostProcess>;
  109106. /**
  109107. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  109108. */
  109109. blurHPostProcesses: PostProcess[];
  109110. /**
  109111. * Post-process array storing all the vertical blur post-processes used by the pipeline
  109112. */
  109113. blurVPostProcesses: PostProcess[];
  109114. /**
  109115. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  109116. */
  109117. textureAdderPostProcess: Nullable<PostProcess>;
  109118. /**
  109119. * Post-process used to create volumetric lighting effect
  109120. */
  109121. volumetricLightPostProcess: Nullable<PostProcess>;
  109122. /**
  109123. * Post-process used to smooth the previous volumetric light post-process on the X axis
  109124. */
  109125. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  109126. /**
  109127. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  109128. */
  109129. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  109130. /**
  109131. * Post-process used to merge the volumetric light effect and the real scene color
  109132. */
  109133. volumetricLightMergePostProces: Nullable<PostProcess>;
  109134. /**
  109135. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  109136. */
  109137. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  109138. /**
  109139. * Base post-process used to calculate the average luminance of the final image for HDR
  109140. */
  109141. luminancePostProcess: Nullable<PostProcess>;
  109142. /**
  109143. * Post-processes used to create down sample post-processes in order to get
  109144. * the average luminance of the final image for HDR
  109145. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  109146. */
  109147. luminanceDownSamplePostProcesses: PostProcess[];
  109148. /**
  109149. * Post-process used to create a HDR effect (light adaptation)
  109150. */
  109151. hdrPostProcess: Nullable<PostProcess>;
  109152. /**
  109153. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  109154. */
  109155. textureAdderFinalPostProcess: Nullable<PostProcess>;
  109156. /**
  109157. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  109158. */
  109159. lensFlareFinalPostProcess: Nullable<PostProcess>;
  109160. /**
  109161. * Post-process used to merge the final HDR post-process and the real scene color
  109162. */
  109163. hdrFinalPostProcess: Nullable<PostProcess>;
  109164. /**
  109165. * Post-process used to create a lens flare effect
  109166. */
  109167. lensFlarePostProcess: Nullable<PostProcess>;
  109168. /**
  109169. * Post-process that merges the result of the lens flare post-process and the real scene color
  109170. */
  109171. lensFlareComposePostProcess: Nullable<PostProcess>;
  109172. /**
  109173. * Post-process used to create a motion blur effect
  109174. */
  109175. motionBlurPostProcess: Nullable<PostProcess>;
  109176. /**
  109177. * Post-process used to create a depth of field effect
  109178. */
  109179. depthOfFieldPostProcess: Nullable<PostProcess>;
  109180. /**
  109181. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109182. */
  109183. fxaaPostProcess: Nullable<FxaaPostProcess>;
  109184. /**
  109185. * Represents the brightness threshold in order to configure the illuminated surfaces
  109186. */
  109187. brightThreshold: number;
  109188. /**
  109189. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  109190. */
  109191. blurWidth: number;
  109192. /**
  109193. * Sets if the blur for highlighted surfaces must be only horizontal
  109194. */
  109195. horizontalBlur: boolean;
  109196. /**
  109197. * Sets the overall exposure used by the pipeline
  109198. */
  109199. exposure: number;
  109200. /**
  109201. * Texture used typically to simulate "dirty" on camera lens
  109202. */
  109203. lensTexture: Nullable<Texture>;
  109204. /**
  109205. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  109206. */
  109207. volumetricLightCoefficient: number;
  109208. /**
  109209. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  109210. */
  109211. volumetricLightPower: number;
  109212. /**
  109213. * Used the set the blur intensity to smooth the volumetric lights
  109214. */
  109215. volumetricLightBlurScale: number;
  109216. /**
  109217. * Light (spot or directional) used to generate the volumetric lights rays
  109218. * The source light must have a shadow generate so the pipeline can get its
  109219. * depth map
  109220. */
  109221. sourceLight: Nullable<SpotLight | DirectionalLight>;
  109222. /**
  109223. * For eye adaptation, represents the minimum luminance the eye can see
  109224. */
  109225. hdrMinimumLuminance: number;
  109226. /**
  109227. * For eye adaptation, represents the decrease luminance speed
  109228. */
  109229. hdrDecreaseRate: number;
  109230. /**
  109231. * For eye adaptation, represents the increase luminance speed
  109232. */
  109233. hdrIncreaseRate: number;
  109234. /**
  109235. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  109236. */
  109237. lensColorTexture: Nullable<Texture>;
  109238. /**
  109239. * The overall strengh for the lens flare effect
  109240. */
  109241. lensFlareStrength: number;
  109242. /**
  109243. * Dispersion coefficient for lens flare ghosts
  109244. */
  109245. lensFlareGhostDispersal: number;
  109246. /**
  109247. * Main lens flare halo width
  109248. */
  109249. lensFlareHaloWidth: number;
  109250. /**
  109251. * Based on the lens distortion effect, defines how much the lens flare result
  109252. * is distorted
  109253. */
  109254. lensFlareDistortionStrength: number;
  109255. /**
  109256. * Lens star texture must be used to simulate rays on the flares and is available
  109257. * in the documentation
  109258. */
  109259. lensStarTexture: Nullable<Texture>;
  109260. /**
  109261. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  109262. * flare effect by taking account of the dirt texture
  109263. */
  109264. lensFlareDirtTexture: Nullable<Texture>;
  109265. /**
  109266. * Represents the focal length for the depth of field effect
  109267. */
  109268. depthOfFieldDistance: number;
  109269. /**
  109270. * Represents the blur intensity for the blurred part of the depth of field effect
  109271. */
  109272. depthOfFieldBlurWidth: number;
  109273. /**
  109274. * For motion blur, defines how much the image is blurred by the movement
  109275. */
  109276. motionStrength: number;
  109277. /**
  109278. * List of animations for the pipeline (IAnimatable implementation)
  109279. */
  109280. animations: Animation[];
  109281. /**
  109282. * Private members
  109283. */
  109284. private _scene;
  109285. private _currentDepthOfFieldSource;
  109286. private _basePostProcess;
  109287. private _hdrCurrentLuminance;
  109288. private _floatTextureType;
  109289. private _ratio;
  109290. private _bloomEnabled;
  109291. private _depthOfFieldEnabled;
  109292. private _vlsEnabled;
  109293. private _lensFlareEnabled;
  109294. private _hdrEnabled;
  109295. private _motionBlurEnabled;
  109296. private _fxaaEnabled;
  109297. private _motionBlurSamples;
  109298. private _volumetricLightStepsCount;
  109299. private _samples;
  109300. /**
  109301. * @ignore
  109302. * Specifies if the bloom pipeline is enabled
  109303. */
  109304. BloomEnabled: boolean;
  109305. /**
  109306. * @ignore
  109307. * Specifies if the depth of field pipeline is enabed
  109308. */
  109309. DepthOfFieldEnabled: boolean;
  109310. /**
  109311. * @ignore
  109312. * Specifies if the lens flare pipeline is enabed
  109313. */
  109314. LensFlareEnabled: boolean;
  109315. /**
  109316. * @ignore
  109317. * Specifies if the HDR pipeline is enabled
  109318. */
  109319. HDREnabled: boolean;
  109320. /**
  109321. * @ignore
  109322. * Specifies if the volumetric lights scattering effect is enabled
  109323. */
  109324. VLSEnabled: boolean;
  109325. /**
  109326. * @ignore
  109327. * Specifies if the motion blur effect is enabled
  109328. */
  109329. MotionBlurEnabled: boolean;
  109330. /**
  109331. * Specifies if anti-aliasing is enabled
  109332. */
  109333. fxaaEnabled: boolean;
  109334. /**
  109335. * Specifies the number of steps used to calculate the volumetric lights
  109336. * Typically in interval [50, 200]
  109337. */
  109338. volumetricLightStepsCount: number;
  109339. /**
  109340. * Specifies the number of samples used for the motion blur effect
  109341. * Typically in interval [16, 64]
  109342. */
  109343. motionBlurSamples: number;
  109344. /**
  109345. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  109346. */
  109347. samples: number;
  109348. /**
  109349. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  109350. * @constructor
  109351. * @param name The rendering pipeline name
  109352. * @param scene The scene linked to this pipeline
  109353. * @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)
  109354. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  109355. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109356. */
  109357. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  109358. private _buildPipeline;
  109359. private _createDownSampleX4PostProcess;
  109360. private _createBrightPassPostProcess;
  109361. private _createBlurPostProcesses;
  109362. private _createTextureAdderPostProcess;
  109363. private _createVolumetricLightPostProcess;
  109364. private _createLuminancePostProcesses;
  109365. private _createHdrPostProcess;
  109366. private _createLensFlarePostProcess;
  109367. private _createDepthOfFieldPostProcess;
  109368. private _createMotionBlurPostProcess;
  109369. private _getDepthTexture;
  109370. private _disposePostProcesses;
  109371. /**
  109372. * Dispose of the pipeline and stop all post processes
  109373. */
  109374. dispose(): void;
  109375. /**
  109376. * Serialize the rendering pipeline (Used when exporting)
  109377. * @returns the serialized object
  109378. */
  109379. serialize(): any;
  109380. /**
  109381. * Parse the serialized pipeline
  109382. * @param source Source pipeline.
  109383. * @param scene The scene to load the pipeline to.
  109384. * @param rootUrl The URL of the serialized pipeline.
  109385. * @returns An instantiated pipeline from the serialized object.
  109386. */
  109387. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  109388. /**
  109389. * Luminance steps
  109390. */
  109391. static LuminanceSteps: number;
  109392. }
  109393. }
  109394. declare module BABYLON {
  109395. /**
  109396. * PostProcessRenderPipelineManager class
  109397. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109398. */
  109399. export class PostProcessRenderPipelineManager {
  109400. private _renderPipelines;
  109401. /**
  109402. * Initializes a PostProcessRenderPipelineManager
  109403. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109404. */
  109405. constructor();
  109406. /**
  109407. * Gets the list of supported render pipelines
  109408. */
  109409. readonly supportedPipelines: PostProcessRenderPipeline[];
  109410. /**
  109411. * Adds a pipeline to the manager
  109412. * @param renderPipeline The pipeline to add
  109413. */
  109414. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  109415. /**
  109416. * Attaches a camera to the pipeline
  109417. * @param renderPipelineName The name of the pipeline to attach to
  109418. * @param cameras the camera to attach
  109419. * @param unique if the camera can be attached multiple times to the pipeline
  109420. */
  109421. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  109422. /**
  109423. * Detaches a camera from the pipeline
  109424. * @param renderPipelineName The name of the pipeline to detach from
  109425. * @param cameras the camera to detach
  109426. */
  109427. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  109428. /**
  109429. * Enables an effect by name on a pipeline
  109430. * @param renderPipelineName the name of the pipeline to enable the effect in
  109431. * @param renderEffectName the name of the effect to enable
  109432. * @param cameras the cameras that the effect should be enabled on
  109433. */
  109434. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109435. /**
  109436. * Disables an effect by name on a pipeline
  109437. * @param renderPipelineName the name of the pipeline to disable the effect in
  109438. * @param renderEffectName the name of the effect to disable
  109439. * @param cameras the cameras that the effect should be disabled on
  109440. */
  109441. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109442. /**
  109443. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  109444. */
  109445. update(): void;
  109446. /** @hidden */
  109447. _rebuild(): void;
  109448. /**
  109449. * Disposes of the manager and pipelines
  109450. */
  109451. dispose(): void;
  109452. }
  109453. }
  109454. declare module BABYLON {
  109455. interface Scene {
  109456. /** @hidden (Backing field) */
  109457. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109458. /**
  109459. * Gets the postprocess render pipeline manager
  109460. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109461. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109462. */
  109463. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109464. }
  109465. /**
  109466. * Defines the Render Pipeline scene component responsible to rendering pipelines
  109467. */
  109468. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  109469. /**
  109470. * The component name helpfull to identify the component in the list of scene components.
  109471. */
  109472. readonly name: string;
  109473. /**
  109474. * The scene the component belongs to.
  109475. */
  109476. scene: Scene;
  109477. /**
  109478. * Creates a new instance of the component for the given scene
  109479. * @param scene Defines the scene to register the component in
  109480. */
  109481. constructor(scene: Scene);
  109482. /**
  109483. * Registers the component in a given scene
  109484. */
  109485. register(): void;
  109486. /**
  109487. * Rebuilds the elements related to this component in case of
  109488. * context lost for instance.
  109489. */
  109490. rebuild(): void;
  109491. /**
  109492. * Disposes the component and the associated ressources
  109493. */
  109494. dispose(): void;
  109495. private _gatherRenderTargets;
  109496. }
  109497. }
  109498. declare module BABYLON {
  109499. /** @hidden */
  109500. export var tonemapPixelShader: {
  109501. name: string;
  109502. shader: string;
  109503. };
  109504. }
  109505. declare module BABYLON {
  109506. /** Defines operator used for tonemapping */
  109507. export enum TonemappingOperator {
  109508. /** Hable */
  109509. Hable = 0,
  109510. /** Reinhard */
  109511. Reinhard = 1,
  109512. /** HejiDawson */
  109513. HejiDawson = 2,
  109514. /** Photographic */
  109515. Photographic = 3
  109516. }
  109517. /**
  109518. * Defines a post process to apply tone mapping
  109519. */
  109520. export class TonemapPostProcess extends PostProcess {
  109521. private _operator;
  109522. /** Defines the required exposure adjustement */
  109523. exposureAdjustment: number;
  109524. /**
  109525. * Creates a new TonemapPostProcess
  109526. * @param name defines the name of the postprocess
  109527. * @param _operator defines the operator to use
  109528. * @param exposureAdjustment defines the required exposure adjustement
  109529. * @param camera defines the camera to use (can be null)
  109530. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  109531. * @param engine defines the hosting engine (can be ignore if camera is set)
  109532. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  109533. */
  109534. constructor(name: string, _operator: TonemappingOperator,
  109535. /** Defines the required exposure adjustement */
  109536. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  109537. }
  109538. }
  109539. declare module BABYLON {
  109540. /** @hidden */
  109541. export var depthVertexShader: {
  109542. name: string;
  109543. shader: string;
  109544. };
  109545. }
  109546. declare module BABYLON {
  109547. /** @hidden */
  109548. export var volumetricLightScatteringPixelShader: {
  109549. name: string;
  109550. shader: string;
  109551. };
  109552. }
  109553. declare module BABYLON {
  109554. /** @hidden */
  109555. export var volumetricLightScatteringPassPixelShader: {
  109556. name: string;
  109557. shader: string;
  109558. };
  109559. }
  109560. declare module BABYLON {
  109561. /**
  109562. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  109563. */
  109564. export class VolumetricLightScatteringPostProcess extends PostProcess {
  109565. private _volumetricLightScatteringPass;
  109566. private _volumetricLightScatteringRTT;
  109567. private _viewPort;
  109568. private _screenCoordinates;
  109569. private _cachedDefines;
  109570. /**
  109571. * If not undefined, the mesh position is computed from the attached node position
  109572. */
  109573. attachedNode: {
  109574. position: Vector3;
  109575. };
  109576. /**
  109577. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  109578. */
  109579. customMeshPosition: Vector3;
  109580. /**
  109581. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  109582. */
  109583. useCustomMeshPosition: boolean;
  109584. /**
  109585. * If the post-process should inverse the light scattering direction
  109586. */
  109587. invert: boolean;
  109588. /**
  109589. * The internal mesh used by the post-process
  109590. */
  109591. mesh: Mesh;
  109592. /**
  109593. * @hidden
  109594. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  109595. */
  109596. useDiffuseColor: boolean;
  109597. /**
  109598. * Array containing the excluded meshes not rendered in the internal pass
  109599. */
  109600. excludedMeshes: AbstractMesh[];
  109601. /**
  109602. * Controls the overall intensity of the post-process
  109603. */
  109604. exposure: number;
  109605. /**
  109606. * Dissipates each sample's contribution in range [0, 1]
  109607. */
  109608. decay: number;
  109609. /**
  109610. * Controls the overall intensity of each sample
  109611. */
  109612. weight: number;
  109613. /**
  109614. * Controls the density of each sample
  109615. */
  109616. density: number;
  109617. /**
  109618. * @constructor
  109619. * @param name The post-process name
  109620. * @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)
  109621. * @param camera The camera that the post-process will be attached to
  109622. * @param mesh The mesh used to create the light scattering
  109623. * @param samples The post-process quality, default 100
  109624. * @param samplingModeThe post-process filtering mode
  109625. * @param engine The babylon engine
  109626. * @param reusable If the post-process is reusable
  109627. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  109628. */
  109629. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  109630. /**
  109631. * Returns the string "VolumetricLightScatteringPostProcess"
  109632. * @returns "VolumetricLightScatteringPostProcess"
  109633. */
  109634. getClassName(): string;
  109635. private _isReady;
  109636. /**
  109637. * Sets the new light position for light scattering effect
  109638. * @param position The new custom light position
  109639. */
  109640. setCustomMeshPosition(position: Vector3): void;
  109641. /**
  109642. * Returns the light position for light scattering effect
  109643. * @return Vector3 The custom light position
  109644. */
  109645. getCustomMeshPosition(): Vector3;
  109646. /**
  109647. * Disposes the internal assets and detaches the post-process from the camera
  109648. */
  109649. dispose(camera: Camera): void;
  109650. /**
  109651. * Returns the render target texture used by the post-process
  109652. * @return the render target texture used by the post-process
  109653. */
  109654. getPass(): RenderTargetTexture;
  109655. private _meshExcluded;
  109656. private _createPass;
  109657. private _updateMeshScreenCoordinates;
  109658. /**
  109659. * Creates a default mesh for the Volumeric Light Scattering post-process
  109660. * @param name The mesh name
  109661. * @param scene The scene where to create the mesh
  109662. * @return the default mesh
  109663. */
  109664. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  109665. }
  109666. }
  109667. declare module BABYLON {
  109668. interface Scene {
  109669. /** @hidden (Backing field) */
  109670. _boundingBoxRenderer: BoundingBoxRenderer;
  109671. /** @hidden (Backing field) */
  109672. _forceShowBoundingBoxes: boolean;
  109673. /**
  109674. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  109675. */
  109676. forceShowBoundingBoxes: boolean;
  109677. /**
  109678. * Gets the bounding box renderer associated with the scene
  109679. * @returns a BoundingBoxRenderer
  109680. */
  109681. getBoundingBoxRenderer(): BoundingBoxRenderer;
  109682. }
  109683. interface AbstractMesh {
  109684. /** @hidden (Backing field) */
  109685. _showBoundingBox: boolean;
  109686. /**
  109687. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  109688. */
  109689. showBoundingBox: boolean;
  109690. }
  109691. /**
  109692. * Component responsible of rendering the bounding box of the meshes in a scene.
  109693. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  109694. */
  109695. export class BoundingBoxRenderer implements ISceneComponent {
  109696. /**
  109697. * The component name helpfull to identify the component in the list of scene components.
  109698. */
  109699. readonly name: string;
  109700. /**
  109701. * The scene the component belongs to.
  109702. */
  109703. scene: Scene;
  109704. /**
  109705. * Color of the bounding box lines placed in front of an object
  109706. */
  109707. frontColor: Color3;
  109708. /**
  109709. * Color of the bounding box lines placed behind an object
  109710. */
  109711. backColor: Color3;
  109712. /**
  109713. * Defines if the renderer should show the back lines or not
  109714. */
  109715. showBackLines: boolean;
  109716. /**
  109717. * @hidden
  109718. */
  109719. renderList: SmartArray<BoundingBox>;
  109720. private _colorShader;
  109721. private _vertexBuffers;
  109722. private _indexBuffer;
  109723. /**
  109724. * Instantiates a new bounding box renderer in a scene.
  109725. * @param scene the scene the renderer renders in
  109726. */
  109727. constructor(scene: Scene);
  109728. /**
  109729. * Registers the component in a given scene
  109730. */
  109731. register(): void;
  109732. private _evaluateSubMesh;
  109733. private _activeMesh;
  109734. private _prepareRessources;
  109735. private _createIndexBuffer;
  109736. /**
  109737. * Rebuilds the elements related to this component in case of
  109738. * context lost for instance.
  109739. */
  109740. rebuild(): void;
  109741. /**
  109742. * @hidden
  109743. */
  109744. reset(): void;
  109745. /**
  109746. * Render the bounding boxes of a specific rendering group
  109747. * @param renderingGroupId defines the rendering group to render
  109748. */
  109749. render(renderingGroupId: number): void;
  109750. /**
  109751. * In case of occlusion queries, we can render the occlusion bounding box through this method
  109752. * @param mesh Define the mesh to render the occlusion bounding box for
  109753. */
  109754. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  109755. /**
  109756. * Dispose and release the resources attached to this renderer.
  109757. */
  109758. dispose(): void;
  109759. }
  109760. }
  109761. declare module BABYLON {
  109762. /** @hidden */
  109763. export var depthPixelShader: {
  109764. name: string;
  109765. shader: string;
  109766. };
  109767. }
  109768. declare module BABYLON {
  109769. /**
  109770. * This represents a depth renderer in Babylon.
  109771. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  109772. */
  109773. export class DepthRenderer {
  109774. private _scene;
  109775. private _depthMap;
  109776. private _effect;
  109777. private _cachedDefines;
  109778. private _camera;
  109779. /**
  109780. * Specifiess that the depth renderer will only be used within
  109781. * the camera it is created for.
  109782. * This can help forcing its rendering during the camera processing.
  109783. */
  109784. useOnlyInActiveCamera: boolean;
  109785. /** @hidden */
  109786. static _SceneComponentInitialization: (scene: Scene) => void;
  109787. /**
  109788. * Instantiates a depth renderer
  109789. * @param scene The scene the renderer belongs to
  109790. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  109791. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  109792. */
  109793. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  109794. /**
  109795. * Creates the depth rendering effect and checks if the effect is ready.
  109796. * @param subMesh The submesh to be used to render the depth map of
  109797. * @param useInstances If multiple world instances should be used
  109798. * @returns if the depth renderer is ready to render the depth map
  109799. */
  109800. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109801. /**
  109802. * Gets the texture which the depth map will be written to.
  109803. * @returns The depth map texture
  109804. */
  109805. getDepthMap(): RenderTargetTexture;
  109806. /**
  109807. * Disposes of the depth renderer.
  109808. */
  109809. dispose(): void;
  109810. }
  109811. }
  109812. declare module BABYLON {
  109813. interface Scene {
  109814. /** @hidden (Backing field) */
  109815. _depthRenderer: {
  109816. [id: string]: DepthRenderer;
  109817. };
  109818. /**
  109819. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  109820. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  109821. * @returns the created depth renderer
  109822. */
  109823. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  109824. /**
  109825. * Disables a depth renderer for a given camera
  109826. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  109827. */
  109828. disableDepthRenderer(camera?: Nullable<Camera>): void;
  109829. }
  109830. /**
  109831. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  109832. * in several rendering techniques.
  109833. */
  109834. export class DepthRendererSceneComponent implements ISceneComponent {
  109835. /**
  109836. * The component name helpfull to identify the component in the list of scene components.
  109837. */
  109838. readonly name: string;
  109839. /**
  109840. * The scene the component belongs to.
  109841. */
  109842. scene: Scene;
  109843. /**
  109844. * Creates a new instance of the component for the given scene
  109845. * @param scene Defines the scene to register the component in
  109846. */
  109847. constructor(scene: Scene);
  109848. /**
  109849. * Registers the component in a given scene
  109850. */
  109851. register(): void;
  109852. /**
  109853. * Rebuilds the elements related to this component in case of
  109854. * context lost for instance.
  109855. */
  109856. rebuild(): void;
  109857. /**
  109858. * Disposes the component and the associated ressources
  109859. */
  109860. dispose(): void;
  109861. private _gatherRenderTargets;
  109862. private _gatherActiveCameraRenderTargets;
  109863. }
  109864. }
  109865. declare module BABYLON {
  109866. interface Scene {
  109867. /** @hidden (Backing field) */
  109868. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  109869. /**
  109870. * Gets or Sets the current geometry buffer associated to the scene.
  109871. */
  109872. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  109873. /**
  109874. * Enables a GeometryBufferRender and associates it with the scene
  109875. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  109876. * @returns the GeometryBufferRenderer
  109877. */
  109878. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  109879. /**
  109880. * Disables the GeometryBufferRender associated with the scene
  109881. */
  109882. disableGeometryBufferRenderer(): void;
  109883. }
  109884. /**
  109885. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  109886. * in several rendering techniques.
  109887. */
  109888. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  109889. /**
  109890. * The component name helpful to identify the component in the list of scene components.
  109891. */
  109892. readonly name: string;
  109893. /**
  109894. * The scene the component belongs to.
  109895. */
  109896. scene: Scene;
  109897. /**
  109898. * Creates a new instance of the component for the given scene
  109899. * @param scene Defines the scene to register the component in
  109900. */
  109901. constructor(scene: Scene);
  109902. /**
  109903. * Registers the component in a given scene
  109904. */
  109905. register(): void;
  109906. /**
  109907. * Rebuilds the elements related to this component in case of
  109908. * context lost for instance.
  109909. */
  109910. rebuild(): void;
  109911. /**
  109912. * Disposes the component and the associated ressources
  109913. */
  109914. dispose(): void;
  109915. private _gatherRenderTargets;
  109916. }
  109917. }
  109918. declare module BABYLON {
  109919. /** @hidden */
  109920. export var outlinePixelShader: {
  109921. name: string;
  109922. shader: string;
  109923. };
  109924. }
  109925. declare module BABYLON {
  109926. /** @hidden */
  109927. export var outlineVertexShader: {
  109928. name: string;
  109929. shader: string;
  109930. };
  109931. }
  109932. declare module BABYLON {
  109933. interface Scene {
  109934. /** @hidden */
  109935. _outlineRenderer: OutlineRenderer;
  109936. /**
  109937. * Gets the outline renderer associated with the scene
  109938. * @returns a OutlineRenderer
  109939. */
  109940. getOutlineRenderer(): OutlineRenderer;
  109941. }
  109942. interface AbstractMesh {
  109943. /** @hidden (Backing field) */
  109944. _renderOutline: boolean;
  109945. /**
  109946. * Gets or sets a boolean indicating if the outline must be rendered as well
  109947. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  109948. */
  109949. renderOutline: boolean;
  109950. /** @hidden (Backing field) */
  109951. _renderOverlay: boolean;
  109952. /**
  109953. * Gets or sets a boolean indicating if the overlay must be rendered as well
  109954. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  109955. */
  109956. renderOverlay: boolean;
  109957. }
  109958. /**
  109959. * This class is responsible to draw bothe outline/overlay of meshes.
  109960. * It should not be used directly but through the available method on mesh.
  109961. */
  109962. export class OutlineRenderer implements ISceneComponent {
  109963. /**
  109964. * The name of the component. Each component must have a unique name.
  109965. */
  109966. name: string;
  109967. /**
  109968. * The scene the component belongs to.
  109969. */
  109970. scene: Scene;
  109971. /**
  109972. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  109973. */
  109974. zOffset: number;
  109975. private _engine;
  109976. private _effect;
  109977. private _cachedDefines;
  109978. private _savedDepthWrite;
  109979. /**
  109980. * Instantiates a new outline renderer. (There could be only one per scene).
  109981. * @param scene Defines the scene it belongs to
  109982. */
  109983. constructor(scene: Scene);
  109984. /**
  109985. * Register the component to one instance of a scene.
  109986. */
  109987. register(): void;
  109988. /**
  109989. * Rebuilds the elements related to this component in case of
  109990. * context lost for instance.
  109991. */
  109992. rebuild(): void;
  109993. /**
  109994. * Disposes the component and the associated ressources.
  109995. */
  109996. dispose(): void;
  109997. /**
  109998. * Renders the outline in the canvas.
  109999. * @param subMesh Defines the sumesh to render
  110000. * @param batch Defines the batch of meshes in case of instances
  110001. * @param useOverlay Defines if the rendering is for the overlay or the outline
  110002. */
  110003. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  110004. /**
  110005. * Returns whether or not the outline renderer is ready for a given submesh.
  110006. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  110007. * @param subMesh Defines the submesh to check readyness for
  110008. * @param useInstances Defines wheter wee are trying to render instances or not
  110009. * @returns true if ready otherwise false
  110010. */
  110011. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110012. private _beforeRenderingMesh;
  110013. private _afterRenderingMesh;
  110014. }
  110015. }
  110016. declare module BABYLON {
  110017. /**
  110018. * Defines the list of states available for a task inside a AssetsManager
  110019. */
  110020. export enum AssetTaskState {
  110021. /**
  110022. * Initialization
  110023. */
  110024. INIT = 0,
  110025. /**
  110026. * Running
  110027. */
  110028. RUNNING = 1,
  110029. /**
  110030. * Done
  110031. */
  110032. DONE = 2,
  110033. /**
  110034. * Error
  110035. */
  110036. ERROR = 3
  110037. }
  110038. /**
  110039. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  110040. */
  110041. export abstract class AbstractAssetTask {
  110042. /**
  110043. * Task name
  110044. */ name: string;
  110045. /**
  110046. * Callback called when the task is successful
  110047. */
  110048. onSuccess: (task: any) => void;
  110049. /**
  110050. * Callback called when the task is not successful
  110051. */
  110052. onError: (task: any, message?: string, exception?: any) => void;
  110053. /**
  110054. * Creates a new AssetsManager
  110055. * @param name defines the name of the task
  110056. */
  110057. constructor(
  110058. /**
  110059. * Task name
  110060. */ name: string);
  110061. private _isCompleted;
  110062. private _taskState;
  110063. private _errorObject;
  110064. /**
  110065. * Get if the task is completed
  110066. */
  110067. readonly isCompleted: boolean;
  110068. /**
  110069. * Gets the current state of the task
  110070. */
  110071. readonly taskState: AssetTaskState;
  110072. /**
  110073. * Gets the current error object (if task is in error)
  110074. */
  110075. readonly errorObject: {
  110076. message?: string;
  110077. exception?: any;
  110078. };
  110079. /**
  110080. * Internal only
  110081. * @hidden
  110082. */
  110083. _setErrorObject(message?: string, exception?: any): void;
  110084. /**
  110085. * Execute the current task
  110086. * @param scene defines the scene where you want your assets to be loaded
  110087. * @param onSuccess is a callback called when the task is successfully executed
  110088. * @param onError is a callback called if an error occurs
  110089. */
  110090. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110091. /**
  110092. * Execute the current task
  110093. * @param scene defines the scene where you want your assets to be loaded
  110094. * @param onSuccess is a callback called when the task is successfully executed
  110095. * @param onError is a callback called if an error occurs
  110096. */
  110097. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110098. /**
  110099. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  110100. * This can be used with failed tasks that have the reason for failure fixed.
  110101. */
  110102. reset(): void;
  110103. private onErrorCallback;
  110104. private onDoneCallback;
  110105. }
  110106. /**
  110107. * Define the interface used by progress events raised during assets loading
  110108. */
  110109. export interface IAssetsProgressEvent {
  110110. /**
  110111. * Defines the number of remaining tasks to process
  110112. */
  110113. remainingCount: number;
  110114. /**
  110115. * Defines the total number of tasks
  110116. */
  110117. totalCount: number;
  110118. /**
  110119. * Defines the task that was just processed
  110120. */
  110121. task: AbstractAssetTask;
  110122. }
  110123. /**
  110124. * Class used to share progress information about assets loading
  110125. */
  110126. export class AssetsProgressEvent implements IAssetsProgressEvent {
  110127. /**
  110128. * Defines the number of remaining tasks to process
  110129. */
  110130. remainingCount: number;
  110131. /**
  110132. * Defines the total number of tasks
  110133. */
  110134. totalCount: number;
  110135. /**
  110136. * Defines the task that was just processed
  110137. */
  110138. task: AbstractAssetTask;
  110139. /**
  110140. * Creates a AssetsProgressEvent
  110141. * @param remainingCount defines the number of remaining tasks to process
  110142. * @param totalCount defines the total number of tasks
  110143. * @param task defines the task that was just processed
  110144. */
  110145. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  110146. }
  110147. /**
  110148. * Define a task used by AssetsManager to load meshes
  110149. */
  110150. export class MeshAssetTask extends AbstractAssetTask {
  110151. /**
  110152. * Defines the name of the task
  110153. */
  110154. name: string;
  110155. /**
  110156. * Defines the list of mesh's names you want to load
  110157. */
  110158. meshesNames: any;
  110159. /**
  110160. * Defines the root url to use as a base to load your meshes and associated resources
  110161. */
  110162. rootUrl: string;
  110163. /**
  110164. * Defines the filename of the scene to load from
  110165. */
  110166. sceneFilename: string;
  110167. /**
  110168. * Gets the list of loaded meshes
  110169. */
  110170. loadedMeshes: Array<AbstractMesh>;
  110171. /**
  110172. * Gets the list of loaded particle systems
  110173. */
  110174. loadedParticleSystems: Array<IParticleSystem>;
  110175. /**
  110176. * Gets the list of loaded skeletons
  110177. */
  110178. loadedSkeletons: Array<Skeleton>;
  110179. /**
  110180. * Gets the list of loaded animation groups
  110181. */
  110182. loadedAnimationGroups: Array<AnimationGroup>;
  110183. /**
  110184. * Callback called when the task is successful
  110185. */
  110186. onSuccess: (task: MeshAssetTask) => void;
  110187. /**
  110188. * Callback called when the task is successful
  110189. */
  110190. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  110191. /**
  110192. * Creates a new MeshAssetTask
  110193. * @param name defines the name of the task
  110194. * @param meshesNames defines the list of mesh's names you want to load
  110195. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  110196. * @param sceneFilename defines the filename of the scene to load from
  110197. */
  110198. constructor(
  110199. /**
  110200. * Defines the name of the task
  110201. */
  110202. name: string,
  110203. /**
  110204. * Defines the list of mesh's names you want to load
  110205. */
  110206. meshesNames: any,
  110207. /**
  110208. * Defines the root url to use as a base to load your meshes and associated resources
  110209. */
  110210. rootUrl: string,
  110211. /**
  110212. * Defines the filename of the scene to load from
  110213. */
  110214. sceneFilename: string);
  110215. /**
  110216. * Execute the current task
  110217. * @param scene defines the scene where you want your assets to be loaded
  110218. * @param onSuccess is a callback called when the task is successfully executed
  110219. * @param onError is a callback called if an error occurs
  110220. */
  110221. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110222. }
  110223. /**
  110224. * Define a task used by AssetsManager to load text content
  110225. */
  110226. export class TextFileAssetTask extends AbstractAssetTask {
  110227. /**
  110228. * Defines the name of the task
  110229. */
  110230. name: string;
  110231. /**
  110232. * Defines the location of the file to load
  110233. */
  110234. url: string;
  110235. /**
  110236. * Gets the loaded text string
  110237. */
  110238. text: string;
  110239. /**
  110240. * Callback called when the task is successful
  110241. */
  110242. onSuccess: (task: TextFileAssetTask) => void;
  110243. /**
  110244. * Callback called when the task is successful
  110245. */
  110246. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  110247. /**
  110248. * Creates a new TextFileAssetTask object
  110249. * @param name defines the name of the task
  110250. * @param url defines the location of the file to load
  110251. */
  110252. constructor(
  110253. /**
  110254. * Defines the name of the task
  110255. */
  110256. name: string,
  110257. /**
  110258. * Defines the location of the file to load
  110259. */
  110260. url: string);
  110261. /**
  110262. * Execute the current task
  110263. * @param scene defines the scene where you want your assets to be loaded
  110264. * @param onSuccess is a callback called when the task is successfully executed
  110265. * @param onError is a callback called if an error occurs
  110266. */
  110267. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110268. }
  110269. /**
  110270. * Define a task used by AssetsManager to load binary data
  110271. */
  110272. export class BinaryFileAssetTask extends AbstractAssetTask {
  110273. /**
  110274. * Defines the name of the task
  110275. */
  110276. name: string;
  110277. /**
  110278. * Defines the location of the file to load
  110279. */
  110280. url: string;
  110281. /**
  110282. * Gets the lodaded data (as an array buffer)
  110283. */
  110284. data: ArrayBuffer;
  110285. /**
  110286. * Callback called when the task is successful
  110287. */
  110288. onSuccess: (task: BinaryFileAssetTask) => void;
  110289. /**
  110290. * Callback called when the task is successful
  110291. */
  110292. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  110293. /**
  110294. * Creates a new BinaryFileAssetTask object
  110295. * @param name defines the name of the new task
  110296. * @param url defines the location of the file to load
  110297. */
  110298. constructor(
  110299. /**
  110300. * Defines the name of the task
  110301. */
  110302. name: string,
  110303. /**
  110304. * Defines the location of the file to load
  110305. */
  110306. url: string);
  110307. /**
  110308. * Execute the current task
  110309. * @param scene defines the scene where you want your assets to be loaded
  110310. * @param onSuccess is a callback called when the task is successfully executed
  110311. * @param onError is a callback called if an error occurs
  110312. */
  110313. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110314. }
  110315. /**
  110316. * Define a task used by AssetsManager to load images
  110317. */
  110318. export class ImageAssetTask extends AbstractAssetTask {
  110319. /**
  110320. * Defines the name of the task
  110321. */
  110322. name: string;
  110323. /**
  110324. * Defines the location of the image to load
  110325. */
  110326. url: string;
  110327. /**
  110328. * Gets the loaded images
  110329. */
  110330. image: HTMLImageElement;
  110331. /**
  110332. * Callback called when the task is successful
  110333. */
  110334. onSuccess: (task: ImageAssetTask) => void;
  110335. /**
  110336. * Callback called when the task is successful
  110337. */
  110338. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  110339. /**
  110340. * Creates a new ImageAssetTask
  110341. * @param name defines the name of the task
  110342. * @param url defines the location of the image to load
  110343. */
  110344. constructor(
  110345. /**
  110346. * Defines the name of the task
  110347. */
  110348. name: string,
  110349. /**
  110350. * Defines the location of the image to load
  110351. */
  110352. url: string);
  110353. /**
  110354. * Execute the current task
  110355. * @param scene defines the scene where you want your assets to be loaded
  110356. * @param onSuccess is a callback called when the task is successfully executed
  110357. * @param onError is a callback called if an error occurs
  110358. */
  110359. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110360. }
  110361. /**
  110362. * Defines the interface used by texture loading tasks
  110363. */
  110364. export interface ITextureAssetTask<TEX extends BaseTexture> {
  110365. /**
  110366. * Gets the loaded texture
  110367. */
  110368. texture: TEX;
  110369. }
  110370. /**
  110371. * Define a task used by AssetsManager to load 2D textures
  110372. */
  110373. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  110374. /**
  110375. * Defines the name of the task
  110376. */
  110377. name: string;
  110378. /**
  110379. * Defines the location of the file to load
  110380. */
  110381. url: string;
  110382. /**
  110383. * Defines if mipmap should not be generated (default is false)
  110384. */
  110385. noMipmap?: boolean | undefined;
  110386. /**
  110387. * Defines if texture must be inverted on Y axis (default is false)
  110388. */
  110389. invertY?: boolean | undefined;
  110390. /**
  110391. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110392. */
  110393. samplingMode: number;
  110394. /**
  110395. * Gets the loaded texture
  110396. */
  110397. texture: Texture;
  110398. /**
  110399. * Callback called when the task is successful
  110400. */
  110401. onSuccess: (task: TextureAssetTask) => void;
  110402. /**
  110403. * Callback called when the task is successful
  110404. */
  110405. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  110406. /**
  110407. * Creates a new TextureAssetTask object
  110408. * @param name defines the name of the task
  110409. * @param url defines the location of the file to load
  110410. * @param noMipmap defines if mipmap should not be generated (default is false)
  110411. * @param invertY defines if texture must be inverted on Y axis (default is false)
  110412. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110413. */
  110414. constructor(
  110415. /**
  110416. * Defines the name of the task
  110417. */
  110418. name: string,
  110419. /**
  110420. * Defines the location of the file to load
  110421. */
  110422. url: string,
  110423. /**
  110424. * Defines if mipmap should not be generated (default is false)
  110425. */
  110426. noMipmap?: boolean | undefined,
  110427. /**
  110428. * Defines if texture must be inverted on Y axis (default is false)
  110429. */
  110430. invertY?: boolean | undefined,
  110431. /**
  110432. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110433. */
  110434. samplingMode?: number);
  110435. /**
  110436. * Execute the current task
  110437. * @param scene defines the scene where you want your assets to be loaded
  110438. * @param onSuccess is a callback called when the task is successfully executed
  110439. * @param onError is a callback called if an error occurs
  110440. */
  110441. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110442. }
  110443. /**
  110444. * Define a task used by AssetsManager to load cube textures
  110445. */
  110446. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  110447. /**
  110448. * Defines the name of the task
  110449. */
  110450. name: string;
  110451. /**
  110452. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  110453. */
  110454. url: string;
  110455. /**
  110456. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  110457. */
  110458. extensions?: string[] | undefined;
  110459. /**
  110460. * Defines if mipmaps should not be generated (default is false)
  110461. */
  110462. noMipmap?: boolean | undefined;
  110463. /**
  110464. * Defines the explicit list of files (undefined by default)
  110465. */
  110466. files?: string[] | undefined;
  110467. /**
  110468. * Gets the loaded texture
  110469. */
  110470. texture: CubeTexture;
  110471. /**
  110472. * Callback called when the task is successful
  110473. */
  110474. onSuccess: (task: CubeTextureAssetTask) => void;
  110475. /**
  110476. * Callback called when the task is successful
  110477. */
  110478. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  110479. /**
  110480. * Creates a new CubeTextureAssetTask
  110481. * @param name defines the name of the task
  110482. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  110483. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  110484. * @param noMipmap defines if mipmaps should not be generated (default is false)
  110485. * @param files defines the explicit list of files (undefined by default)
  110486. */
  110487. constructor(
  110488. /**
  110489. * Defines the name of the task
  110490. */
  110491. name: string,
  110492. /**
  110493. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  110494. */
  110495. url: string,
  110496. /**
  110497. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  110498. */
  110499. extensions?: string[] | undefined,
  110500. /**
  110501. * Defines if mipmaps should not be generated (default is false)
  110502. */
  110503. noMipmap?: boolean | undefined,
  110504. /**
  110505. * Defines the explicit list of files (undefined by default)
  110506. */
  110507. files?: string[] | undefined);
  110508. /**
  110509. * Execute the current task
  110510. * @param scene defines the scene where you want your assets to be loaded
  110511. * @param onSuccess is a callback called when the task is successfully executed
  110512. * @param onError is a callback called if an error occurs
  110513. */
  110514. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110515. }
  110516. /**
  110517. * Define a task used by AssetsManager to load HDR cube textures
  110518. */
  110519. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  110520. /**
  110521. * Defines the name of the task
  110522. */
  110523. name: string;
  110524. /**
  110525. * Defines the location of the file to load
  110526. */
  110527. url: string;
  110528. /**
  110529. * Defines the desired size (the more it increases the longer the generation will be)
  110530. */
  110531. size: number;
  110532. /**
  110533. * Defines if mipmaps should not be generated (default is false)
  110534. */
  110535. noMipmap: boolean;
  110536. /**
  110537. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  110538. */
  110539. generateHarmonics: boolean;
  110540. /**
  110541. * 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)
  110542. */
  110543. gammaSpace: boolean;
  110544. /**
  110545. * Internal Use Only
  110546. */
  110547. reserved: boolean;
  110548. /**
  110549. * Gets the loaded texture
  110550. */
  110551. texture: HDRCubeTexture;
  110552. /**
  110553. * Callback called when the task is successful
  110554. */
  110555. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  110556. /**
  110557. * Callback called when the task is successful
  110558. */
  110559. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  110560. /**
  110561. * Creates a new HDRCubeTextureAssetTask object
  110562. * @param name defines the name of the task
  110563. * @param url defines the location of the file to load
  110564. * @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.
  110565. * @param noMipmap defines if mipmaps should not be generated (default is false)
  110566. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  110567. * @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)
  110568. * @param reserved Internal use only
  110569. */
  110570. constructor(
  110571. /**
  110572. * Defines the name of the task
  110573. */
  110574. name: string,
  110575. /**
  110576. * Defines the location of the file to load
  110577. */
  110578. url: string,
  110579. /**
  110580. * Defines the desired size (the more it increases the longer the generation will be)
  110581. */
  110582. size: number,
  110583. /**
  110584. * Defines if mipmaps should not be generated (default is false)
  110585. */
  110586. noMipmap?: boolean,
  110587. /**
  110588. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  110589. */
  110590. generateHarmonics?: boolean,
  110591. /**
  110592. * 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)
  110593. */
  110594. gammaSpace?: boolean,
  110595. /**
  110596. * Internal Use Only
  110597. */
  110598. reserved?: boolean);
  110599. /**
  110600. * Execute the current task
  110601. * @param scene defines the scene where you want your assets to be loaded
  110602. * @param onSuccess is a callback called when the task is successfully executed
  110603. * @param onError is a callback called if an error occurs
  110604. */
  110605. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110606. }
  110607. /**
  110608. * This class can be used to easily import assets into a scene
  110609. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  110610. */
  110611. export class AssetsManager {
  110612. private _scene;
  110613. private _isLoading;
  110614. protected _tasks: AbstractAssetTask[];
  110615. protected _waitingTasksCount: number;
  110616. protected _totalTasksCount: number;
  110617. /**
  110618. * Callback called when all tasks are processed
  110619. */
  110620. onFinish: (tasks: AbstractAssetTask[]) => void;
  110621. /**
  110622. * Callback called when a task is successful
  110623. */
  110624. onTaskSuccess: (task: AbstractAssetTask) => void;
  110625. /**
  110626. * Callback called when a task had an error
  110627. */
  110628. onTaskError: (task: AbstractAssetTask) => void;
  110629. /**
  110630. * Callback called when a task is done (whatever the result is)
  110631. */
  110632. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  110633. /**
  110634. * Observable called when all tasks are processed
  110635. */
  110636. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  110637. /**
  110638. * Observable called when a task had an error
  110639. */
  110640. onTaskErrorObservable: Observable<AbstractAssetTask>;
  110641. /**
  110642. * Observable called when a task is successful
  110643. */
  110644. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  110645. /**
  110646. * Observable called when a task is done (whatever the result is)
  110647. */
  110648. onProgressObservable: Observable<IAssetsProgressEvent>;
  110649. /**
  110650. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  110651. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110652. */
  110653. useDefaultLoadingScreen: boolean;
  110654. /**
  110655. * Creates a new AssetsManager
  110656. * @param scene defines the scene to work on
  110657. */
  110658. constructor(scene: Scene);
  110659. /**
  110660. * Add a MeshAssetTask to the list of active tasks
  110661. * @param taskName defines the name of the new task
  110662. * @param meshesNames defines the name of meshes to load
  110663. * @param rootUrl defines the root url to use to locate files
  110664. * @param sceneFilename defines the filename of the scene file
  110665. * @returns a new MeshAssetTask object
  110666. */
  110667. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  110668. /**
  110669. * Add a TextFileAssetTask to the list of active tasks
  110670. * @param taskName defines the name of the new task
  110671. * @param url defines the url of the file to load
  110672. * @returns a new TextFileAssetTask object
  110673. */
  110674. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  110675. /**
  110676. * Add a BinaryFileAssetTask to the list of active tasks
  110677. * @param taskName defines the name of the new task
  110678. * @param url defines the url of the file to load
  110679. * @returns a new BinaryFileAssetTask object
  110680. */
  110681. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  110682. /**
  110683. * Add a ImageAssetTask to the list of active tasks
  110684. * @param taskName defines the name of the new task
  110685. * @param url defines the url of the file to load
  110686. * @returns a new ImageAssetTask object
  110687. */
  110688. addImageTask(taskName: string, url: string): ImageAssetTask;
  110689. /**
  110690. * Add a TextureAssetTask to the list of active tasks
  110691. * @param taskName defines the name of the new task
  110692. * @param url defines the url of the file to load
  110693. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  110694. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  110695. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  110696. * @returns a new TextureAssetTask object
  110697. */
  110698. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  110699. /**
  110700. * Add a CubeTextureAssetTask to the list of active tasks
  110701. * @param taskName defines the name of the new task
  110702. * @param url defines the url of the file to load
  110703. * @param extensions defines the extension to use to load the cube map (can be null)
  110704. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  110705. * @param files defines the list of files to load (can be null)
  110706. * @returns a new CubeTextureAssetTask object
  110707. */
  110708. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  110709. /**
  110710. *
  110711. * Add a HDRCubeTextureAssetTask to the list of active tasks
  110712. * @param taskName defines the name of the new task
  110713. * @param url defines the url of the file to load
  110714. * @param size defines the size you want for the cubemap (can be null)
  110715. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  110716. * @param generateHarmonics defines if you want to automatically generate (true by default)
  110717. * @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)
  110718. * @param reserved Internal use only
  110719. * @returns a new HDRCubeTextureAssetTask object
  110720. */
  110721. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  110722. /**
  110723. * Remove a task from the assets manager.
  110724. * @param task the task to remove
  110725. */
  110726. removeTask(task: AbstractAssetTask): void;
  110727. private _decreaseWaitingTasksCount;
  110728. private _runTask;
  110729. /**
  110730. * Reset the AssetsManager and remove all tasks
  110731. * @return the current instance of the AssetsManager
  110732. */
  110733. reset(): AssetsManager;
  110734. /**
  110735. * Start the loading process
  110736. * @return the current instance of the AssetsManager
  110737. */
  110738. load(): AssetsManager;
  110739. }
  110740. }
  110741. declare module BABYLON {
  110742. /**
  110743. * Wrapper class for promise with external resolve and reject.
  110744. */
  110745. export class Deferred<T> {
  110746. /**
  110747. * The promise associated with this deferred object.
  110748. */
  110749. readonly promise: Promise<T>;
  110750. private _resolve;
  110751. private _reject;
  110752. /**
  110753. * The resolve method of the promise associated with this deferred object.
  110754. */
  110755. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  110756. /**
  110757. * The reject method of the promise associated with this deferred object.
  110758. */
  110759. readonly reject: (reason?: any) => void;
  110760. /**
  110761. * Constructor for this deferred object.
  110762. */
  110763. constructor();
  110764. }
  110765. }
  110766. declare module BABYLON {
  110767. /**
  110768. * Class used to help managing file picking and drag'n'drop
  110769. */
  110770. export class FilesInput {
  110771. /**
  110772. * List of files ready to be loaded
  110773. */
  110774. static readonly FilesToLoad: {
  110775. [key: string]: File;
  110776. };
  110777. /**
  110778. * Callback called when a file is processed
  110779. */
  110780. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  110781. private _engine;
  110782. private _currentScene;
  110783. private _sceneLoadedCallback;
  110784. private _progressCallback;
  110785. private _additionalRenderLoopLogicCallback;
  110786. private _textureLoadingCallback;
  110787. private _startingProcessingFilesCallback;
  110788. private _onReloadCallback;
  110789. private _errorCallback;
  110790. private _elementToMonitor;
  110791. private _sceneFileToLoad;
  110792. private _filesToLoad;
  110793. /**
  110794. * Creates a new FilesInput
  110795. * @param engine defines the rendering engine
  110796. * @param scene defines the hosting scene
  110797. * @param sceneLoadedCallback callback called when scene is loaded
  110798. * @param progressCallback callback called to track progress
  110799. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  110800. * @param textureLoadingCallback callback called when a texture is loading
  110801. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  110802. * @param onReloadCallback callback called when a reload is requested
  110803. * @param errorCallback callback call if an error occurs
  110804. */
  110805. 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);
  110806. private _dragEnterHandler;
  110807. private _dragOverHandler;
  110808. private _dropHandler;
  110809. /**
  110810. * Calls this function to listen to drag'n'drop events on a specific DOM element
  110811. * @param elementToMonitor defines the DOM element to track
  110812. */
  110813. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  110814. /**
  110815. * Release all associated resources
  110816. */
  110817. dispose(): void;
  110818. private renderFunction;
  110819. private drag;
  110820. private drop;
  110821. private _traverseFolder;
  110822. private _processFiles;
  110823. /**
  110824. * Load files from a drop event
  110825. * @param event defines the drop event to use as source
  110826. */
  110827. loadFiles(event: any): void;
  110828. private _processReload;
  110829. /**
  110830. * Reload the current scene from the loaded files
  110831. */
  110832. reload(): void;
  110833. }
  110834. }
  110835. declare module BABYLON {
  110836. /**
  110837. * Defines the root class used to create scene optimization to use with SceneOptimizer
  110838. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110839. */
  110840. export class SceneOptimization {
  110841. /**
  110842. * Defines the priority of this optimization (0 by default which means first in the list)
  110843. */
  110844. priority: number;
  110845. /**
  110846. * Gets a string describing the action executed by the current optimization
  110847. * @returns description string
  110848. */
  110849. getDescription(): string;
  110850. /**
  110851. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110852. * @param scene defines the current scene where to apply this optimization
  110853. * @param optimizer defines the current optimizer
  110854. * @returns true if everything that can be done was applied
  110855. */
  110856. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110857. /**
  110858. * Creates the SceneOptimization object
  110859. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  110860. * @param desc defines the description associated with the optimization
  110861. */
  110862. constructor(
  110863. /**
  110864. * Defines the priority of this optimization (0 by default which means first in the list)
  110865. */
  110866. priority?: number);
  110867. }
  110868. /**
  110869. * Defines an optimization used to reduce the size of render target textures
  110870. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110871. */
  110872. export class TextureOptimization extends SceneOptimization {
  110873. /**
  110874. * Defines the priority of this optimization (0 by default which means first in the list)
  110875. */
  110876. priority: number;
  110877. /**
  110878. * 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
  110879. */
  110880. maximumSize: number;
  110881. /**
  110882. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  110883. */
  110884. step: number;
  110885. /**
  110886. * Gets a string describing the action executed by the current optimization
  110887. * @returns description string
  110888. */
  110889. getDescription(): string;
  110890. /**
  110891. * Creates the TextureOptimization object
  110892. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  110893. * @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
  110894. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  110895. */
  110896. constructor(
  110897. /**
  110898. * Defines the priority of this optimization (0 by default which means first in the list)
  110899. */
  110900. priority?: number,
  110901. /**
  110902. * 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
  110903. */
  110904. maximumSize?: number,
  110905. /**
  110906. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  110907. */
  110908. step?: number);
  110909. /**
  110910. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110911. * @param scene defines the current scene where to apply this optimization
  110912. * @param optimizer defines the current optimizer
  110913. * @returns true if everything that can be done was applied
  110914. */
  110915. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110916. }
  110917. /**
  110918. * Defines an optimization used to increase or decrease the rendering resolution
  110919. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110920. */
  110921. export class HardwareScalingOptimization extends SceneOptimization {
  110922. /**
  110923. * Defines the priority of this optimization (0 by default which means first in the list)
  110924. */
  110925. priority: number;
  110926. /**
  110927. * Defines the maximum scale to use (2 by default)
  110928. */
  110929. maximumScale: number;
  110930. /**
  110931. * Defines the step to use between two passes (0.5 by default)
  110932. */
  110933. step: number;
  110934. private _currentScale;
  110935. private _directionOffset;
  110936. /**
  110937. * Gets a string describing the action executed by the current optimization
  110938. * @return description string
  110939. */
  110940. getDescription(): string;
  110941. /**
  110942. * Creates the HardwareScalingOptimization object
  110943. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  110944. * @param maximumScale defines the maximum scale to use (2 by default)
  110945. * @param step defines the step to use between two passes (0.5 by default)
  110946. */
  110947. constructor(
  110948. /**
  110949. * Defines the priority of this optimization (0 by default which means first in the list)
  110950. */
  110951. priority?: number,
  110952. /**
  110953. * Defines the maximum scale to use (2 by default)
  110954. */
  110955. maximumScale?: number,
  110956. /**
  110957. * Defines the step to use between two passes (0.5 by default)
  110958. */
  110959. step?: number);
  110960. /**
  110961. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110962. * @param scene defines the current scene where to apply this optimization
  110963. * @param optimizer defines the current optimizer
  110964. * @returns true if everything that can be done was applied
  110965. */
  110966. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110967. }
  110968. /**
  110969. * Defines an optimization used to remove shadows
  110970. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110971. */
  110972. export class ShadowsOptimization extends SceneOptimization {
  110973. /**
  110974. * Gets a string describing the action executed by the current optimization
  110975. * @return description string
  110976. */
  110977. getDescription(): string;
  110978. /**
  110979. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110980. * @param scene defines the current scene where to apply this optimization
  110981. * @param optimizer defines the current optimizer
  110982. * @returns true if everything that can be done was applied
  110983. */
  110984. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110985. }
  110986. /**
  110987. * Defines an optimization used to turn post-processes off
  110988. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110989. */
  110990. export class PostProcessesOptimization extends SceneOptimization {
  110991. /**
  110992. * Gets a string describing the action executed by the current optimization
  110993. * @return description string
  110994. */
  110995. getDescription(): string;
  110996. /**
  110997. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110998. * @param scene defines the current scene where to apply this optimization
  110999. * @param optimizer defines the current optimizer
  111000. * @returns true if everything that can be done was applied
  111001. */
  111002. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111003. }
  111004. /**
  111005. * Defines an optimization used to turn lens flares off
  111006. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111007. */
  111008. export class LensFlaresOptimization extends SceneOptimization {
  111009. /**
  111010. * Gets a string describing the action executed by the current optimization
  111011. * @return description string
  111012. */
  111013. getDescription(): string;
  111014. /**
  111015. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111016. * @param scene defines the current scene where to apply this optimization
  111017. * @param optimizer defines the current optimizer
  111018. * @returns true if everything that can be done was applied
  111019. */
  111020. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111021. }
  111022. /**
  111023. * Defines an optimization based on user defined callback.
  111024. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111025. */
  111026. export class CustomOptimization extends SceneOptimization {
  111027. /**
  111028. * Callback called to apply the custom optimization.
  111029. */
  111030. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  111031. /**
  111032. * Callback called to get custom description
  111033. */
  111034. onGetDescription: () => string;
  111035. /**
  111036. * Gets a string describing the action executed by the current optimization
  111037. * @returns description string
  111038. */
  111039. getDescription(): string;
  111040. /**
  111041. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111042. * @param scene defines the current scene where to apply this optimization
  111043. * @param optimizer defines the current optimizer
  111044. * @returns true if everything that can be done was applied
  111045. */
  111046. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111047. }
  111048. /**
  111049. * Defines an optimization used to turn particles off
  111050. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111051. */
  111052. export class ParticlesOptimization extends SceneOptimization {
  111053. /**
  111054. * Gets a string describing the action executed by the current optimization
  111055. * @return description string
  111056. */
  111057. getDescription(): string;
  111058. /**
  111059. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111060. * @param scene defines the current scene where to apply this optimization
  111061. * @param optimizer defines the current optimizer
  111062. * @returns true if everything that can be done was applied
  111063. */
  111064. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111065. }
  111066. /**
  111067. * Defines an optimization used to turn render targets off
  111068. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111069. */
  111070. export class RenderTargetsOptimization extends SceneOptimization {
  111071. /**
  111072. * Gets a string describing the action executed by the current optimization
  111073. * @return description string
  111074. */
  111075. getDescription(): string;
  111076. /**
  111077. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111078. * @param scene defines the current scene where to apply this optimization
  111079. * @param optimizer defines the current optimizer
  111080. * @returns true if everything that can be done was applied
  111081. */
  111082. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111083. }
  111084. /**
  111085. * Defines an optimization used to merge meshes with compatible materials
  111086. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111087. */
  111088. export class MergeMeshesOptimization extends SceneOptimization {
  111089. private static _UpdateSelectionTree;
  111090. /**
  111091. * Gets or sets a boolean which defines if optimization octree has to be updated
  111092. */
  111093. /**
  111094. * Gets or sets a boolean which defines if optimization octree has to be updated
  111095. */
  111096. static UpdateSelectionTree: boolean;
  111097. /**
  111098. * Gets a string describing the action executed by the current optimization
  111099. * @return description string
  111100. */
  111101. getDescription(): string;
  111102. private _canBeMerged;
  111103. /**
  111104. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111105. * @param scene defines the current scene where to apply this optimization
  111106. * @param optimizer defines the current optimizer
  111107. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  111108. * @returns true if everything that can be done was applied
  111109. */
  111110. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  111111. }
  111112. /**
  111113. * Defines a list of options used by SceneOptimizer
  111114. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111115. */
  111116. export class SceneOptimizerOptions {
  111117. /**
  111118. * Defines the target frame rate to reach (60 by default)
  111119. */
  111120. targetFrameRate: number;
  111121. /**
  111122. * Defines the interval between two checkes (2000ms by default)
  111123. */
  111124. trackerDuration: number;
  111125. /**
  111126. * Gets the list of optimizations to apply
  111127. */
  111128. optimizations: SceneOptimization[];
  111129. /**
  111130. * Creates a new list of options used by SceneOptimizer
  111131. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  111132. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  111133. */
  111134. constructor(
  111135. /**
  111136. * Defines the target frame rate to reach (60 by default)
  111137. */
  111138. targetFrameRate?: number,
  111139. /**
  111140. * Defines the interval between two checkes (2000ms by default)
  111141. */
  111142. trackerDuration?: number);
  111143. /**
  111144. * Add a new optimization
  111145. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  111146. * @returns the current SceneOptimizerOptions
  111147. */
  111148. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  111149. /**
  111150. * Add a new custom optimization
  111151. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  111152. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  111153. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111154. * @returns the current SceneOptimizerOptions
  111155. */
  111156. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  111157. /**
  111158. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  111159. * @param targetFrameRate defines the target frame rate (60 by default)
  111160. * @returns a SceneOptimizerOptions object
  111161. */
  111162. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111163. /**
  111164. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  111165. * @param targetFrameRate defines the target frame rate (60 by default)
  111166. * @returns a SceneOptimizerOptions object
  111167. */
  111168. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111169. /**
  111170. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  111171. * @param targetFrameRate defines the target frame rate (60 by default)
  111172. * @returns a SceneOptimizerOptions object
  111173. */
  111174. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111175. }
  111176. /**
  111177. * Class used to run optimizations in order to reach a target frame rate
  111178. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111179. */
  111180. export class SceneOptimizer implements IDisposable {
  111181. private _isRunning;
  111182. private _options;
  111183. private _scene;
  111184. private _currentPriorityLevel;
  111185. private _targetFrameRate;
  111186. private _trackerDuration;
  111187. private _currentFrameRate;
  111188. private _sceneDisposeObserver;
  111189. private _improvementMode;
  111190. /**
  111191. * Defines an observable called when the optimizer reaches the target frame rate
  111192. */
  111193. onSuccessObservable: Observable<SceneOptimizer>;
  111194. /**
  111195. * Defines an observable called when the optimizer enables an optimization
  111196. */
  111197. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  111198. /**
  111199. * Defines an observable called when the optimizer is not able to reach the target frame rate
  111200. */
  111201. onFailureObservable: Observable<SceneOptimizer>;
  111202. /**
  111203. * Gets a boolean indicating if the optimizer is in improvement mode
  111204. */
  111205. readonly isInImprovementMode: boolean;
  111206. /**
  111207. * Gets the current priority level (0 at start)
  111208. */
  111209. readonly currentPriorityLevel: number;
  111210. /**
  111211. * Gets the current frame rate checked by the SceneOptimizer
  111212. */
  111213. readonly currentFrameRate: number;
  111214. /**
  111215. * Gets or sets the current target frame rate (60 by default)
  111216. */
  111217. /**
  111218. * Gets or sets the current target frame rate (60 by default)
  111219. */
  111220. targetFrameRate: number;
  111221. /**
  111222. * Gets or sets the current interval between two checks (every 2000ms by default)
  111223. */
  111224. /**
  111225. * Gets or sets the current interval between two checks (every 2000ms by default)
  111226. */
  111227. trackerDuration: number;
  111228. /**
  111229. * Gets the list of active optimizations
  111230. */
  111231. readonly optimizations: SceneOptimization[];
  111232. /**
  111233. * Creates a new SceneOptimizer
  111234. * @param scene defines the scene to work on
  111235. * @param options defines the options to use with the SceneOptimizer
  111236. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  111237. * @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)
  111238. */
  111239. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  111240. /**
  111241. * Stops the current optimizer
  111242. */
  111243. stop(): void;
  111244. /**
  111245. * Reset the optimizer to initial step (current priority level = 0)
  111246. */
  111247. reset(): void;
  111248. /**
  111249. * Start the optimizer. By default it will try to reach a specific framerate
  111250. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  111251. */
  111252. start(): void;
  111253. private _checkCurrentState;
  111254. /**
  111255. * Release all resources
  111256. */
  111257. dispose(): void;
  111258. /**
  111259. * Helper function to create a SceneOptimizer with one single line of code
  111260. * @param scene defines the scene to work on
  111261. * @param options defines the options to use with the SceneOptimizer
  111262. * @param onSuccess defines a callback to call on success
  111263. * @param onFailure defines a callback to call on failure
  111264. * @returns the new SceneOptimizer object
  111265. */
  111266. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  111267. }
  111268. }
  111269. declare module BABYLON {
  111270. /**
  111271. * Class used to serialize a scene into a string
  111272. */
  111273. export class SceneSerializer {
  111274. /**
  111275. * Clear cache used by a previous serialization
  111276. */
  111277. static ClearCache(): void;
  111278. /**
  111279. * Serialize a scene into a JSON compatible object
  111280. * @param scene defines the scene to serialize
  111281. * @returns a JSON compatible object
  111282. */
  111283. static Serialize(scene: Scene): any;
  111284. /**
  111285. * Serialize a mesh into a JSON compatible object
  111286. * @param toSerialize defines the mesh to serialize
  111287. * @param withParents defines if parents must be serialized as well
  111288. * @param withChildren defines if children must be serialized as well
  111289. * @returns a JSON compatible object
  111290. */
  111291. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  111292. }
  111293. }
  111294. declare module BABYLON {
  111295. /**
  111296. * This represents the different options avilable for the video capture.
  111297. */
  111298. export interface VideoRecorderOptions {
  111299. /** Defines the mime type of the video */
  111300. mimeType: string;
  111301. /** Defines the video the video should be recorded at */
  111302. fps: number;
  111303. /** Defines the chunk size for the recording data */
  111304. recordChunckSize: number;
  111305. /** The audio tracks to attach to the record */
  111306. audioTracks?: MediaStreamTrack[];
  111307. }
  111308. /**
  111309. * This can helps recording videos from BabylonJS.
  111310. * This is based on the available WebRTC functionalities of the browser.
  111311. *
  111312. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  111313. */
  111314. export class VideoRecorder {
  111315. private static readonly _defaultOptions;
  111316. /**
  111317. * Returns wehther or not the VideoRecorder is available in your browser.
  111318. * @param engine Defines the Babylon Engine to check the support for
  111319. * @returns true if supported otherwise false
  111320. */
  111321. static IsSupported(engine: Engine): boolean;
  111322. private readonly _options;
  111323. private _canvas;
  111324. private _mediaRecorder;
  111325. private _recordedChunks;
  111326. private _fileName;
  111327. private _resolve;
  111328. private _reject;
  111329. /**
  111330. * True wether a recording is already in progress.
  111331. */
  111332. readonly isRecording: boolean;
  111333. /**
  111334. * Create a new VideoCapture object which can help converting what you see in Babylon to
  111335. * a video file.
  111336. * @param engine Defines the BabylonJS Engine you wish to record
  111337. * @param options Defines options that can be used to customized the capture
  111338. */
  111339. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  111340. /**
  111341. * Stops the current recording before the default capture timeout passed in the startRecording
  111342. * functions.
  111343. */
  111344. stopRecording(): void;
  111345. /**
  111346. * Starts recording the canvas for a max duration specified in parameters.
  111347. * @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.
  111348. * @param maxDuration Defines the maximum recording time in seconds.
  111349. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  111350. * @return a promise callback at the end of the recording with the video data in Blob.
  111351. */
  111352. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  111353. /**
  111354. * Releases internal resources used during the recording.
  111355. */
  111356. dispose(): void;
  111357. private _handleDataAvailable;
  111358. private _handleError;
  111359. private _handleStop;
  111360. }
  111361. }
  111362. declare module BABYLON {
  111363. /**
  111364. * Helper class to push actions to a pool of workers.
  111365. */
  111366. export class WorkerPool implements IDisposable {
  111367. private _workerInfos;
  111368. private _pendingActions;
  111369. /**
  111370. * Constructor
  111371. * @param workers Array of workers to use for actions
  111372. */
  111373. constructor(workers: Array<Worker>);
  111374. /**
  111375. * Terminates all workers and clears any pending actions.
  111376. */
  111377. dispose(): void;
  111378. /**
  111379. * Pushes an action to the worker pool. If all the workers are active, the action will be
  111380. * pended until a worker has completed its action.
  111381. * @param action The action to perform. Call onComplete when the action is complete.
  111382. */
  111383. push(action: (worker: Worker, onComplete: () => void) => void): void;
  111384. private _execute;
  111385. }
  111386. }
  111387. declare module BABYLON {
  111388. /**
  111389. * Class containing a set of static utilities functions for screenshots
  111390. */
  111391. export class ScreenshotTools {
  111392. /**
  111393. * Captures a screenshot of the current rendering
  111394. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111395. * @param engine defines the rendering engine
  111396. * @param camera defines the source camera
  111397. * @param size This parameter can be set to a single number or to an object with the
  111398. * following (optional) properties: precision, width, height. If a single number is passed,
  111399. * it will be used for both width and height. If an object is passed, the screenshot size
  111400. * will be derived from the parameters. The precision property is a multiplier allowing
  111401. * rendering at a higher or lower resolution
  111402. * @param successCallback defines the callback receives a single parameter which contains the
  111403. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  111404. * src parameter of an <img> to display it
  111405. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  111406. * Check your browser for supported MIME types
  111407. */
  111408. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  111409. /**
  111410. * Generates an image screenshot from the specified camera.
  111411. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111412. * @param engine The engine to use for rendering
  111413. * @param camera The camera to use for rendering
  111414. * @param size This parameter can be set to a single number or to an object with the
  111415. * following (optional) properties: precision, width, height. If a single number is passed,
  111416. * it will be used for both width and height. If an object is passed, the screenshot size
  111417. * will be derived from the parameters. The precision property is a multiplier allowing
  111418. * rendering at a higher or lower resolution
  111419. * @param successCallback The callback receives a single parameter which contains the
  111420. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  111421. * src parameter of an <img> to display it
  111422. * @param mimeType The MIME type of the screenshot image (default: image/png).
  111423. * Check your browser for supported MIME types
  111424. * @param samples Texture samples (default: 1)
  111425. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  111426. * @param fileName A name for for the downloaded file.
  111427. */
  111428. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  111429. }
  111430. }
  111431. declare module BABYLON {
  111432. /**
  111433. * A cursor which tracks a point on a path
  111434. */
  111435. export class PathCursor {
  111436. private path;
  111437. /**
  111438. * Stores path cursor callbacks for when an onchange event is triggered
  111439. */
  111440. private _onchange;
  111441. /**
  111442. * The value of the path cursor
  111443. */
  111444. value: number;
  111445. /**
  111446. * The animation array of the path cursor
  111447. */
  111448. animations: Animation[];
  111449. /**
  111450. * Initializes the path cursor
  111451. * @param path The path to track
  111452. */
  111453. constructor(path: Path2);
  111454. /**
  111455. * Gets the cursor point on the path
  111456. * @returns A point on the path cursor at the cursor location
  111457. */
  111458. getPoint(): Vector3;
  111459. /**
  111460. * Moves the cursor ahead by the step amount
  111461. * @param step The amount to move the cursor forward
  111462. * @returns This path cursor
  111463. */
  111464. moveAhead(step?: number): PathCursor;
  111465. /**
  111466. * Moves the cursor behind by the step amount
  111467. * @param step The amount to move the cursor back
  111468. * @returns This path cursor
  111469. */
  111470. moveBack(step?: number): PathCursor;
  111471. /**
  111472. * Moves the cursor by the step amount
  111473. * If the step amount is greater than one, an exception is thrown
  111474. * @param step The amount to move the cursor
  111475. * @returns This path cursor
  111476. */
  111477. move(step: number): PathCursor;
  111478. /**
  111479. * Ensures that the value is limited between zero and one
  111480. * @returns This path cursor
  111481. */
  111482. private ensureLimits;
  111483. /**
  111484. * Runs onchange callbacks on change (used by the animation engine)
  111485. * @returns This path cursor
  111486. */
  111487. private raiseOnChange;
  111488. /**
  111489. * Executes a function on change
  111490. * @param f A path cursor onchange callback
  111491. * @returns This path cursor
  111492. */
  111493. onchange(f: (cursor: PathCursor) => void): PathCursor;
  111494. }
  111495. }
  111496. declare module BABYLON {
  111497. /** @hidden */
  111498. export var blurPixelShader: {
  111499. name: string;
  111500. shader: string;
  111501. };
  111502. }
  111503. declare module BABYLON {
  111504. /** @hidden */
  111505. export var bones300Declaration: {
  111506. name: string;
  111507. shader: string;
  111508. };
  111509. }
  111510. declare module BABYLON {
  111511. /** @hidden */
  111512. export var instances300Declaration: {
  111513. name: string;
  111514. shader: string;
  111515. };
  111516. }
  111517. declare module BABYLON {
  111518. /** @hidden */
  111519. export var pointCloudVertexDeclaration: {
  111520. name: string;
  111521. shader: string;
  111522. };
  111523. }
  111524. // Mixins
  111525. interface Window {
  111526. mozIndexedDB: IDBFactory;
  111527. webkitIndexedDB: IDBFactory;
  111528. msIndexedDB: IDBFactory;
  111529. webkitURL: typeof URL;
  111530. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  111531. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  111532. WebGLRenderingContext: WebGLRenderingContext;
  111533. MSGesture: MSGesture;
  111534. CANNON: any;
  111535. AudioContext: AudioContext;
  111536. webkitAudioContext: AudioContext;
  111537. PointerEvent: any;
  111538. Math: Math;
  111539. Uint8Array: Uint8ArrayConstructor;
  111540. Float32Array: Float32ArrayConstructor;
  111541. mozURL: typeof URL;
  111542. msURL: typeof URL;
  111543. VRFrameData: any; // WebVR, from specs 1.1
  111544. DracoDecoderModule: any;
  111545. setImmediate(handler: (...args: any[]) => void): number;
  111546. }
  111547. interface Document {
  111548. mozCancelFullScreen(): void;
  111549. msCancelFullScreen(): void;
  111550. webkitCancelFullScreen(): void;
  111551. requestPointerLock(): void;
  111552. exitPointerLock(): void;
  111553. mozFullScreen: boolean;
  111554. msIsFullScreen: boolean;
  111555. readonly webkitIsFullScreen: boolean;
  111556. readonly pointerLockElement: Element;
  111557. mozPointerLockElement: HTMLElement;
  111558. msPointerLockElement: HTMLElement;
  111559. webkitPointerLockElement: HTMLElement;
  111560. }
  111561. interface HTMLCanvasElement {
  111562. requestPointerLock(): void;
  111563. msRequestPointerLock?(): void;
  111564. mozRequestPointerLock?(): void;
  111565. webkitRequestPointerLock?(): void;
  111566. /** Track wether a record is in progress */
  111567. isRecording: boolean;
  111568. /** Capture Stream method defined by some browsers */
  111569. captureStream(fps?: number): MediaStream;
  111570. }
  111571. interface CanvasRenderingContext2D {
  111572. msImageSmoothingEnabled: boolean;
  111573. }
  111574. interface MouseEvent {
  111575. mozMovementX: number;
  111576. mozMovementY: number;
  111577. webkitMovementX: number;
  111578. webkitMovementY: number;
  111579. msMovementX: number;
  111580. msMovementY: number;
  111581. }
  111582. interface Navigator {
  111583. mozGetVRDevices: (any: any) => any;
  111584. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  111585. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  111586. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  111587. webkitGetGamepads(): Gamepad[];
  111588. msGetGamepads(): Gamepad[];
  111589. webkitGamepads(): Gamepad[];
  111590. }
  111591. interface HTMLVideoElement {
  111592. mozSrcObject: any;
  111593. }
  111594. interface Math {
  111595. fround(x: number): number;
  111596. imul(a: number, b: number): number;
  111597. }
  111598. interface WebGLProgram {
  111599. context?: WebGLRenderingContext;
  111600. vertexShader?: WebGLShader;
  111601. fragmentShader?: WebGLShader;
  111602. isParallelCompiled: boolean;
  111603. onCompiled?: () => void;
  111604. }
  111605. interface WebGLRenderingContext {
  111606. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  111607. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  111608. vertexAttribDivisor(index: number, divisor: number): void;
  111609. createVertexArray(): any;
  111610. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  111611. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  111612. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  111613. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  111614. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  111615. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  111616. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  111617. // Queries
  111618. createQuery(): WebGLQuery;
  111619. deleteQuery(query: WebGLQuery): void;
  111620. beginQuery(target: number, query: WebGLQuery): void;
  111621. endQuery(target: number): void;
  111622. getQueryParameter(query: WebGLQuery, pname: number): any;
  111623. getQuery(target: number, pname: number): any;
  111624. MAX_SAMPLES: number;
  111625. RGBA8: number;
  111626. READ_FRAMEBUFFER: number;
  111627. DRAW_FRAMEBUFFER: number;
  111628. UNIFORM_BUFFER: number;
  111629. HALF_FLOAT_OES: number;
  111630. RGBA16F: number;
  111631. RGBA32F: number;
  111632. R32F: number;
  111633. RG32F: number;
  111634. RGB32F: number;
  111635. R16F: number;
  111636. RG16F: number;
  111637. RGB16F: number;
  111638. RED: number;
  111639. RG: number;
  111640. R8: number;
  111641. RG8: number;
  111642. UNSIGNED_INT_24_8: number;
  111643. DEPTH24_STENCIL8: number;
  111644. /* Multiple Render Targets */
  111645. drawBuffers(buffers: number[]): void;
  111646. readBuffer(src: number): void;
  111647. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  111648. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  111649. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  111650. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  111651. // Occlusion Query
  111652. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  111653. ANY_SAMPLES_PASSED: number;
  111654. QUERY_RESULT_AVAILABLE: number;
  111655. QUERY_RESULT: number;
  111656. }
  111657. interface WebGLBuffer {
  111658. references: number;
  111659. capacity: number;
  111660. is32Bits: boolean;
  111661. }
  111662. interface WebGLProgram {
  111663. transformFeedback?: WebGLTransformFeedback | null;
  111664. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  111665. }
  111666. interface EXT_disjoint_timer_query {
  111667. QUERY_COUNTER_BITS_EXT: number;
  111668. TIME_ELAPSED_EXT: number;
  111669. TIMESTAMP_EXT: number;
  111670. GPU_DISJOINT_EXT: number;
  111671. QUERY_RESULT_EXT: number;
  111672. QUERY_RESULT_AVAILABLE_EXT: number;
  111673. queryCounterEXT(query: WebGLQuery, target: number): void;
  111674. createQueryEXT(): WebGLQuery;
  111675. beginQueryEXT(target: number, query: WebGLQuery): void;
  111676. endQueryEXT(target: number): void;
  111677. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  111678. deleteQueryEXT(query: WebGLQuery): void;
  111679. }
  111680. interface WebGLUniformLocation {
  111681. _currentState: any;
  111682. }
  111683. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  111684. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  111685. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  111686. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  111687. interface WebGLRenderingContext {
  111688. readonly RASTERIZER_DISCARD: number;
  111689. readonly DEPTH_COMPONENT24: number;
  111690. readonly TEXTURE_3D: number;
  111691. readonly TEXTURE_2D_ARRAY: number;
  111692. readonly TEXTURE_COMPARE_FUNC: number;
  111693. readonly TEXTURE_COMPARE_MODE: number;
  111694. readonly COMPARE_REF_TO_TEXTURE: number;
  111695. readonly TEXTURE_WRAP_R: number;
  111696. readonly HALF_FLOAT: number;
  111697. readonly RGB8: number;
  111698. readonly RED_INTEGER: number;
  111699. readonly RG_INTEGER: number;
  111700. readonly RGB_INTEGER: number;
  111701. readonly RGBA_INTEGER: number;
  111702. readonly R8_SNORM: number;
  111703. readonly RG8_SNORM: number;
  111704. readonly RGB8_SNORM: number;
  111705. readonly RGBA8_SNORM: number;
  111706. readonly R8I: number;
  111707. readonly RG8I: number;
  111708. readonly RGB8I: number;
  111709. readonly RGBA8I: number;
  111710. readonly R8UI: number;
  111711. readonly RG8UI: number;
  111712. readonly RGB8UI: number;
  111713. readonly RGBA8UI: number;
  111714. readonly R16I: number;
  111715. readonly RG16I: number;
  111716. readonly RGB16I: number;
  111717. readonly RGBA16I: number;
  111718. readonly R16UI: number;
  111719. readonly RG16UI: number;
  111720. readonly RGB16UI: number;
  111721. readonly RGBA16UI: number;
  111722. readonly R32I: number;
  111723. readonly RG32I: number;
  111724. readonly RGB32I: number;
  111725. readonly RGBA32I: number;
  111726. readonly R32UI: number;
  111727. readonly RG32UI: number;
  111728. readonly RGB32UI: number;
  111729. readonly RGBA32UI: number;
  111730. readonly RGB10_A2UI: number;
  111731. readonly R11F_G11F_B10F: number;
  111732. readonly RGB9_E5: number;
  111733. readonly RGB10_A2: number;
  111734. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  111735. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  111736. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  111737. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  111738. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  111739. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  111740. 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;
  111741. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  111742. readonly TRANSFORM_FEEDBACK: number;
  111743. readonly INTERLEAVED_ATTRIBS: number;
  111744. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  111745. createTransformFeedback(): WebGLTransformFeedback;
  111746. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  111747. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  111748. beginTransformFeedback(primitiveMode: number): void;
  111749. endTransformFeedback(): void;
  111750. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  111751. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111752. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111753. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111754. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  111755. }
  111756. interface ImageBitmap {
  111757. readonly width: number;
  111758. readonly height: number;
  111759. close(): void;
  111760. }
  111761. interface WebGLQuery extends WebGLObject {
  111762. }
  111763. declare var WebGLQuery: {
  111764. prototype: WebGLQuery;
  111765. new(): WebGLQuery;
  111766. };
  111767. interface WebGLSampler extends WebGLObject {
  111768. }
  111769. declare var WebGLSampler: {
  111770. prototype: WebGLSampler;
  111771. new(): WebGLSampler;
  111772. };
  111773. interface WebGLSync extends WebGLObject {
  111774. }
  111775. declare var WebGLSync: {
  111776. prototype: WebGLSync;
  111777. new(): WebGLSync;
  111778. };
  111779. interface WebGLTransformFeedback extends WebGLObject {
  111780. }
  111781. declare var WebGLTransformFeedback: {
  111782. prototype: WebGLTransformFeedback;
  111783. new(): WebGLTransformFeedback;
  111784. };
  111785. interface WebGLVertexArrayObject extends WebGLObject {
  111786. }
  111787. declare var WebGLVertexArrayObject: {
  111788. prototype: WebGLVertexArrayObject;
  111789. new(): WebGLVertexArrayObject;
  111790. };
  111791. // Type definitions for WebVR API
  111792. // Project: https://w3c.github.io/webvr/
  111793. // Definitions by: six a <https://github.com/lostfictions>
  111794. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  111795. interface VRDisplay extends EventTarget {
  111796. /**
  111797. * Dictionary of capabilities describing the VRDisplay.
  111798. */
  111799. readonly capabilities: VRDisplayCapabilities;
  111800. /**
  111801. * z-depth defining the far plane of the eye view frustum
  111802. * enables mapping of values in the render target depth
  111803. * attachment to scene coordinates. Initially set to 10000.0.
  111804. */
  111805. depthFar: number;
  111806. /**
  111807. * z-depth defining the near plane of the eye view frustum
  111808. * enables mapping of values in the render target depth
  111809. * attachment to scene coordinates. Initially set to 0.01.
  111810. */
  111811. depthNear: number;
  111812. /**
  111813. * An identifier for this distinct VRDisplay. Used as an
  111814. * association point in the Gamepad API.
  111815. */
  111816. readonly displayId: number;
  111817. /**
  111818. * A display name, a user-readable name identifying it.
  111819. */
  111820. readonly displayName: string;
  111821. readonly isConnected: boolean;
  111822. readonly isPresenting: boolean;
  111823. /**
  111824. * If this VRDisplay supports room-scale experiences, the optional
  111825. * stage attribute contains details on the room-scale parameters.
  111826. */
  111827. readonly stageParameters: VRStageParameters | null;
  111828. /**
  111829. * Passing the value returned by `requestAnimationFrame` to
  111830. * `cancelAnimationFrame` will unregister the callback.
  111831. * @param handle Define the hanle of the request to cancel
  111832. */
  111833. cancelAnimationFrame(handle: number): void;
  111834. /**
  111835. * Stops presenting to the VRDisplay.
  111836. * @returns a promise to know when it stopped
  111837. */
  111838. exitPresent(): Promise<void>;
  111839. /**
  111840. * Return the current VREyeParameters for the given eye.
  111841. * @param whichEye Define the eye we want the parameter for
  111842. * @returns the eye parameters
  111843. */
  111844. getEyeParameters(whichEye: string): VREyeParameters;
  111845. /**
  111846. * Populates the passed VRFrameData with the information required to render
  111847. * the current frame.
  111848. * @param frameData Define the data structure to populate
  111849. * @returns true if ok otherwise false
  111850. */
  111851. getFrameData(frameData: VRFrameData): boolean;
  111852. /**
  111853. * Get the layers currently being presented.
  111854. * @returns the list of VR layers
  111855. */
  111856. getLayers(): VRLayer[];
  111857. /**
  111858. * Return a VRPose containing the future predicted pose of the VRDisplay
  111859. * when the current frame will be presented. The value returned will not
  111860. * change until JavaScript has returned control to the browser.
  111861. *
  111862. * The VRPose will contain the position, orientation, velocity,
  111863. * and acceleration of each of these properties.
  111864. * @returns the pose object
  111865. */
  111866. getPose(): VRPose;
  111867. /**
  111868. * Return the current instantaneous pose of the VRDisplay, with no
  111869. * prediction applied.
  111870. * @returns the current instantaneous pose
  111871. */
  111872. getImmediatePose(): VRPose;
  111873. /**
  111874. * The callback passed to `requestAnimationFrame` will be called
  111875. * any time a new frame should be rendered. When the VRDisplay is
  111876. * presenting the callback will be called at the native refresh
  111877. * rate of the HMD. When not presenting this function acts
  111878. * identically to how window.requestAnimationFrame acts. Content should
  111879. * make no assumptions of frame rate or vsync behavior as the HMD runs
  111880. * asynchronously from other displays and at differing refresh rates.
  111881. * @param callback Define the eaction to run next frame
  111882. * @returns the request handle it
  111883. */
  111884. requestAnimationFrame(callback: FrameRequestCallback): number;
  111885. /**
  111886. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  111887. * Repeat calls while already presenting will update the VRLayers being displayed.
  111888. * @param layers Define the list of layer to present
  111889. * @returns a promise to know when the request has been fulfilled
  111890. */
  111891. requestPresent(layers: VRLayer[]): Promise<void>;
  111892. /**
  111893. * Reset the pose for this display, treating its current position and
  111894. * orientation as the "origin/zero" values. VRPose.position,
  111895. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  111896. * updated when calling resetPose(). This should be called in only
  111897. * sitting-space experiences.
  111898. */
  111899. resetPose(): void;
  111900. /**
  111901. * The VRLayer provided to the VRDisplay will be captured and presented
  111902. * in the HMD. Calling this function has the same effect on the source
  111903. * canvas as any other operation that uses its source image, and canvases
  111904. * created without preserveDrawingBuffer set to true will be cleared.
  111905. * @param pose Define the pose to submit
  111906. */
  111907. submitFrame(pose?: VRPose): void;
  111908. }
  111909. declare var VRDisplay: {
  111910. prototype: VRDisplay;
  111911. new(): VRDisplay;
  111912. };
  111913. interface VRLayer {
  111914. leftBounds?: number[] | Float32Array | null;
  111915. rightBounds?: number[] | Float32Array | null;
  111916. source?: HTMLCanvasElement | null;
  111917. }
  111918. interface VRDisplayCapabilities {
  111919. readonly canPresent: boolean;
  111920. readonly hasExternalDisplay: boolean;
  111921. readonly hasOrientation: boolean;
  111922. readonly hasPosition: boolean;
  111923. readonly maxLayers: number;
  111924. }
  111925. interface VREyeParameters {
  111926. /** @deprecated */
  111927. readonly fieldOfView: VRFieldOfView;
  111928. readonly offset: Float32Array;
  111929. readonly renderHeight: number;
  111930. readonly renderWidth: number;
  111931. }
  111932. interface VRFieldOfView {
  111933. readonly downDegrees: number;
  111934. readonly leftDegrees: number;
  111935. readonly rightDegrees: number;
  111936. readonly upDegrees: number;
  111937. }
  111938. interface VRFrameData {
  111939. readonly leftProjectionMatrix: Float32Array;
  111940. readonly leftViewMatrix: Float32Array;
  111941. readonly pose: VRPose;
  111942. readonly rightProjectionMatrix: Float32Array;
  111943. readonly rightViewMatrix: Float32Array;
  111944. readonly timestamp: number;
  111945. }
  111946. interface VRPose {
  111947. readonly angularAcceleration: Float32Array | null;
  111948. readonly angularVelocity: Float32Array | null;
  111949. readonly linearAcceleration: Float32Array | null;
  111950. readonly linearVelocity: Float32Array | null;
  111951. readonly orientation: Float32Array | null;
  111952. readonly position: Float32Array | null;
  111953. readonly timestamp: number;
  111954. }
  111955. interface VRStageParameters {
  111956. sittingToStandingTransform?: Float32Array;
  111957. sizeX?: number;
  111958. sizeY?: number;
  111959. }
  111960. interface Navigator {
  111961. getVRDisplays(): Promise<VRDisplay[]>;
  111962. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  111963. }
  111964. interface Window {
  111965. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  111966. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  111967. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  111968. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  111969. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  111970. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  111971. }
  111972. interface Gamepad {
  111973. readonly displayId: number;
  111974. }
  111975. interface XRDevice {
  111976. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  111977. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  111978. }
  111979. interface XRSession {
  111980. getInputSources(): Array<any>;
  111981. baseLayer: XRWebGLLayer;
  111982. requestFrameOfReference(type: string): Promise<void>;
  111983. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  111984. end(): Promise<void>;
  111985. requestAnimationFrame: Function;
  111986. addEventListener: Function;
  111987. }
  111988. interface XRSessionCreationOptions {
  111989. outputContext?: WebGLRenderingContext | null;
  111990. immersive?: boolean;
  111991. environmentIntegration?: boolean;
  111992. }
  111993. interface XRLayer {
  111994. getViewport: Function;
  111995. framebufferWidth: number;
  111996. framebufferHeight: number;
  111997. }
  111998. interface XRView {
  111999. projectionMatrix: Float32Array;
  112000. }
  112001. interface XRFrame {
  112002. getDevicePose: Function;
  112003. getInputPose: Function;
  112004. views: Array<XRView>;
  112005. baseLayer: XRLayer;
  112006. }
  112007. interface XRFrameOfReference {
  112008. }
  112009. interface XRWebGLLayer extends XRLayer {
  112010. framebuffer: WebGLFramebuffer;
  112011. }
  112012. declare var XRWebGLLayer: {
  112013. prototype: XRWebGLLayer;
  112014. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  112015. };